Compare commits

..

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

6 changed files with 586 additions and 861 deletions

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,7 @@ window.addEventListener("resize", function() {
} }
}); });
screen.orientation.onchange = function() { window.onorientationchange = function() {
if(CineraProps.IsMobile) if(CineraProps.IsMobile)
{ {
setTimeout(DelayedUpdateSize, 512, player); setTimeout(DelayedUpdateSize, 512, player);
@ -65,12 +65,3 @@ document.addEventListener("keydown", function(ev) {
ev.preventDefault(); 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) { for (var i = 0; i < markerEls.length; ++i) {
var markerEl = markerEls[i]; var markerEl = markerEls[i];
var marker = { var marker = {
timestamp: parseFloat(markerEl.getAttribute("data-timestamp")), timestamp: parseInt(markerEl.getAttribute("data-timestamp"), 10),
ref: markerEl.getAttribute("data-ref"), 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, el: markerEl,
fadedProgress: markerEl.querySelector(".progress.faded"), fadedProgress: markerEl.querySelector(".progress.faded"),
progress: markerEl.querySelector(".progress.main"), progress: markerEl.querySelector(".progress.main"),
@ -955,7 +955,8 @@ Player.prototype.InitMobileStyle = function()
this.IconifyMenuTogglers(); this.IconifyMenuTogglers();
this.InitMobileControls(); this.InitMobileControls();
this.ConnectMobileControls(); 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. // 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() this.platformPlayer.getCurrentTime()
.then(function(Result) { .then(function(Result) {
Parent.currentTime = Result; Parent.currentTime = Result;
if(Parent.desiredTime == -1) { Parent.desiredTime = Parent.currentTime; } if(this.desiredTime == -1) { this.desiredTime = this.currentTime; }
Parent.updateProgress(); Parent.updateProgress();
}); });
} break; } break;
@ -1460,10 +1461,7 @@ Player.prototype.onPlatformReady = function() {
case vod_platform.VIMEO: case vod_platform.VIMEO:
{ {
this.videoContainer.style.position = "relative"; this.videoContainer.style.position = "relative";
if(!CineraProps.IsMobile) this.videoContainer.style.alignSelf = "unset";
{
this.videoContainer.style.alignSelf = "unset";
}
var CallData = { var CallData = {
id: this.videoContainer.getAttribute("data-videoId"), id: this.videoContainer.getAttribute("data-videoId"),
@ -1554,11 +1552,10 @@ Player.prototype.updateLink = function()
} break; } break;
case vod_platform.VIMEO: case vod_platform.VIMEO:
{ {
var Parent = this;
this.platformPlayer.getCurrentTime() this.platformPlayer.getCurrentTime()
.then(function(Response) .then(function(Response)
{ {
Parent.link.value = baseURL + "#" + Math.round(Response); this.link.value = baseURL + "#" + Math.round(Response);
}); });
} break; } break;
case vod_platform.YOUTUBE: case vod_platform.YOUTUBE:
@ -1631,7 +1628,6 @@ Player.prototype.toggleMenuVisibility = function(MenuID, Trigger) {
if(element.classList.contains("visible")) if(element.classList.contains("visible"))
{ {
HideMenu(element); HideMenu(element);
this.MenusFocused.MenuID = menu_id.UNSET;
if(Trigger == trigger_id.KEYBOARD && this.Menus[menu_id.MARKERS].Item.LastFocused) 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: case menu_id.MARKERS:
{ {
var time = this.MenusFocused.Item.getAttribute("data-timestamp"); var time = this.MenusFocused.Item.getAttribute("data-timestamp");
this.setTimeThenPlay(parseFloat(time)); this.setTimeThenPlay(parseInt(time));
} break; } break;
case menu_id.QUOTES: case menu_id.QUOTES:
{ {
var time = this.MenusFocused.Item.querySelector(".timecode").getAttribute("data-timestamp"); var time = this.MenusFocused.Item.querySelector(".timecode").getAttribute("data-timestamp");
this.setTimeThenPlay(parseFloat(time)); this.setTimeThenPlay(parseInt(time));
if(this.currentMarker) if(this.currentMarker)
{ {
this.setScroller(this.Menus[menu_id.MARKERS], this.currentMarker.el, true, false); 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: case menu_id.REFERENCES:
{ {
var time = this.MenusFocused.Identifier.getAttribute("data-timestamp"); var time = this.MenusFocused.Identifier.getAttribute("data-timestamp");
this.setTimeThenPlay(parseFloat(time)); this.setTimeThenPlay(parseInt(time));
if(this.currentMarker) if(this.currentMarker)
{ {
this.setScroller(this.Menus[menu_id.MARKERS], this.currentMarker.el, true, false); 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) if(this.currentMarker && this.currentMarker.el)
{ {
var time = this.currentMarker.el.getAttribute("data-timestamp"); 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); 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) function mouseSkipToTimecode(player, time, ev)
{ {
player.setTimeThenPlay(parseFloat(time)); player.setTimeThenPlay(parseInt(time, 10));
ev.preventDefault(); ev.preventDefault();
ev.stopPropagation(); ev.stopPropagation();
return false; return false;

View File

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

View File

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

View File

@ -76,7 +76,7 @@ typedef struct {
typedef struct { typedef struct {
int line; int line;
int h, m, s, ms; int h, m, s;
char* text; char* text;
char* author; char* author;
@ -471,7 +471,7 @@ next_attr:
static void _hmml_parse_timecode(struct _hmml_parser* p, HMML_Timestamp* ts) 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 offset = 0;
int count = sscanf(p->cursor, "[%u:%u%n", &m, &s, &offset); 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 == ':') { if(c == ':') {
unsigned int tmp; unsigned int tmp;
offset = 0; 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"); _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; s = tmp;
p->cursor += offset; 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 != ']') { } else if(c != ']') {
_hmml_err(p, "Unable to parse timecode"); _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; ++p->cursor;
} }
if(ms >= 1000) {
_hmml_err(p, "Milliseconds cannot exceed 999");
}
if(s >= 60) { if(s >= 60) {
_hmml_err(p, "Seconds cannot exceed 59"); _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->h = h;
ts->m = m; ts->m = m;
ts->s = s; 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) 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 = { const struct HMML_Version hmml_version = {
2, 0, 15 2, 0, 14
}; };
#undef HSTX #undef HSTX