Compare commits

..

No commits in common. "master" and "v0.10.25" have entirely different histories.

6 changed files with 182 additions and 267 deletions

View File

@ -23,7 +23,7 @@ typedef struct
version CINERA_APP_VERSION = {
.Major = 0,
.Minor = 10,
.Patch = 30
.Patch = 25
};
#define __USE_XOPEN2K8 // NOTE(matt): O_NOFOLLOW
@ -210,12 +210,7 @@ typedef struct
int C;
int Seconds;
};
union
{
int D;
int Milliseconds;
};
} v4;
} v3;
void
Clear(void *V, uint64_t Size)
@ -903,8 +898,8 @@ FreeBook(memory_book *M)
void
FreeAndReinitialiseBook(memory_book *M)
{
uint64_t PageSize = M->PageSize;
uint64_t DataWidthInBytes = M->DataWidthInBytes;
int PageSize = M->PageSize;
int DataWidthInBytes = M->DataWidthInBytes;
FreeBook(M);
@ -2172,7 +2167,7 @@ IndexingError(string Filename, uint64_t LineNumber, severity Severity, char *Mes
}
void
PrintTimecode(FILE *Dest, v4 Timecode)
PrintTimecode(FILE *Dest, v3 Timecode)
{
Colourise(CS_BLUE_BOLD);
if(Timecode.Hours)
@ -2187,7 +2182,7 @@ PrintTimecode(FILE *Dest, v4 Timecode)
}
void
IndexingChronologyError(string *Filename, uint64_t LineNumber, v4 ThisTimecode, v4 PrevTimecode)
IndexingChronologyError(string *Filename, uint64_t LineNumber, v3 ThisTimecode, v3 PrevTimecode)
{
severity Severity = S_ERROR;
ErrorFilenameAndLineNumber(Filename, LineNumber, Severity, ED_INDEXING);
@ -4172,68 +4167,6 @@ LogEdit(edit_type_id EditType, string Lineage, string EntryID, string *EntryTitl
}
}
#define CINERA_HSL_TRANSPARENT_HUE 65535
typedef struct
{
unsigned int Hue:16;
unsigned int Saturation:8;
unsigned int Lightness:8;
} hsl_colour;
hsl_colour
CharToColour(char Char)
{
hsl_colour Colour;
if(Char >= 'a' && Char <= 'z')
{
Colour.Hue = (((float)Char - 'a') / ('z' - 'a') * 360);
Colour.Saturation = (((float)Char - 'a') / ('z' - 'a') * 26 + 74);
}
else if(Char >= 'A' && Char <= 'Z')
{
Colour.Hue = (((float)Char - 'A') / ('Z' - 'A') * 360);
Colour.Saturation = (((float)Char - 'A') / ('Z' - 'A') * 26 + 74);
}
else if(Char >= '0' && Char <= '9')
{
Colour.Hue = (((float)Char - '0') / ('9' - '0') * 360);
Colour.Saturation = (((float)Char - '0') / ('9' - '0') * 26 + 74);
}
else
{
Colour.Hue = 180;
Colour.Saturation = 50;
}
return Colour;
}
void
StringToColourHash(hsl_colour *Colour, string String)
{
Colour->Hue = 0;
Colour->Saturation = 0;
Colour->Lightness = 74;
for(int i = 0; i < String.Length; ++i)
{
Colour->Hue += CharToColour(String.Base[i]).Hue;
Colour->Saturation += CharToColour(String.Base[i]).Saturation;
}
Colour->Hue = Colour->Hue % 360;
Colour->Saturation = Colour->Saturation % 26 + 74;
}
bool
IsValidHSLColour(hsl_colour Colour)
{
return (Colour.Hue >= 0 && Colour.Hue < 360)
&& (Colour.Saturation >= 0 && Colour.Saturation <= 100)
&& (Colour.Lightness >= 0 && Colour.Lightness <= 100);
}
#define SLASH 1
#define NULLTERM 1
typedef struct
@ -4371,7 +4304,7 @@ typedef struct
typedef struct
{
v4 Timecode;
v3 Timecode;
int Identifier;
} identifier;
@ -4388,7 +4321,6 @@ typedef struct
{
string Marker;
string WrittenText;
hsl_colour Colour;
} category_info;
#define CopyString(Dest, DestSize, Format, ...) CopyString_(__LINE__, (Dest), (DestSize), (Format), ##__VA_ARGS__)
@ -4498,7 +4430,7 @@ CopyStringToBuffer_(int LineNumber, buffer *Dest, char *Format, ...)
}
int
DigitsInTimecode(v4 Timecode)
DigitsInTimecode(v3 Timecode)
{
int Result = 0;
int ColonChar = 1;
@ -4521,7 +4453,7 @@ DigitsInTimecode(v4 Timecode)
#define CopyTimecodeToBuffer(Dest, Timecode) CopyTimecodeToBuffer_(__LINE__, Dest, Timecode)
void
CopyTimecodeToBuffer_(int LineNumber, buffer *Dest, v4 Timecode)
CopyTimecodeToBuffer_(int LineNumber, buffer *Dest, v3 Timecode)
{
if(DigitsInTimecode(Timecode) + (Dest->Ptr - Dest->Location) >= Dest->Size)
{
@ -4783,16 +4715,18 @@ typedef struct
bool Resolving;
} clash_resolver;
void
InitClashResolver(clash_resolver *ClashResolver)
clash_resolver
InitClashResolver(void)
{
ClashResolver->Book[0] = InitBook(sizeof(clash_entry), 8);
ClashResolver->Book[1] = InitBook(sizeof(clash_entry), 8);
ClashResolver->Main = &ClashResolver->Book[0];
ClashResolver->Holder = &ClashResolver->Book[1];
ClashResolver->Chain = InitBookOfPointers(8);
ClashResolver->ChainStructure = CS_OPEN_ENDED;
ClashResolver->Resolving = FALSE;
clash_resolver Result = {};
Result.Book[0] = InitBook(sizeof(clash_entry), 8);
Result.Book[1] = InitBook(sizeof(clash_entry), 8);
Result.Main = &Result.Book[0];
Result.Holder = &Result.Book[1];
Result.Chain = InitBookOfPointers(8);
Result.ChainStructure = CS_OPEN_ENDED;
Result.Resolving = FALSE;
return Result;
}
void
@ -5529,17 +5463,69 @@ InitTemplate(template *Template, string Location, template_type Type)
Template->Metadata.NavBuffer = InitBook(sizeof(navigation_buffer), 4);
}
v4
V4(int A, int B, int C, int D)
v3
V3(int A, int B, int C)
{
v4 Result = { .A = A, .B = B, .C = C, .D = D };
v3 Result = { .A = A, .B = B, .C = C };
return Result;
}
float
TimecodeToDottedSeconds(v4 Timecode)
int
TimecodeToSeconds(v3 Timecode)
{
return (float)Timecode.Hours * SECONDS_PER_HOUR + (float)Timecode.Minutes * SECONDS_PER_MINUTE + (float)Timecode.Seconds + (float)Timecode.Milliseconds / 1000;
return Timecode.Hours * SECONDS_PER_HOUR + Timecode.Minutes * SECONDS_PER_MINUTE + Timecode.Seconds;
}
typedef struct
{
unsigned int Hue:16;
unsigned int Saturation:8;
unsigned int Lightness:8;
} hsl_colour;
hsl_colour
CharToColour(char Char)
{
hsl_colour Colour;
if(Char >= 'a' && Char <= 'z')
{
Colour.Hue = (((float)Char - 'a') / ('z' - 'a') * 360);
Colour.Saturation = (((float)Char - 'a') / ('z' - 'a') * 26 + 74);
}
else if(Char >= 'A' && Char <= 'Z')
{
Colour.Hue = (((float)Char - 'A') / ('Z' - 'A') * 360);
Colour.Saturation = (((float)Char - 'A') / ('Z' - 'A') * 26 + 74);
}
else if(Char >= '0' && Char <= '9')
{
Colour.Hue = (((float)Char - '0') / ('9' - '0') * 360);
Colour.Saturation = (((float)Char - '0') / ('9' - '0') * 26 + 74);
}
else
{
Colour.Hue = 180;
Colour.Saturation = 50;
}
return Colour;
}
void
StringToColourHash(hsl_colour *Colour, string String)
{
Colour->Hue = 0;
Colour->Saturation = 0;
Colour->Lightness = 74;
for(int i = 0; i < String.Length; ++i)
{
Colour->Hue += CharToColour(String.Base[i]).Hue;
Colour->Saturation += CharToColour(String.Base[i]).Saturation;
}
Colour->Hue = Colour->Hue % 360;
Colour->Saturation = Colour->Saturation % 26 + 74;
}
char *
@ -8111,7 +8097,7 @@ BuildCredits(string HMMLFilepath, buffer *CreditsMenu, HMML_VideoMetaData *Metad
}
void
InsertCategory(_memory_book(category_info) *GlobalTopics, _memory_book(category_info) *LocalTopics, _memory_book(category_info) *GlobalMedia, _memory_book(category_info) *LocalMedia, string Marker, hsl_colour *Colour)
InsertCategory(_memory_book(category_info) *GlobalTopics, _memory_book(category_info) *LocalTopics, _memory_book(category_info) *GlobalMedia, _memory_book(category_info) *LocalMedia, string Marker)
{
medium *Medium = GetMediumFromProject(CurrentProject, Marker);
@ -8212,15 +8198,11 @@ InsertCategory(_memory_book(category_info) *GlobalTopics, _memory_book(category_
{
category_info *Src = GetPlaceInBook(LocalTopics, CategoryCount - 1);
category_info *Dest = GetPlaceInBook(LocalTopics, CategoryCount);
*Dest = *Src;
Dest->Marker = Src->Marker;
}
category_info *New = GetPlaceInBook(LocalTopics, CategoryCount);
New->Marker = Marker;
if(Colour)
{
New->Colour = *Colour;
}
break;
}
}
@ -8231,10 +8213,6 @@ InsertCategory(_memory_book(category_info) *GlobalTopics, _memory_book(category_
{
category_info *New = GetPlaceInBook(LocalTopics, TopicIndex);
New->Marker = Marker;
if(Colour)
{
New->Colour = *Colour;
}
}
bool MadeGlobalSpace = FALSE;
@ -8258,15 +8236,11 @@ InsertCategory(_memory_book(category_info) *GlobalTopics, _memory_book(category_
{
category_info *Src = GetPlaceInBook(GlobalTopics, CategoryCount - 1);
category_info *Dest = GetPlaceInBook(GlobalTopics, CategoryCount);
*Dest = *Src;
Dest->Marker = Src->Marker;
}
category_info *New = GetPlaceInBook(GlobalTopics, CategoryCount);
New->Marker = Marker;
if(Colour)
{
New->Colour = *Colour;
}
break;
}
}
@ -8278,10 +8252,6 @@ InsertCategory(_memory_book(category_info) *GlobalTopics, _memory_book(category_
{
category_info *New = GetPlaceInBook(GlobalTopics, TopicIndex);
New->Marker = Marker;
if(Colour)
{
New->Colour = *Colour;
}
}
}
}
@ -8373,18 +8343,9 @@ BuildCategoryIcons(buffer *CategoryIcons, _memory_book(category_info) *LocalTopi
CopyString(SanitisedMarker, sizeof(SanitisedMarker), "%.*s", (int)This->Marker.Length, This->Marker.Base);
SanitisePunctuation(SanitisedMarker);
CopyStringToBuffer(CategoryIcons,
"<div title=\"%.*s\" class=\"category %s\"",
CopyStringToBuffer(CategoryIcons, "<div title=\"%.*s\" class=\"category %s\"></div>",
(int)This->Marker.Length, This->Marker.Base,
SanitisedMarker);
if(IsValidHSLColour(This->Colour))
{
CopyStringToBuffer(CategoryIcons,
" data-hue=\"%u\" data-saturation=\"%u%%\"",
This->Colour.Hue, This->Colour.Saturation);
}
CopyStringToBuffer(CategoryIcons,
"></div>");
}
}
@ -8664,7 +8625,7 @@ BuildQuote(memory_book *Strings, quote_info *Info, string Speaker, int ID, bool
}
rc
GenerateTopicColours(neighbourhood *N, string Topic, hsl_colour *Dest)
GenerateTopicColours(neighbourhood *N, string Topic)
{
rc Result = RC_SUCCESS;
// NOTE(matt): Stack-string
@ -8675,15 +8636,6 @@ GenerateTopicColours(neighbourhood *N, string Topic, hsl_colour *Dest)
medium *Medium = GetMediumFromProject(CurrentProject, Topic);
if(!Medium)
{
if(StringsMatch(Topic, Wrap0("nullTopic")))
{
Dest->Hue = CINERA_HSL_TRANSPARENT_HUE;
}
else
{
StringToColourHash(Dest, Topic);
}
file Topics = {};
Topics.Path = 0;
Topics.Buffer.ID = BID_TOPICS;
@ -8749,8 +8701,10 @@ GenerateTopicColours(neighbourhood *N, string Topic, hsl_colour *Dest)
}
else
{
hsl_colour Colour;
StringToColourHash(&Colour, Topic);
WriteToFile(Topics.Handle, ".category.%s { border: 1px solid hsl(%d, %d%%, %d%%); background: hsl(%d, %d%%, %d%%); }\n",
SanitisedTopic, Dest->Hue, Dest->Saturation, Dest->Lightness, Dest->Hue, Dest->Saturation, Dest->Lightness);
SanitisedTopic, Colour.Hue, Colour.Saturation, Colour.Lightness, Colour.Hue, Colour.Saturation, Colour.Lightness);
}
#if DEBUG_MEM
@ -10862,9 +10816,9 @@ HMMLOutputLocationIs(neighbourhood *N, char *OutputLocation)
}
bool
TimecodeIs(v4 Timecode, int Hours, int Minutes, int Seconds, int Milliseconds)
TimecodeIs(v3 Timecode, int Hours, int Minutes, int Seconds)
{
return Timecode.Hours == Hours && Timecode.Minutes == Minutes && Timecode.Seconds == Seconds && Timecode.Milliseconds == Milliseconds;
return Timecode.Hours == Hours && Timecode.Minutes == Minutes && Timecode.Seconds == Seconds;
}
rc
@ -10875,14 +10829,14 @@ ProcessTimestamp(buffers *CollationBuffers, neighbourhood *N, string Filepath, m
bool *HasQuoteMenu, bool *HasReferenceMenu, bool *HasFilterMenu, bool *RequiresCineraJS,
int *QuoteIdentifier, int *RefIdentifier,
_memory_book(category_info) *Topics, _memory_book(category_info) *Media,
HMML_Timestamp *Timestamp, v4 *PreviousTimecode)
HMML_Timestamp *Timestamp, v3 *PreviousTimecode)
{
MEM_TEST_TOP();
// TODO(matt): Introduce and use a SystemError() in here
rc Result = RC_SUCCESS;
v4 Timecode = V4(Timestamp->h, Timestamp->m, Timestamp->s, Timestamp->ms);
if(TimecodeToDottedSeconds(Timecode) >= TimecodeToDottedSeconds(*PreviousTimecode))
v3 Timecode = V3(Timestamp->h, Timestamp->m, Timestamp->s);
if(TimecodeToSeconds(Timecode) >= TimecodeToSeconds(*PreviousTimecode))
{
*PreviousTimecode = Timecode;
@ -10903,8 +10857,8 @@ ProcessTimestamp(buffers *CollationBuffers, neighbourhood *N, string Filepath, m
CopyStringToBuffer(&IndexBuffers->Header,
" <div data-timestamp=\"%.3f\"",
TimecodeToDottedSeconds(Timecode));
" <div data-timestamp=\"%d\"",
TimecodeToSeconds(Timecode));
CopyStringToBuffer(&IndexBuffers->Class,
" class=\"marker");
@ -10940,7 +10894,7 @@ ProcessTimestamp(buffers *CollationBuffers, neighbourhood *N, string Filepath, m
{
*HasFilterMenu = TRUE;
}
InsertCategory(Topics, &LocalTopics, Media, &LocalMedia, Wrap0("authored"), NULL);
InsertCategory(Topics, &LocalTopics, Media, &LocalMedia, Wrap0("authored"));
hsl_colour AuthorColour;
StringToColourHash(&AuthorColour, Author);
// TODO(matt): That EDITION_NETWORK site database API-polling stuff
@ -10965,15 +10919,14 @@ ProcessTimestamp(buffers *CollationBuffers, neighbourhood *N, string Filepath, m
HMML_MarkerType Type = Timestamp->markers[MarkerIndex].type;
if(Type == HMML_CATEGORY)
{
hsl_colour TopicColour = {};
Result = GenerateTopicColours(N, Wrap0(Timestamp->markers[MarkerIndex].marker), &TopicColour);
Result = GenerateTopicColours(N, Wrap0(Timestamp->markers[MarkerIndex].marker));
if(Result == RC_SUCCESS)
{
if(!*HasFilterMenu)
{
*HasFilterMenu = TRUE;
}
InsertCategory(Topics, &LocalTopics, Media, &LocalMedia, Wrap0(Timestamp->markers[MarkerIndex].marker), &TopicColour);
InsertCategory(Topics, &LocalTopics, Media, &LocalMedia, Wrap0(Timestamp->markers[MarkerIndex].marker));
CopyStringToBuffer(&IndexBuffers->Text, "%.*s", (int)StringLength(Readable), InPtr);
}
else
@ -11162,10 +11115,10 @@ ProcessTimestamp(buffers *CollationBuffers, neighbourhood *N, string Filepath, m
" <div class=\"quote_byline\">&mdash;%.*s, %.*s</div>\n"
" </span>\n"
" <div class=\"ref_indices\">\n"
" <span data-timestamp=\"%.3f\" class=\"timecode\"><span class=\"ref_index\">[&#%d;]</span><span class=\"time\">",
" <span data-timestamp=\"%d\" class=\"timecode\"><span class=\"ref_index\">[&#%d;]</span><span class=\"time\">",
(int)QuoteUsername.Length, QuoteUsername.Base,
(int)DateString.Length, DateString.Base, // TODO(matt): Convert Unixtime to date-string
TimecodeToDottedSeconds(Timecode),
TimecodeToSeconds(Timecode),
*QuoteIdentifier);
CopyTimecodeToBuffer(&MenuBuffers->Quote, Timecode);
CopyStringToBuffer(&MenuBuffers->Quote, "</span></span>\n"
@ -11189,7 +11142,7 @@ ProcessTimestamp(buffers *CollationBuffers, neighbourhood *N, string Filepath, m
if(Result == RC_SUCCESS)
{
CopyStringToBuffer(&CollationBuffers->SearchEntry, "\"%.3f\": \"", TimecodeToDottedSeconds(Timecode));
CopyStringToBuffer(&CollationBuffers->SearchEntry, "\"%d\": \"", TimecodeToSeconds(Timecode));
if(Timestamp->quote.present && !Timestamp->text[0])
{
CopyStringToBuffer(&CollationBuffers->SearchEntry, "\u201C");
@ -11204,15 +11157,14 @@ ProcessTimestamp(buffers *CollationBuffers, neighbourhood *N, string Filepath, m
while(MarkerIndex < Timestamp->marker_count)
{
hsl_colour TopicColour = {};
Result = GenerateTopicColours(N, Wrap0(Timestamp->markers[MarkerIndex].marker), &TopicColour);
Result = GenerateTopicColours(N, Wrap0(Timestamp->markers[MarkerIndex].marker));
if(Result == RC_SUCCESS)
{
if(!*HasFilterMenu)
{
*HasFilterMenu = TRUE;
}
InsertCategory(Topics, &LocalTopics, Media, &LocalMedia, Wrap0(Timestamp->markers[MarkerIndex].marker), &TopicColour);
InsertCategory(Topics, &LocalTopics, Media, &LocalMedia, Wrap0(Timestamp->markers[MarkerIndex].marker));
++MarkerIndex;
}
else
@ -11225,11 +11177,10 @@ ProcessTimestamp(buffers *CollationBuffers, neighbourhood *N, string Filepath, m
{
if(LocalTopics.ItemCount == 0)
{
hsl_colour TopicColour = {};
Result = GenerateTopicColours(N, Wrap0("nullTopic"), &TopicColour);
Result = GenerateTopicColours(N, Wrap0("nullTopic"));
if(Result == RC_SUCCESS)
{
InsertCategory(Topics, &LocalTopics, Media, &LocalMedia, Wrap0("nullTopic"), &TopicColour);
InsertCategory(Topics, &LocalTopics, Media, &LocalMedia, Wrap0("nullTopic"));
}
}
@ -11237,7 +11188,7 @@ ProcessTimestamp(buffers *CollationBuffers, neighbourhood *N, string Filepath, m
{
if(LocalMedia.ItemCount == 0)
{
InsertCategory(Topics, &LocalTopics, Media, &LocalMedia, DefaultMedium->ID, NULL);
InsertCategory(Topics, &LocalTopics, Media, &LocalMedia, DefaultMedium->ID);
}
BuildTimestampClass(&IndexBuffers->Class, &LocalTopics, &LocalMedia, DefaultMedium->ID);
@ -11880,7 +11831,7 @@ HMMLToBuffers(buffers *CollationBuffers, template *BespokeTemplate, string BaseF
Print(stdout, "\n\n --- Entering Timestamps Loop ---\n\n\n\n");
#endif
v4 PreviousTimecode = {};
v3 PreviousTimecode = {};
for(int TimestampIndex = 0; TimestampIndex < HMML.timestamp_count; ++TimestampIndex)
{
// TODO(matt): Thoroughly test this reorganisation
@ -11967,7 +11918,7 @@ HMMLToBuffers(buffers *CollationBuffers, template *BespokeTemplate, string BaseF
{
identifier *ThisIdentifier = GetPlaceInBook(&This->Identifier, j);
CopyStringToBuffer(&MenuBuffers.Reference,
"<span data-timestamp=\"%.3f\" class=\"timecode\"><span class=\"ref_index\">[%d]</span><span class=\"time\">", TimecodeToDottedSeconds(ThisIdentifier->Timecode), ThisIdentifier->Identifier);
"<span data-timestamp=\"%d\" class=\"timecode\"><span class=\"ref_index\">[%d]</span><span class=\"time\">", TimecodeToSeconds(ThisIdentifier->Timecode), ThisIdentifier->Identifier);
CopyTimecodeToBuffer(&MenuBuffers.Reference, ThisIdentifier->Timecode);
CopyStringToBuffer(&MenuBuffers.Reference, "</span></span>");
}
@ -12035,21 +11986,13 @@ HMMLToBuffers(buffers *CollationBuffers, template *BespokeTemplate, string BaseF
bool NullTopic = StringsMatch(This->Marker, Wrap0("nullTopic"));
CopyStringToBuffer(&MenuBuffers.FilterTopics,
" <div%s class=\"filter_content %s\">\n"
" <span class=\"icon category %s\"",
NullTopic ? " title=\"Timestamps that don't fit into the above topic(s) may be filtered using this pseudo-topic\"" : "",
SanitisedMarker,
SanitisedMarker);
if(IsValidHSLColour(This->Colour))
{
CopyStringToBuffer(&MenuBuffers.FilterTopics,
" data-hue=\"%u\" data-saturation=\"%u%%\"",
This->Colour.Hue, This->Colour.Saturation);
}
CopyStringToBuffer(&MenuBuffers.FilterTopics,
"></span><span class=\"cineraText\">%.*s</span>\n"
" <div %sclass=\"filter_content %s\">\n"
" <span class=\"icon category %s\"></span><span class=\"cineraText\">%.*s</span>\n"
" </div>\n",
NullTopic ? "title=\"Timestamps that don't fit into the above topic(s) may be filtered using this pseudo-topic\" " : "",
SanitisedMarker,
SanitisedMarker,
NullTopic ? (int)sizeof("(null topic)")-1 : (int)This->Marker.Length,
NullTopic ? "(null topic)" : This->Marker.Base);
}
@ -18323,8 +18266,7 @@ main(int ArgC, char **Args)
CollationBuffers.Search.ID = BID_COLLATION_BUFFERS_SEARCH; // NOTE(matt): Allocated by SearchToBuffer()
memory_book TokensList = InitBook(sizeof(tokens), 8);
clash_resolver ClashResolver = {};
InitClashResolver(&ClashResolver);
clash_resolver ClashResolver = InitClashResolver();
template BespokeTemplate = {};
neighbourhood Neighbourhood = {};

View File

@ -42,7 +42,7 @@ window.addEventListener("resize", function() {
}
});
screen.orientation.onchange = function() {
window.onorientationchange = function() {
if(CineraProps.IsMobile)
{
setTimeout(DelayedUpdateSize, 512, player);
@ -65,12 +65,3 @@ document.addEventListener("keydown", function(ev) {
ev.preventDefault();
}
});
document.addEventListener("fullscreenchange", function() {
if(!document.fullscreenElement && CineraProps.V == views.SUPERTHEATRE)
{
CineraProps.V = views.THEATRE;
localStorage.setItem(player.cineraViewStorageItem, views.THEATRE);
player.updateSize();
}
});

View File

@ -163,9 +163,9 @@ function Player(cineraElement, refsCallback) {
for (var i = 0; i < markerEls.length; ++i) {
var markerEl = markerEls[i];
var marker = {
timestamp: parseFloat(markerEl.getAttribute("data-timestamp")),
timestamp: parseInt(markerEl.getAttribute("data-timestamp"), 10),
ref: markerEl.getAttribute("data-ref"),
endTime: (i < markerEls.length - 1 ? parseFloat(markerEls[i+1].getAttribute("data-timestamp")) : null),
endTime: (i < markerEls.length - 1 ? parseInt(markerEls[i+1].getAttribute("data-timestamp"), 10) : null),
el: markerEl,
fadedProgress: markerEl.querySelector(".progress.faded"),
progress: markerEl.querySelector(".progress.main"),
@ -955,7 +955,8 @@ Player.prototype.InitMobileStyle = function()
this.IconifyMenuTogglers();
this.InitMobileControls();
this.ConnectMobileControls();
this.ApplyMobileStyle(this.videoContainer);
var VideoContainer = this.root.querySelector(".video_container");
this.ApplyMobileStyle(VideoContainer);
}
// Call this after changing the size of the video container in order to update the platform player.
@ -1237,7 +1238,7 @@ Player.prototype.doFrame = function() {
this.platformPlayer.getCurrentTime()
.then(function(Result) {
Parent.currentTime = Result;
if(Parent.desiredTime == -1) { Parent.desiredTime = Parent.currentTime; }
if(this.desiredTime == -1) { this.desiredTime = this.currentTime; }
Parent.updateProgress();
});
} break;
@ -1460,10 +1461,7 @@ Player.prototype.onPlatformReady = function() {
case vod_platform.VIMEO:
{
this.videoContainer.style.position = "relative";
if(!CineraProps.IsMobile)
{
this.videoContainer.style.alignSelf = "unset";
}
this.videoContainer.style.alignSelf = "unset";
var CallData = {
id: this.videoContainer.getAttribute("data-videoId"),
@ -1554,11 +1552,10 @@ Player.prototype.updateLink = function()
} break;
case vod_platform.VIMEO:
{
var Parent = this;
this.platformPlayer.getCurrentTime()
.then(function(Response)
{
Parent.link.value = baseURL + "#" + Math.round(Response);
this.link.value = baseURL + "#" + Math.round(Response);
});
} break;
case vod_platform.YOUTUBE:
@ -1631,7 +1628,6 @@ Player.prototype.toggleMenuVisibility = function(MenuID, Trigger) {
if(element.classList.contains("visible"))
{
HideMenu(element);
this.MenusFocused.MenuID = menu_id.UNSET;
if(Trigger == trigger_id.KEYBOARD && this.Menus[menu_id.MARKERS].Item.LastFocused)
{
@ -2017,12 +2013,12 @@ Player.prototype.handleKey = function(key) {
case menu_id.MARKERS:
{
var time = this.MenusFocused.Item.getAttribute("data-timestamp");
this.setTimeThenPlay(parseFloat(time));
this.setTimeThenPlay(parseInt(time));
} break;
case menu_id.QUOTES:
{
var time = this.MenusFocused.Item.querySelector(".timecode").getAttribute("data-timestamp");
this.setTimeThenPlay(parseFloat(time));
this.setTimeThenPlay(parseInt(time));
if(this.currentMarker)
{
this.setScroller(this.Menus[menu_id.MARKERS], this.currentMarker.el, true, false);
@ -2032,7 +2028,7 @@ Player.prototype.handleKey = function(key) {
case menu_id.REFERENCES:
{
var time = this.MenusFocused.Identifier.getAttribute("data-timestamp");
this.setTimeThenPlay(parseFloat(time));
this.setTimeThenPlay(parseInt(time));
if(this.currentMarker)
{
this.setScroller(this.Menus[menu_id.MARKERS], this.currentMarker.el, true, false);
@ -2054,7 +2050,7 @@ Player.prototype.handleKey = function(key) {
if(this.currentMarker && this.currentMarker.el)
{
var time = this.currentMarker.el.getAttribute("data-timestamp");
this.setTimeThenPlay(parseFloat(time));
this.setTimeThenPlay(parseInt(time));
this.setScroller(this.Menus[menu_id.MARKERS], this.currentMarker.el, true, false);
}
}
@ -2914,7 +2910,7 @@ Player.prototype.mouseOverCredits = function(item) {
function mouseSkipToTimecode(player, time, ev)
{
player.setTimeThenPlay(parseFloat(time));
player.setTimeThenPlay(parseInt(time, 10));
ev.preventDefault();
ev.stopPropagation();
return false;

View File

@ -13,9 +13,6 @@ DeriveReliableWindowDimensions()
Y: null,
};
var ScrollPosX = window.scrollX;
var ScrollPosY = window.scrollY;
var DisplaySettings = [];
for(var i = 0; i < document.body.children.length; ++i)
{
@ -43,9 +40,6 @@ DeriveReliableWindowDimensions()
Child.style.display = DisplaySettings.shift();
}
ScrollTriggeredInternally = true;
window.scroll(ScrollPosX, ScrollPosY);
return Result;
}
@ -82,7 +76,7 @@ function IsVisible(Element, WindowDim) {
function
GetRealOrientation(PreferredLandscape, IsMobile)
{
var Result = screen.orientation.angle;
var Result = window.orientation;
var WindowDim = GetWindowDim(IsMobile);
if(WindowDim.Y > WindowDim.X)
{
@ -323,7 +317,6 @@ function IsInRangeEx(Min, N, Max)
}
/* Auto-scrolling */
var ScrollTriggeredInternally = false;
var LastScrollYPos = 0;
var ScrollTicking = false;
var ScrollerFunction;
@ -390,11 +383,7 @@ function
InitScrollEventListener(Element, IsMobile, StickyObscuringElement)
{
window.addEventListener('scroll', function() {
if(ScrollTriggeredInternally)
{
ScrollTriggeredInternally = false;
}
else if(ScrollCondition == undefined || ScrollCondition == true)
if(ScrollCondition == undefined || ScrollCondition == true)
{
LastScrollYPos = window.scrollY;
@ -551,6 +540,35 @@ BindHelp(Button, DocumentationContainer)
})
}
function RGBtoHSL(colour)
{
var rgb = colour.slice(4, -1).split(", ");
var red = rgb[0];
var green = rgb[1];
var blue = rgb[2];
var min = Math.min(red, green, blue);
var max = Math.max(red, green, blue);
var chroma = max - min;
var hue = 0;
if(max == red)
{
hue = ((green - blue) / chroma) % 6;
}
else if(max == green)
{
hue = ((blue - red) / chroma) + 2;
}
else if(max == blue)
{
hue = ((red - green) / chroma) + 4;
}
var saturation = chroma / 255 * 100;
hue = (hue * 60) < 0 ? 360 + (hue * 60) : (hue * 60);
return [hue, saturation]
}
function getBackgroundColourRGB(element) {
var Colour = getComputedStyle(element).getPropertyValue("background-color");
var depth = 0;
@ -581,34 +599,28 @@ function setTextLightness(textElement)
{
var textHue = textElement.getAttribute("data-hue");
var textSaturation = textElement.getAttribute("data-saturation");
if(textHue && textSaturation)
if(getBackgroundBrightness(textElement.parentNode) < 127)
{
if(getBackgroundBrightness(textElement.parentNode) < 127)
{
textElement.style.color = ("hsl(" + textHue + ", " + textSaturation + ", 76%)");
}
else
{
textElement.style.color = ("hsl(" + textHue + ", " + textSaturation + ", 24%)");
}
textElement.style.color = ("hsl(" + textHue + ", " + textSaturation + ", 76%)");
}
else
{
textElement.style.color = ("hsl(" + textHue + ", " + textSaturation + ", 24%)");
}
}
function setDotLightness(topicDot)
{
var dotHue = topicDot.getAttribute("data-hue");
var dotSaturation = topicDot.getAttribute("data-saturation");
if(dotHue && dotSaturation)
var Hue = RGBtoHSL(getComputedStyle(topicDot).getPropertyValue("background-color"))[0];
var Saturation = RGBtoHSL(getComputedStyle(topicDot).getPropertyValue("background-color"))[1];
if(getBackgroundBrightness(topicDot.parentNode) < 127)
{
if(getBackgroundBrightness(topicDot.parentNode) < 127)
{
topicDot.style.backgroundColor = ("hsl(" + dotHue + ", " + dotSaturation + ", 76%)");
topicDot.style.borderColor = ("hsl(" + dotHue + ", " + dotSaturation + ", 76%)");
}
else
{
topicDot.style.backgroundColor = ("hsl(" + dotHue + ", " + dotSaturation + ", 47%)");
topicDot.style.borderColor = ("hsl(" + dotHue + ", " + dotSaturation + ", 47%)");
}
topicDot.style.backgroundColor = ("hsl(" + Hue + ", " + Saturation + "%, 76%)");
topicDot.style.borderColor = ("hsl(" + Hue + ", " + Saturation + "%, 76%)");
}
else
{
topicDot.style.backgroundColor = ("hsl(" + Hue + ", " + Saturation + "%, 47%)");
topicDot.style.borderColor = ("hsl(" + Hue + ", " + Saturation + "%, 47%)");
}
}

View File

@ -213,11 +213,11 @@ function prepareToParseIndexFile(project)
mode = "markers";
episode.markers = [];
} else if (mode == "markers") {
var match = line.match(/"(\d+.\d+)": "(.+)"/);
var match = line.match(/"(\d+)": "(.+)"/);
if (match == null) {
console.log(name, line);
} else {
var totalTime = parseFloat(line.slice(1));
var totalTime = parseInt(line.slice(1));
var marker = {
totalTime: totalTime,
prettyTime: markerTime(totalTime),
@ -292,7 +292,7 @@ function markerTime(totalTime) {
var markTime = "(";
var hours = Math.floor(totalTime / 60 / 60);
var minutes = Math.floor(totalTime / 60) % 60;
var seconds = Math.floor(totalTime) % 60;
var seconds = totalTime % 60;
if (hours > 0) {
markTime += padTimeComponent(hours) + ":";
}
@ -460,7 +460,7 @@ function runSearch(refresh) {
Search.ResultsSummary.style.display = "none";
}
var totalTime = Math.floor(totalSeconds/60/60) + "h " + Math.floor(totalSeconds/60)%60 + "m " + Math.floor(totalSeconds)%60 + "s ";
var totalTime = Math.floor(totalSeconds/60/60) + "h " + Math.floor(totalSeconds/60)%60 + "m " + totalSeconds%60 + "s ";
Search.ResultsSummary.textContent = "Found: " + numEpisodes + " episodes, " + numMarkers + " markers, " + totalTime + "total.";
}
@ -3866,7 +3866,7 @@ InitResizeEventListener()
function
InitOrientationChangeListener()
{
screen.orientation.onchange = function()
window.onorientationchange = function()
{
if(CineraProps.IsMobile)
{

View File

@ -76,7 +76,7 @@ typedef struct {
typedef struct {
int line;
int h, m, s, ms;
int h, m, s;
char* text;
char* author;
@ -471,7 +471,7 @@ next_attr:
static void _hmml_parse_timecode(struct _hmml_parser* p, HMML_Timestamp* ts)
{
unsigned int h = 0, m = 0, s = 0, ms = 0;
unsigned int h = 0, m = 0, s = 0;
int offset = 0;
int count = sscanf(p->cursor, "[%u:%u%n", &m, &s, &offset);
@ -485,7 +485,7 @@ static void _hmml_parse_timecode(struct _hmml_parser* p, HMML_Timestamp* ts)
if(c == ':') {
unsigned int tmp;
offset = 0;
if(sscanf(p->cursor, ":%u%n", &tmp, &offset) != 1 || offset == 0) {
if(sscanf(p->cursor, ":%u]%n", &tmp, &offset) != 1 || offset == 0) {
_hmml_err(p, "Unable to parse 3-part timecode");
}
@ -494,27 +494,6 @@ static void _hmml_parse_timecode(struct _hmml_parser* p, HMML_Timestamp* ts)
s = tmp;
p->cursor += offset;
c = *p->cursor;
}
if(c == '.') {
unsigned int tmp;
offset = 0;
int non_number_chars = 2;
int digits_in_100 = 3;
int max_chars_to_parse = non_number_chars + digits_in_100;
if(sscanf(p->cursor, ".%u]%n", &tmp, &offset) != 1 || offset == 0 || offset > max_chars_to_parse) {
_hmml_err(p, "Unable to parse %u.5-part timecode", h ? 3 : 2);
}
for(int i = offset - non_number_chars; i < digits_in_100; ++i) {
tmp *= 10;
}
ms = tmp;
p->cursor += offset;
} else if(c != ']') {
_hmml_err(p, "Unable to parse timecode");
@ -522,10 +501,6 @@ static void _hmml_parse_timecode(struct _hmml_parser* p, HMML_Timestamp* ts)
++p->cursor;
}
if(ms >= 1000) {
_hmml_err(p, "Milliseconds cannot exceed 999");
}
if(s >= 60) {
_hmml_err(p, "Seconds cannot exceed 59");
}
@ -537,7 +512,6 @@ static void _hmml_parse_timecode(struct _hmml_parser* p, HMML_Timestamp* ts)
ts->h = h;
ts->m = m;
ts->s = s;
ts->ms = ms;
}
static void _hmml_store_marker(struct _hmml_parser* p, HMML_Timestamp* ts, char** out, char* text_mem, size_t text_mem_size)
@ -850,7 +824,7 @@ void hmml_free(HMML_Output* out)
}
const struct HMML_Version hmml_version = {
2, 0, 15
2, 0, 14
};
#undef HSTX