2021-01-25 18:09:30 +00:00
|
|
|
var cinera = document.querySelector(".cinera");
|
|
|
|
var baseURL = location.hash ? (location.toString().substr(0, location.toString().length - location.hash.length)) : location;
|
|
|
|
|
2019-03-07 20:16:27 +00:00
|
|
|
var originalTextContent = {
|
|
|
|
TitleQuotes: null,
|
|
|
|
TitleReferences: null,
|
|
|
|
TitleCredits: null,
|
|
|
|
EpisodePrev: null,
|
|
|
|
EpisodeNext: null,
|
|
|
|
};
|
|
|
|
|
2017-11-11 00:34:47 +00:00
|
|
|
var menuState = [];
|
2021-01-25 18:09:30 +00:00
|
|
|
var titleBar = cinera.querySelector(".cineraMenus");
|
|
|
|
var quotesMenu = null;
|
|
|
|
var referencesMenu = null;
|
|
|
|
var filterMenu = null;
|
|
|
|
var viewsMenu = null;
|
|
|
|
var linkMenu = null;
|
|
|
|
var creditsMenu = null;
|
|
|
|
var sourceMenus = null;
|
|
|
|
var helpButton = null;
|
|
|
|
var helpDocumentation = null;
|
2017-11-11 00:34:47 +00:00
|
|
|
|
2021-02-04 00:13:55 +00:00
|
|
|
// NOTE(matt): One set of markers per page. There is code to support multiple, which we may want to extend everywhere
|
|
|
|
var MarkersContainer = cinera.querySelector(".markers_container");
|
|
|
|
|
2018-01-17 20:15:00 +00:00
|
|
|
var views = {
|
2019-03-07 20:16:27 +00:00
|
|
|
REGULAR: 0,
|
|
|
|
THEATRE: 1,
|
|
|
|
SUPERTHEATRE: 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
var devices = {
|
|
|
|
DESKTOP: 0,
|
|
|
|
MOBILE: 1,
|
2018-01-17 20:15:00 +00:00
|
|
|
};
|
2019-03-07 20:16:27 +00:00
|
|
|
|
2021-02-04 00:13:55 +00:00
|
|
|
var CineraProps = {
|
2018-01-17 20:15:00 +00:00
|
|
|
C: null,
|
|
|
|
V: views.REGULAR,
|
|
|
|
Z: null,
|
|
|
|
X: null,
|
|
|
|
Y: null,
|
|
|
|
W: null,
|
2018-02-23 23:36:42 +00:00
|
|
|
mW: null,
|
2018-01-17 20:15:00 +00:00
|
|
|
H: null,
|
2018-02-23 23:36:42 +00:00
|
|
|
mH: null,
|
2019-03-07 20:16:27 +00:00
|
|
|
P: null,
|
2021-01-25 18:09:30 +00:00
|
|
|
Display: null,
|
|
|
|
FlexDirection: null,
|
|
|
|
JustifyContent: null,
|
2021-02-04 00:13:55 +00:00
|
|
|
O: null,
|
2021-02-10 22:41:46 +00:00
|
|
|
IsMobile: IsMobile(),
|
2021-01-25 18:09:30 +00:00
|
|
|
ScrollX: null,
|
|
|
|
ScrollY: null,
|
2018-01-17 20:15:00 +00:00
|
|
|
};
|
2021-02-12 23:48:02 +00:00
|
|
|
CineraProps.O = GetRealOrientation(orientations.LANDSCAPE_LEFT, CineraProps.IsMobile);
|
2018-01-17 20:15:00 +00:00
|
|
|
|
2021-01-25 18:09:30 +00:00
|
|
|
if(titleBar)
|
2018-01-17 20:15:00 +00:00
|
|
|
{
|
2021-01-25 18:09:30 +00:00
|
|
|
quotesMenu = titleBar.querySelector(".quotes_container");
|
|
|
|
if(quotesMenu)
|
2018-01-17 20:15:00 +00:00
|
|
|
{
|
2021-01-25 18:09:30 +00:00
|
|
|
originalTextContent.TitleQuotes = quotesMenu.previousElementSibling.textContent;
|
|
|
|
menuState.push(quotesMenu);
|
|
|
|
var quoteItems = quotesMenu.querySelectorAll(".ref");
|
|
|
|
if(quoteItems)
|
|
|
|
{
|
|
|
|
for(var i = 0; i < quoteItems.length; ++i)
|
2018-01-17 20:15:00 +00:00
|
|
|
{
|
2021-01-25 18:09:30 +00:00
|
|
|
quoteItems[i].addEventListener("mouseenter", function(ev) {
|
|
|
|
mouseOverQuotes(this);
|
|
|
|
})
|
|
|
|
};
|
|
|
|
}
|
|
|
|
var quoteTimecodes = quotesMenu.querySelectorAll(".refs .ref .ref_indices .timecode");
|
|
|
|
for (var i = 0; i < quoteTimecodes.length; ++i) {
|
|
|
|
quoteTimecodes[i].addEventListener("click", function(ev) {
|
|
|
|
if (player) {
|
|
|
|
var time = ev.currentTarget.getAttribute("data-timestamp");
|
|
|
|
mouseSkipToTimecode(player, time, ev);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
var lastFocusedQuote = null;
|
2018-01-17 20:15:00 +00:00
|
|
|
}
|
|
|
|
|
2021-01-25 18:09:30 +00:00
|
|
|
referencesMenu = titleBar.querySelector(".references_container");
|
|
|
|
if(referencesMenu)
|
|
|
|
{
|
|
|
|
originalTextContent.TitleReferences = referencesMenu.previousElementSibling.textContent;
|
|
|
|
menuState.push(referencesMenu);
|
|
|
|
var referenceItems = referencesMenu.querySelectorAll(".ref");
|
|
|
|
if(referenceItems)
|
|
|
|
{
|
|
|
|
for(var i = 0; i < referenceItems.length; ++i)
|
|
|
|
{
|
|
|
|
referenceItems[i].addEventListener("mouseenter", function(ev) {
|
|
|
|
mouseOverReferences(this);
|
|
|
|
})
|
|
|
|
};
|
|
|
|
var lastFocusedReference = null;
|
|
|
|
var lastFocusedIdentifier = null;
|
|
|
|
}
|
2018-05-22 21:43:59 +00:00
|
|
|
|
2021-01-25 18:09:30 +00:00
|
|
|
var refTimecodes = referencesMenu.querySelectorAll(".refs .ref .ref_indices .timecode");
|
|
|
|
for (var i = 0; i < refTimecodes.length; ++i) {
|
|
|
|
refTimecodes[i].addEventListener("click", function(ev) {
|
|
|
|
if (player) {
|
|
|
|
var time = ev.currentTarget.getAttribute("data-timestamp");
|
|
|
|
mouseSkipToTimecode(player, time, ev);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2018-05-22 21:43:59 +00:00
|
|
|
|
2021-01-25 18:09:30 +00:00
|
|
|
if(referencesMenu || quotesMenu)
|
|
|
|
{
|
|
|
|
var refSources = titleBar.querySelectorAll(".refs .ref"); // This is for both quotes and refs
|
|
|
|
for (var i = 0; i < refSources.length; ++i) {
|
|
|
|
refSources[i].addEventListener("click", function(ev) {
|
|
|
|
if (player) {
|
|
|
|
player.pause();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2018-05-22 21:43:59 +00:00
|
|
|
|
2021-01-25 18:09:30 +00:00
|
|
|
filterMenu = titleBar.querySelector(".filter_container");
|
|
|
|
if(filterMenu)
|
|
|
|
{
|
|
|
|
menuState.push(filterMenu);
|
|
|
|
var lastFocusedCategory = null;
|
|
|
|
var lastFocusedTopic = null;
|
|
|
|
var lastFocusedMedium = null;
|
2018-05-22 21:43:59 +00:00
|
|
|
|
2021-01-25 18:09:30 +00:00
|
|
|
var filter = filterMenu.parentNode;
|
2017-11-11 00:34:47 +00:00
|
|
|
|
2021-01-25 18:09:30 +00:00
|
|
|
var filterModeElement = filter.querySelector(".filter_mode");
|
|
|
|
filterModeElement.addEventListener("click", function(ev) {
|
|
|
|
ev.stopPropagation();
|
|
|
|
toggleFilterMode();
|
|
|
|
});
|
|
|
|
|
|
|
|
var filterMode = filterModeElement.classList[1];
|
|
|
|
var filterItems = filter.querySelectorAll(".filter_content");
|
|
|
|
|
|
|
|
var filterInitState = new Object();
|
|
|
|
var filterState = new Object();
|
|
|
|
for(var i = 0; i < filterItems.length; ++i)
|
|
|
|
{
|
|
|
|
filterItems[i].addEventListener("mouseenter", function(ev) {
|
|
|
|
navigateFilter(this);
|
|
|
|
})
|
|
|
|
|
|
|
|
filterItems[i].addEventListener("click", function(ev) {
|
|
|
|
ev.stopPropagation();
|
|
|
|
filterItemToggle(this);
|
|
|
|
});
|
|
|
|
|
|
|
|
var filterItemName = filterItems[i].classList.item(1);
|
|
|
|
if(filterItems[i].parentNode.classList.contains("filter_topics"))
|
2017-11-11 00:34:47 +00:00
|
|
|
{
|
2021-01-25 18:09:30 +00:00
|
|
|
filterInitState[filterItemName] = { "type" : "topic", "off": (filterItems[i].classList.item(2) == "off") };
|
|
|
|
filterState[filterItemName] = { "type" : "topic", "off": (filterItems[i].classList.item(2) == "off") };
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
filterInitState[filterItemName] = { "type" : "medium", "off": (filterItems[i].classList.item(2) == "off") };
|
|
|
|
filterState[filterItemName] = { "type" : "medium", "off": (filterItems[i].classList.item(2) == "off") };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
viewsMenu = titleBar.querySelector(".views");
|
2021-02-10 22:41:46 +00:00
|
|
|
if(viewsMenu && !CineraProps.IsMobile)
|
2021-01-25 18:09:30 +00:00
|
|
|
{
|
|
|
|
menuState.push(viewsMenu);
|
|
|
|
var viewsContainer = viewsMenu.querySelector(".views_container");
|
|
|
|
viewsMenu.addEventListener("mouseenter", function(ev) {
|
|
|
|
handleMouseOverViewsMenu();
|
|
|
|
});
|
|
|
|
viewsMenu.addEventListener("mouseleave", function(ev) {
|
|
|
|
viewsContainer.style.display = "none";
|
|
|
|
});
|
|
|
|
|
|
|
|
var viewItems = viewsMenu.querySelectorAll(".view");
|
|
|
|
for(var i = 0; i < viewItems.length; ++i)
|
|
|
|
{
|
|
|
|
viewItems[i].addEventListener("click", function(ev) {
|
|
|
|
switch(this.getAttribute("data-id"))
|
2017-11-11 00:34:47 +00:00
|
|
|
{
|
2021-01-25 18:09:30 +00:00
|
|
|
case "regular":
|
|
|
|
case "theatre":
|
|
|
|
{
|
|
|
|
toggleTheatreMode();
|
|
|
|
} break;
|
|
|
|
case "super":
|
|
|
|
{
|
|
|
|
toggleSuperTheatreMode();
|
|
|
|
} break;
|
2017-11-11 00:34:47 +00:00
|
|
|
}
|
2021-01-25 18:09:30 +00:00
|
|
|
});
|
|
|
|
}
|
2017-11-11 00:34:47 +00:00
|
|
|
}
|
2020-05-09 17:33:25 +00:00
|
|
|
|
2021-01-25 18:09:30 +00:00
|
|
|
linkMenu = titleBar.querySelector(".link_container");
|
|
|
|
linkAnnotation = true;
|
|
|
|
if(linkMenu)
|
|
|
|
{
|
|
|
|
menuState.push(linkMenu);
|
2017-11-11 00:34:47 +00:00
|
|
|
|
2021-01-25 18:09:30 +00:00
|
|
|
var linkMode = linkMenu.querySelector("#cineraLinkMode");
|
|
|
|
var link = linkMenu.querySelector("#cineraLink");
|
2018-04-17 23:05:14 +00:00
|
|
|
|
2021-01-25 18:09:30 +00:00
|
|
|
linkMode.addEventListener("click", function(ev) {
|
|
|
|
ev.stopPropagation();
|
|
|
|
toggleLinkMode(linkMode, link);
|
|
|
|
});
|
2018-04-17 23:05:14 +00:00
|
|
|
|
2021-01-25 18:09:30 +00:00
|
|
|
link.addEventListener("click", function(ev) {
|
|
|
|
CopyToClipboard(link);
|
|
|
|
toggleMenuVisibility(linkMenu);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
creditsMenu = titleBar.querySelector(".credits_container");
|
|
|
|
if(creditsMenu)
|
|
|
|
{
|
|
|
|
originalTextContent.TitleCredits = creditsMenu.previousElementSibling.textContent;
|
|
|
|
menuState.push(creditsMenu);
|
|
|
|
var lastFocusedCreditItem = null;
|
|
|
|
|
|
|
|
var creditItems = creditsMenu.querySelectorAll(".person, .support");
|
|
|
|
for(var i = 0; i < creditItems.length; ++i)
|
|
|
|
{
|
|
|
|
creditItems[i].addEventListener("mouseenter", function(ev) {
|
|
|
|
if(this != lastFocusedCreditItem)
|
|
|
|
{
|
|
|
|
lastFocusedCreditItem.classList.remove("focused");
|
|
|
|
unfocusSprite(lastFocusedCreditItem);
|
|
|
|
if(lastFocusedCreditItem.classList.contains("support"))
|
|
|
|
{
|
|
|
|
setSpriteLightness(lastFocusedCreditItem.firstChild);
|
|
|
|
}
|
|
|
|
lastFocusedCreditItem = this;
|
|
|
|
focusedElement = lastFocusedCreditItem;
|
|
|
|
focusedElement.classList.add("focused");
|
|
|
|
focusSprite(focusedElement);
|
|
|
|
if(focusedElement.classList.contains("support"))
|
|
|
|
{
|
|
|
|
setSpriteLightness(focusedElement.firstChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceMenus = titleBar.querySelectorAll(".menu");
|
|
|
|
|
|
|
|
helpButton = titleBar.querySelector(".cineraHelp");
|
|
|
|
helpDocumentation = helpButton.querySelector(".help_container");
|
|
|
|
BindHelp(helpButton, helpDocumentation);
|
|
|
|
}
|
2017-11-11 00:34:47 +00:00
|
|
|
|
|
|
|
var focusedElement = null;
|
|
|
|
var focusedIdentifier = null;
|
|
|
|
|
2021-01-25 18:09:30 +00:00
|
|
|
var playerContainer = cinera.querySelector(".cineraPlayerContainer")
|
2019-03-07 20:16:27 +00:00
|
|
|
var prevEpisode = playerContainer.querySelector(".episodeMarker.prev");
|
|
|
|
if(prevEpisode) { originalTextContent.EpisodePrev = prevEpisode.firstChild.textContent; }
|
|
|
|
var nextEpisode = playerContainer.querySelector(".episodeMarker.next");
|
|
|
|
if(nextEpisode) { originalTextContent.EpisodeNext = nextEpisode.firstChild.textContent; }
|
|
|
|
var testMarkers = playerContainer.querySelectorAll(".marker");
|
2018-01-15 21:52:24 +00:00
|
|
|
|
2019-03-07 20:16:27 +00:00
|
|
|
// NOTE(matt): All the originalTextContent values must be set by this point, because the player's construction may need them
|
2021-01-25 18:09:30 +00:00
|
|
|
var MobileCineraContentRuleSelector = ".cinera.mobile .cineraPlayerContainer .markers_container > .markers .marker .cineraContent";
|
|
|
|
var MobileCineraContentRule = GetOrSetRule(MobileCineraContentRuleSelector);
|
|
|
|
|
2021-01-27 21:58:56 +00:00
|
|
|
var MenuContainerRuleSelector = ".cineraMenus > .menu .quotes_container, .cineraMenus > .menu .references_container, .cineraMenus > .menu .filter_container, .cineraMenus > .menu .views_container, .cineraMenus > .menu .link_container, .cineraMenus > .menu .credits_container";
|
|
|
|
var MenuContainerRule = GetOrSetRule(MenuContainerRuleSelector);
|
|
|
|
|
2021-02-10 22:41:46 +00:00
|
|
|
if(CineraProps.IsMobile)
|
2021-01-25 18:09:30 +00:00
|
|
|
{
|
|
|
|
InitMobileStyle();
|
|
|
|
}
|
2021-01-27 21:58:56 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
var MenuMaxHeight = cinera.offsetHeight - titleBar.offsetHeight - 4;
|
|
|
|
MenuContainerRule.style.maxHeight = MenuMaxHeight + "px";
|
|
|
|
}
|
2021-01-25 18:09:30 +00:00
|
|
|
|
2017-11-11 00:34:47 +00:00
|
|
|
var player = new Player(playerContainer, onRefChanged);
|
2018-04-17 23:05:14 +00:00
|
|
|
|
2021-02-10 22:41:46 +00:00
|
|
|
if(CineraProps.IsMobile)
|
2021-01-25 18:09:30 +00:00
|
|
|
{
|
|
|
|
ConnectMobileControls(player);
|
|
|
|
}
|
|
|
|
|
2018-04-17 23:05:14 +00:00
|
|
|
var cineraViewStorageItem = "cineraView";
|
2021-01-25 18:09:30 +00:00
|
|
|
|
2018-04-17 23:05:14 +00:00
|
|
|
if(viewsMenu && localStorage.getItem(cineraViewStorageItem))
|
|
|
|
{
|
|
|
|
toggleTheatreMode();
|
|
|
|
}
|
|
|
|
|
2021-01-25 18:09:30 +00:00
|
|
|
InitScrollEventListener(cinera);
|
|
|
|
|
2021-02-12 23:48:02 +00:00
|
|
|
function
|
|
|
|
DelayedUpdateSize()
|
|
|
|
{
|
|
|
|
player.updateSize();
|
|
|
|
}
|
|
|
|
|
2021-02-04 00:13:55 +00:00
|
|
|
window.addEventListener("resize", function() {
|
|
|
|
if(CineraProps.IsMobile)
|
|
|
|
{
|
2021-02-12 23:48:02 +00:00
|
|
|
setTimeout(DelayedUpdateSize, 512);
|
2021-02-04 00:13:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player.updateSize();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
window.onorientationchange = function() {
|
|
|
|
if(CineraProps.IsMobile)
|
|
|
|
{
|
2021-02-12 23:48:02 +00:00
|
|
|
setTimeout(DelayedUpdateSize, 512);
|
2021-02-04 00:13:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player.updateSize();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-11-11 00:34:47 +00:00
|
|
|
document.addEventListener("keydown", function(ev) {
|
|
|
|
var key = ev.key;
|
|
|
|
if(ev.getModifierState("Shift") && key == " ")
|
|
|
|
{
|
|
|
|
key = "capitalSpace";
|
|
|
|
}
|
|
|
|
|
2018-05-22 21:43:59 +00:00
|
|
|
if(!ev.getModifierState("Control") && handleKey(key) == true && focusedElement)
|
2017-11-11 00:34:47 +00:00
|
|
|
{
|
|
|
|
ev.preventDefault();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
for(var i = 0; i < sourceMenus.length; ++i)
|
|
|
|
{
|
|
|
|
sourceMenus[i].addEventListener("mouseenter", function(ev) {
|
2021-01-25 18:09:30 +00:00
|
|
|
handleMenuTogglerInteraction(this, ev.type);
|
2017-11-11 00:34:47 +00:00
|
|
|
})
|
|
|
|
sourceMenus[i].addEventListener("mouseleave", function(ev) {
|
2021-01-25 18:09:30 +00:00
|
|
|
handleMenuTogglerInteraction(this, ev.type);
|
|
|
|
})
|
|
|
|
sourceMenus[i].addEventListener("click", function(ev) {
|
|
|
|
handleMenuTogglerInteraction(this, ev.type);
|
2017-11-11 00:34:47 +00:00
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
var colouredItems = playerContainer.querySelectorAll(".author, .member, .project");
|
|
|
|
for(i = 0; i < colouredItems.length; ++i)
|
|
|
|
{
|
|
|
|
setTextLightness(colouredItems[i]);
|
|
|
|
}
|
|
|
|
|
2021-01-25 18:09:30 +00:00
|
|
|
var topicDots = cinera.querySelectorAll(".category");
|
2017-11-11 00:34:47 +00:00
|
|
|
for(var i = 0; i < topicDots.length; ++i)
|
|
|
|
{
|
|
|
|
setDotLightness(topicDots[i]);
|
|
|
|
}
|
|
|
|
|
2018-04-17 23:05:14 +00:00
|
|
|
var lastAnnotationStorageItem = "cineraTimecode_" + window.location.pathname;
|
|
|
|
var lastAnnotation;
|
2017-11-11 00:34:47 +00:00
|
|
|
if(location.hash) {
|
|
|
|
player.setTime(location.hash.startsWith('#') ? location.hash.substr(1) : location.hash);
|
|
|
|
}
|
2018-04-17 23:05:14 +00:00
|
|
|
else if(lastAnnotation = localStorage.getItem(lastAnnotationStorageItem))
|
|
|
|
{
|
|
|
|
player.setTime(lastAnnotation);
|
|
|
|
}
|