2022-07-29 22:34:12 +01:00
|
|
|
/*
|
|
|
|
This file is (C) Captain ALM
|
|
|
|
Under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License
|
|
|
|
*/
|
2022-07-30 21:03:47 +01:00
|
|
|
var EntryData = []
|
|
|
|
var EntryIndices = []
|
2022-07-30 17:59:14 +01:00
|
|
|
var SortOrderStateI = true
|
2022-07-30 18:05:11 +01:00
|
|
|
var SortOrderBStateI = true
|
2022-07-30 21:03:47 +01:00
|
|
|
var SortOrderEnabled = false
|
|
|
|
var SortValue = ""
|
|
|
|
var OrderValue = ""
|
2022-07-30 16:49:44 +01:00
|
|
|
function SetupJS() {
|
2022-07-30 21:03:47 +01:00
|
|
|
SetupIndexArray()
|
2022-07-30 16:23:00 +01:00
|
|
|
SetupJSTheme()
|
2022-07-30 17:59:14 +01:00
|
|
|
SetupJSHSO()
|
2022-07-30 21:03:47 +01:00
|
|
|
SetupJSSOI()
|
2022-08-17 21:44:52 +01:00
|
|
|
SetupJSRSN()
|
2022-07-30 16:23:00 +01:00
|
|
|
}
|
2022-07-30 16:19:45 +01:00
|
|
|
function CreateEntry(id, name, videourl, videotype, start, end, duration) {
|
|
|
|
EntryData[id] = {
|
2022-07-30 15:07:10 +01:00
|
|
|
name: name,
|
|
|
|
videourl: videourl,
|
|
|
|
videotype: videotype,
|
|
|
|
start: Date.parse(start),
|
|
|
|
end: Date.parse(end),
|
2022-07-30 16:19:45 +01:00
|
|
|
duration : parseInt(duration, 10)
|
2022-07-30 15:07:10 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
function CreateVideoPlaceholder(id) {
|
2022-07-30 21:06:04 +01:00
|
|
|
var imgPH = document.createElement("img")
|
2022-07-30 15:07:10 +01:00
|
|
|
imgPH.src = PlayImageURL
|
|
|
|
imgPH.id = "play-"+id
|
|
|
|
imgPH.alt = "Play Video"
|
2022-07-30 15:13:54 +01:00
|
|
|
imgPH.title = "Play"
|
2022-07-30 15:07:10 +01:00
|
|
|
imgPH.width = 360
|
|
|
|
imgPH.style.cursor = "pointer"
|
|
|
|
if (document.addEventListener) {
|
|
|
|
imgPH.addEventListener("click", function () {ActivateVideo(id);})
|
|
|
|
} else {
|
|
|
|
imgPH.setAttribute("onclick", "ActivateVideo("+id+");")
|
|
|
|
imgPH.onclick = function () {ActivateVideo(id);}
|
|
|
|
}
|
|
|
|
document.getElementById("video-" + id).appendChild(imgPH)
|
|
|
|
}
|
|
|
|
function ActivateVideo(id) {
|
2022-07-30 21:06:04 +01:00
|
|
|
var holder = document.getElementById("video-" + id)
|
2022-07-30 15:07:10 +01:00
|
|
|
holder.removeChild(document.getElementById("play-"+id))
|
2022-07-30 21:06:04 +01:00
|
|
|
var vid = document.createElement("video")
|
2022-07-30 15:07:10 +01:00
|
|
|
vid.controls = true
|
2022-07-30 15:12:43 +01:00
|
|
|
vid.width = 360
|
2022-07-30 21:06:04 +01:00
|
|
|
var vids = document.createElement("source")
|
2022-07-30 15:07:10 +01:00
|
|
|
vids.src = EntryData[id].videourl
|
|
|
|
vids.type = EntryData[id].videotype
|
2022-07-30 21:06:04 +01:00
|
|
|
var vida = document.createElement("a")
|
2022-07-30 15:07:10 +01:00
|
|
|
vida.href = EntryData[id].videourl
|
|
|
|
vida.innerText = "The Video"
|
|
|
|
vid.appendChild(vids)
|
|
|
|
vid.appendChild(vida)
|
|
|
|
holder.appendChild(vid)
|
2022-07-30 16:19:45 +01:00
|
|
|
if (vid.play) {vid.play();}
|
|
|
|
}
|
2022-07-30 21:03:47 +01:00
|
|
|
function SetupIndexArray() {
|
|
|
|
for (var i = 0; i < EntryData.length; i++) {
|
|
|
|
EntryIndices[i] = i
|
|
|
|
}
|
|
|
|
}
|
2022-07-30 16:19:45 +01:00
|
|
|
function SetupJSTheme() {
|
2022-07-30 21:06:04 +01:00
|
|
|
var th = document.getElementById("theme")
|
2022-07-30 16:19:45 +01:00
|
|
|
th.href = "#"
|
|
|
|
if (document.addEventListener) {
|
2022-07-30 21:45:57 +01:00
|
|
|
th.addEventListener("click", ToggleTheme)
|
2022-07-30 16:19:45 +01:00
|
|
|
} else {
|
2022-07-30 21:45:57 +01:00
|
|
|
th.setAttribute("onclick", "ToggleTheme();")
|
|
|
|
th.onclick = ToggleTheme
|
2022-07-30 16:19:45 +01:00
|
|
|
}
|
|
|
|
}
|
2022-07-30 23:58:23 +01:00
|
|
|
function ReplaceHistory(url) {
|
2022-07-30 21:06:04 +01:00
|
|
|
var s = true
|
2022-07-30 16:49:44 +01:00
|
|
|
if (window.history) {
|
2022-07-30 23:58:23 +01:00
|
|
|
if (window.history.replaceState) {
|
2022-08-17 18:27:13 +01:00
|
|
|
window.history.replaceState({}, "", url)
|
2022-07-30 16:49:44 +01:00
|
|
|
s = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (s) {
|
|
|
|
document.location.href = url
|
|
|
|
}
|
|
|
|
}
|
2022-07-30 21:45:57 +01:00
|
|
|
function ToggleTheme() {
|
2022-07-30 21:06:04 +01:00
|
|
|
var th = document.getElementById("theme")
|
|
|
|
var thimg = document.getElementById("theme-img")
|
|
|
|
var thsty = document.getElementById("style-theme")
|
|
|
|
var logo = document.getElementById("logo")
|
|
|
|
var url = document.location.href
|
2022-07-30 17:03:52 +01:00
|
|
|
url = url.split("#", 1)[0].split('?', 1)[0]
|
2022-07-30 16:19:45 +01:00
|
|
|
if (document.getElementById("so-theme")) {
|
|
|
|
thimg.src = SunImageURL
|
|
|
|
thimg.alt = "()"
|
|
|
|
th.title = "Switch to Light Mode"
|
|
|
|
document.getElementById("so-form").removeChild(document.getElementById("so-theme"))
|
|
|
|
logo.href = "?"
|
2022-07-30 23:58:23 +01:00
|
|
|
ReplaceHistory(url+"?"+TheParameters+"#")
|
2022-07-30 16:49:44 +01:00
|
|
|
thsty.href = CssDarkURL
|
2022-07-30 16:19:45 +01:00
|
|
|
} else {
|
|
|
|
thimg.src = MoonImageURL
|
|
|
|
thimg.alt = "{"
|
|
|
|
th.title = "Switch to Dark Mode"
|
2022-07-30 21:06:04 +01:00
|
|
|
var thi = document.createElement("input")
|
2022-07-30 16:19:45 +01:00
|
|
|
thi.name = "light"
|
|
|
|
thi.type = "hidden"
|
|
|
|
thi.id = "so-theme"
|
|
|
|
document.getElementById("so-form").appendChild(thi)
|
|
|
|
logo.href = "?light"
|
2022-07-30 16:49:44 +01:00
|
|
|
if (TheParameters === "") {
|
2022-07-30 23:58:23 +01:00
|
|
|
ReplaceHistory(url+"?light#")
|
2022-07-30 16:49:44 +01:00
|
|
|
} else {
|
2022-07-30 23:58:23 +01:00
|
|
|
ReplaceHistory(url+"?light&"+TheParameters+"#")
|
2022-07-30 16:49:44 +01:00
|
|
|
}
|
|
|
|
thsty.href = CssLightURL
|
2022-07-30 15:07:10 +01:00
|
|
|
}
|
|
|
|
}
|
2022-07-30 17:59:14 +01:00
|
|
|
function SetupJSHSO() {
|
2022-07-30 21:06:04 +01:00
|
|
|
var pb = document.getElementById("sort-menu-button")
|
|
|
|
var pane = document.getElementById("so-pane")
|
2022-07-30 17:59:14 +01:00
|
|
|
if (document.addEventListener) {
|
|
|
|
document.addEventListener("click", HandleGlobalClick)
|
2022-07-30 18:05:11 +01:00
|
|
|
pb.addEventListener("mouseover", HandleSortOrderBEnter)
|
|
|
|
pb.addEventListener("mouseout", HandleSortOrderBLeave)
|
2022-07-30 17:59:14 +01:00
|
|
|
pane.addEventListener("mouseover", HandleSortOrderEnter)
|
|
|
|
pane.addEventListener("mouseout", HandleSortOrderLeave)
|
|
|
|
} else {
|
|
|
|
document.parentElement.setAttribute("onclick", "HandleGlobalClick();")
|
2022-07-30 18:05:11 +01:00
|
|
|
pb.setAttribute("onmouseover", "HandleSortOrderBEnter();")
|
|
|
|
pb.setAttribute("onmouseout", "HandleSortOrderBLeave();")
|
2022-07-30 17:59:14 +01:00
|
|
|
pane.setAttribute("onmouseover", "HandleSortOrderEnter();")
|
|
|
|
pane.setAttribute("onmouseout", "HandleSortOrderLeave();")
|
|
|
|
document.parentElement.onclick = HandleGlobalClick
|
2022-07-30 18:05:11 +01:00
|
|
|
pb.onmouseover = HandleSortOrderBEnter
|
|
|
|
pb.onmouseout = HandleSortOrderBLeave
|
2022-07-30 17:59:14 +01:00
|
|
|
pane.onmouseover = HandleSortOrderEnter
|
|
|
|
pane.onmouseout = HandleSortOrderLeave
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function HandleGlobalClick() {
|
2022-07-30 18:05:11 +01:00
|
|
|
if (SortOrderStateI && SortOrderBStateI) {document.getElementById("sort-menu").checked = false;}
|
|
|
|
}
|
|
|
|
function HandleSortOrderBEnter() {
|
|
|
|
SortOrderBStateI = false
|
|
|
|
}
|
|
|
|
function HandleSortOrderBLeave(){
|
|
|
|
SortOrderBStateI = true
|
2022-07-30 17:59:14 +01:00
|
|
|
}
|
|
|
|
function HandleSortOrderEnter() {
|
|
|
|
SortOrderStateI = false
|
|
|
|
}
|
|
|
|
function HandleSortOrderLeave(){
|
|
|
|
SortOrderStateI = true
|
2022-07-30 21:03:47 +01:00
|
|
|
}
|
|
|
|
function SetupJSSOI() {
|
2022-07-30 21:06:04 +01:00
|
|
|
var submit = document.getElementById("so-submit")
|
2022-07-30 21:03:47 +01:00
|
|
|
if (submit.parentNode) {submit.parentNode.removeChild(submit);}
|
2022-07-30 21:06:04 +01:00
|
|
|
var oc = document.getElementById("so-order")
|
2022-07-30 21:03:47 +01:00
|
|
|
OrderValue = oc.value
|
2022-07-30 21:06:04 +01:00
|
|
|
var sc = document.getElementById("so-sort")
|
2022-07-30 21:03:47 +01:00
|
|
|
SortValue = sc.value
|
|
|
|
if (document.addEventListener) {
|
|
|
|
oc.addEventListener("change", HandleSortOrderChange)
|
|
|
|
sc.addEventListener("change", HandleSortOrderChange)
|
|
|
|
} else {
|
|
|
|
oc.setAttribute("onchange", "HandleSortOrderChange();")
|
|
|
|
sc.setAttribute("onchange", "HandleSortOrderChange();")
|
|
|
|
oc.onchange = HandleSortOrderChange
|
|
|
|
sc.onchange = HandleSortOrderChange
|
|
|
|
}
|
|
|
|
SortOrderEnabled = true
|
|
|
|
}
|
|
|
|
function HandleSortOrderChange() {
|
|
|
|
if (SortOrderEnabled) {EntrySort(document.getElementById("so-order").value, document.getElementById("so-sort").value);}
|
|
|
|
}
|
|
|
|
function EntrySort(o, s) {
|
|
|
|
var ts = s.toString().toLowerCase()
|
|
|
|
var chg = false
|
|
|
|
if (SortValue !== s) {
|
|
|
|
chg = true
|
|
|
|
SortValue = s
|
|
|
|
}
|
2022-07-30 21:17:02 +01:00
|
|
|
if (chg || OrderValue !== o) {
|
|
|
|
if (ts === "desc" || ts === "descending") {
|
|
|
|
ts = -1
|
|
|
|
} else {
|
|
|
|
ts = 1
|
|
|
|
}
|
2022-07-30 21:06:04 +01:00
|
|
|
var to = o.toString().toLowerCase()
|
2022-07-30 21:03:47 +01:00
|
|
|
if (to === "start") {
|
|
|
|
if (ts < 0) {
|
|
|
|
EntryIndices = EntryIndices.sort(SortStartD)
|
|
|
|
} else {
|
|
|
|
EntryIndices = EntryIndices.sort(SortStartA)
|
|
|
|
}
|
|
|
|
} else if (to === "end") {
|
|
|
|
if (ts < 0) {
|
|
|
|
EntryIndices = EntryIndices.sort(SortEndD)
|
|
|
|
} else {
|
|
|
|
EntryIndices = EntryIndices.sort(SortEndA)
|
|
|
|
}
|
|
|
|
} else if (to === "name") {
|
|
|
|
if (ts < 0) {
|
|
|
|
EntryIndices = EntryIndices.sort(SortNameD)
|
|
|
|
} else {
|
|
|
|
EntryIndices = EntryIndices.sort(SortNameA)
|
|
|
|
}
|
|
|
|
} else if (to === "duration") {
|
|
|
|
if (ts < 0) {
|
|
|
|
EntryIndices = EntryIndices.sort(SortDurationD)
|
|
|
|
} else {
|
|
|
|
EntryIndices = EntryIndices.sort(SortDurationA)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
chg = true
|
|
|
|
OrderValue = o
|
|
|
|
}
|
|
|
|
if (chg) {
|
|
|
|
TheParameters = "order="+OrderValue+"&sort="+SortValue
|
2022-07-30 21:07:22 +01:00
|
|
|
var url = document.location.href
|
|
|
|
url = url.split("#", 1)[0].split('?', 1)[0]
|
2022-07-30 21:03:47 +01:00
|
|
|
if (document.getElementById("so-theme")) {
|
2022-07-30 23:58:23 +01:00
|
|
|
ReplaceHistory(url+"?light&"+TheParameters)
|
2022-07-30 21:03:47 +01:00
|
|
|
} else {
|
2022-07-30 23:58:23 +01:00
|
|
|
ReplaceHistory(url+"?"+TheParameters)
|
2022-07-30 21:03:47 +01:00
|
|
|
}
|
|
|
|
for (var i = 0; i < EntryIndices.length; i++) {
|
2022-07-30 21:11:29 +01:00
|
|
|
var tNode = document.getElementById("entry-"+EntryIndices[i])
|
|
|
|
var pNode = tNode.parentNode
|
|
|
|
tNode = pNode.removeChild(tNode)
|
|
|
|
pNode.appendChild(tNode)
|
2022-07-30 21:03:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function SortStartA(a, b) {
|
|
|
|
if (EntryData[a].start < EntryData[b].start) {
|
|
|
|
return -1
|
|
|
|
} else {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function SortStartD(a, b) {
|
|
|
|
if (EntryData[a].start > EntryData[b].start) {
|
|
|
|
return -1
|
|
|
|
} else {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function SortEndA(a, b) {
|
|
|
|
if (EntryData[a].end < EntryData[b].end) {
|
|
|
|
return -1
|
|
|
|
} else {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function SortEndD(a, b) {
|
|
|
|
if (EntryData[a].end > EntryData[b].end) {
|
|
|
|
return -1
|
|
|
|
} else {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function SortNameA(a, b) {
|
|
|
|
if (EntryData[a].name < EntryData[b].name) {
|
|
|
|
return -1
|
|
|
|
} else {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function SortNameD(a, b) {
|
|
|
|
if (EntryData[a].name > EntryData[b].name) {
|
|
|
|
return -1
|
|
|
|
} else {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function SortDurationA(a, b) {
|
|
|
|
if (EntryData[a].duration < EntryData[b].duration) {
|
|
|
|
return -1
|
|
|
|
} else {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function SortDurationD(a, b) {
|
|
|
|
if (EntryData[a].duration > EntryData[b].duration) {
|
|
|
|
return -1
|
|
|
|
} else {
|
|
|
|
return 1
|
|
|
|
}
|
2022-08-17 13:44:18 +01:00
|
|
|
}
|
2022-08-17 21:44:52 +01:00
|
|
|
function SetupJSRSN() {
|
|
|
|
if (window.addEventListener) {
|
|
|
|
window.addEventListener("resize", PerformNavResize)
|
|
|
|
} else {
|
|
|
|
window.setAttribute("onresize", "PerformNavResize();")
|
|
|
|
window.onresize = PerformNavResize
|
|
|
|
}
|
|
|
|
PerformNavResize()
|
|
|
|
}
|
2022-08-17 18:27:13 +01:00
|
|
|
function PerformNavResize() {
|
2022-08-17 21:55:09 +01:00
|
|
|
var ww = 0
|
|
|
|
if (window.innerWidth && window.innerWidth !== 10) {
|
|
|
|
ww = window.innerWidth
|
|
|
|
} else {
|
|
|
|
var ht = document.getElementsByTagName("html")
|
|
|
|
if (ht && ht.length > 0) {ww = ht[0].clientWidth;}
|
|
|
|
}
|
|
|
|
if (ww > 0) {
|
|
|
|
var maxbarsz = ww - 324;
|
2022-08-17 18:27:13 +01:00
|
|
|
var men = document.getElementById("menu")
|
|
|
|
var vmen = document.getElementById("vmenu")
|
|
|
|
if (men && vmen) {
|
2022-08-17 21:59:18 +01:00
|
|
|
if (ww > 678) {
|
2022-08-17 21:44:52 +01:00
|
|
|
while (vmen.childNodes.length > 0) {InsertBefore(men, vmen.removeChild(vmen.childNodes[vmen.childNodes.length - 1]));}
|
2022-08-17 18:27:13 +01:00
|
|
|
} else {
|
|
|
|
var vmeni
|
|
|
|
var mensz = 0
|
|
|
|
var menc = []
|
|
|
|
var imenc = 0
|
2022-08-17 21:26:20 +01:00
|
|
|
for (vmeni = 0; vmeni < vmen.childNodes.length; vmeni++) {
|
2022-08-17 18:27:13 +01:00
|
|
|
if (vmen.childNodes[vmeni].nodeType === Node.ELEMENT_NODE) {
|
|
|
|
if (mensz+vmen.childNodes[vmeni].clientWidth > maxbarsz) {menc[imenc] = vmen.childNodes[vmeni]; imenc++;}
|
|
|
|
mensz += vmen.childNodes[vmeni].clientWidth
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (menc.length > 0) {
|
2022-08-17 18:35:43 +01:00
|
|
|
for (vmeni = 0; vmeni < menc.length; vmeni++) {vmen.removeChild(menc[vmeni]);}
|
|
|
|
for (vmeni = menc.length - 1; vmeni >= 0; vmeni--) {InsertBefore(men, menc[vmeni]);}
|
2022-08-17 18:27:13 +01:00
|
|
|
} else {
|
|
|
|
for (vmeni = 0; vmeni < men.childNodes.length; vmeni++) {
|
|
|
|
if (men.childNodes[vmeni].nodeType === Node.ELEMENT_NODE) {
|
|
|
|
var mena = GetFirstSubElement(men.childNodes[vmeni], 0)
|
|
|
|
var menaw = GetNavTextWidth(mena.textContent)
|
|
|
|
if (mensz+menaw <= maxbarsz) {menc[imenc] = men.childNodes[vmeni]; imenc++;}
|
|
|
|
mensz += menaw
|
|
|
|
}
|
|
|
|
}
|
2022-08-17 18:35:43 +01:00
|
|
|
for (vmeni = 0; vmeni < menc.length; vmeni++) {vmen.appendChild(men.removeChild(menc[vmeni]));}
|
2022-08-17 18:27:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function GetFirstSubElement(t,r) {
|
|
|
|
for (var gfsei = 0; gfsei < t.childNodes.length; gfsei++) {
|
|
|
|
if (t.childNodes[gfsei].nodeType === Node.ELEMENT_NODE) {
|
|
|
|
if (r < 1) {return t.childNodes[gfsei];} else {return GetFirstSubElement(t.childNodes[gfsei], r - 1);}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
function InsertBefore(p,c) {
|
2022-08-17 18:39:08 +01:00
|
|
|
if (p.childNodes.length > 0) {p.insertBefore(c, p.childNodes[0]);} else {p.appendChild(c);}
|
2022-08-17 18:27:13 +01:00
|
|
|
}
|
2022-08-17 13:44:18 +01:00
|
|
|
function GetNavTextWidth(s) {
|
2022-08-17 18:27:13 +01:00
|
|
|
var st = document.getElementById("st")
|
2022-08-17 13:44:18 +01:00
|
|
|
if (st) {
|
|
|
|
st.textContent = s
|
2022-08-17 18:27:13 +01:00
|
|
|
var trw = st.clientWidth
|
2022-08-17 13:44:18 +01:00
|
|
|
st.textContent = ""
|
2022-08-17 18:27:13 +01:00
|
|
|
return trw
|
2022-08-17 13:44:18 +01:00
|
|
|
}
|
|
|
|
return 8 * s.length + 32
|
2022-07-30 17:59:14 +01:00
|
|
|
}
|