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 15:07:10 +01:00
|
|
|
const EntryData = []
|
2022-07-30 16:49:44 +01:00
|
|
|
function SetupJS() {
|
2022-07-30 16:23:00 +01:00
|
|
|
SetupJSTheme()
|
|
|
|
}
|
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) {
|
|
|
|
let imgPH = document.createElement("img")
|
|
|
|
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) {
|
|
|
|
let holder = document.getElementById("video-" + id)
|
|
|
|
holder.removeChild(document.getElementById("play-"+id))
|
|
|
|
let vid = document.createElement("video")
|
|
|
|
vid.controls = true
|
2022-07-30 15:12:43 +01:00
|
|
|
vid.width = 360
|
2022-07-30 15:07:10 +01:00
|
|
|
let vids = document.createElement("source")
|
|
|
|
vids.src = EntryData[id].videourl
|
|
|
|
vids.type = EntryData[id].videotype
|
|
|
|
let vida = document.createElement("a")
|
|
|
|
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();}
|
|
|
|
}
|
|
|
|
function SetupJSTheme() {
|
|
|
|
let th = document.getElementById("theme")
|
|
|
|
th.href = "#"
|
|
|
|
if (document.addEventListener) {
|
|
|
|
th.addEventListener("click", ToggleTheme)
|
|
|
|
} else {
|
|
|
|
th.setAttribute("onclick", "ToggleTheme();")
|
|
|
|
th.onclick = ToggleTheme
|
|
|
|
}
|
|
|
|
}
|
2022-07-30 16:57:18 +01:00
|
|
|
function ReplaceHistory(url) {
|
2022-07-30 16:49:44 +01:00
|
|
|
let s = true
|
|
|
|
if (window.history) {
|
2022-07-30 16:57:18 +01:00
|
|
|
if (window.history.replaceState) {
|
|
|
|
window.history.replaceState({}, "", url)
|
2022-07-30 16:49:44 +01:00
|
|
|
s = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (s) {
|
|
|
|
document.location.href = url
|
|
|
|
}
|
|
|
|
}
|
2022-07-30 16:19:45 +01:00
|
|
|
function ToggleTheme() {
|
|
|
|
let th = document.getElementById("theme")
|
|
|
|
let thimg = document.getElementById("theme-img")
|
|
|
|
let thsty = document.getElementById("style-theme")
|
|
|
|
let logo = document.getElementById("logo")
|
2022-07-30 16:49:44 +01:00
|
|
|
let 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 16:57:18 +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"
|
|
|
|
let thi = document.createElement("input")
|
|
|
|
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 16:57:18 +01:00
|
|
|
ReplaceHistory(url+"?light")
|
2022-07-30 16:49:44 +01:00
|
|
|
} else {
|
2022-07-30 16:57:18 +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
|
|
|
}
|
|
|
|
}
|