You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
2.8 KiB
JavaScript
106 lines
2.8 KiB
JavaScript
2 years ago
|
function cinemaMode(videoId){
|
||
|
let source = document.querySelector("source")
|
||
|
source.setAttribute("src", "resources/video/lq" + videoId + ".webm")
|
||
|
video.load()
|
||
|
video.play()
|
||
|
|
||
|
cinema.removeAttribute("hidden")
|
||
|
}
|
||
|
|
||
|
function loadQuestion(questionId){
|
||
|
questionFiller(questionId)
|
||
|
shuffleChildren(answers)
|
||
|
}
|
||
|
|
||
|
function questionMode(){
|
||
|
if(window.answerFlag == 0){
|
||
|
question.removeAttribute("hidden")
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function exit(){
|
||
|
question.setAttribute("hidden", "")
|
||
|
cinema.setAttribute("hidden", "")
|
||
|
video.pause()
|
||
|
}
|
||
|
|
||
|
const exitBoxes = document.querySelectorAll("#close")
|
||
|
exitBoxes.forEach(x => {
|
||
|
x.addEventListener("click", (e) => {
|
||
|
exit()
|
||
|
})
|
||
|
})
|
||
|
|
||
|
|
||
|
function shuffleChildren(parent){
|
||
|
var children = parent.children;
|
||
|
var frag = document.createDocumentFragment();
|
||
|
var randomChild;
|
||
|
|
||
|
while (children.length) {
|
||
|
randomChild = children[Math.floor(Math.random() * children.length)]
|
||
|
frag.appendChild(randomChild);
|
||
|
}
|
||
|
|
||
|
parent.appendChild(frag);
|
||
|
}
|
||
|
|
||
|
function pushScore() {
|
||
|
document.querySelector("progress").value = score
|
||
|
if(score == document.querySelector("progress").max) {
|
||
|
// vyhral jsi, zde udelej co chces
|
||
|
// Chci se stát obecně lepším člověkem ;)
|
||
|
//alert("Dobrá práce člověče, figurkama umíš tahat na výbornou jako správnej flamendr, ale co na to češi?Stala se z vás ikona této aplikace!")
|
||
|
boxes.forEach(
|
||
|
(boxRemove) => {
|
||
|
boxRemove.remove();
|
||
|
}
|
||
|
)
|
||
|
document.querySelector(".grid").style.display = "flex"
|
||
|
document.querySelector("#title").style.width = "100"
|
||
|
document.documentElement.style.setProperty('--termLength', 60 + "vw");
|
||
|
document.querySelector("audio").remove();
|
||
|
fakeScreen.replaceChild(fakeScreen.children[0],fakeScreen.children[0])
|
||
|
fakeScreen.replaceChild(fakeScreen.children[1],fakeScreen.children[1])
|
||
|
fakeScreen.replaceChild(fakeScreen.children[2],fakeScreen.children[2])
|
||
|
fakeScreen.children[0].innerHTML="[ RUN ENDED ]<span class=\"cursor1\">_</span>"
|
||
|
fakeScreen.children[1].innerHTML="Gratuluji!<span class=\"cursor2\"></span>"
|
||
|
fakeScreen.children[2].innerHTML=">Bye<span class=\"cursor3\">_</span>"
|
||
|
fakeScreen.children[3].innerHTML="<audio autoplay><source src=\"resources/audio/outro.webm\" type=\"audio/webm\"></audio>"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function audioplayer(){
|
||
|
playlist = ["intro","cyber","minute","supremers","violence"]
|
||
|
music = document.querySelector("audio");
|
||
|
music.play()
|
||
|
music.onended = function(e){
|
||
|
if(i < 4){
|
||
|
i += 1
|
||
|
}
|
||
|
else{
|
||
|
i=0
|
||
|
}
|
||
|
music.innerHTML="<audio autoplay><source src=\"resources/audio/" + playlist[i] + ".webm\" type=\"audio/webm\"></audio>"
|
||
|
music.play()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const bodyForAudio = document.querySelector("body");
|
||
|
|
||
|
function onetime(node, type, callback) {
|
||
|
|
||
|
// create event
|
||
|
node.addEventListener(type, function(e) {
|
||
|
// remove event
|
||
|
e.target.removeEventListener(e.type, arguments.callee);
|
||
|
// call handler
|
||
|
return callback(e);
|
||
|
});
|
||
|
|
||
|
}
|
||
|
|
||
|
onetime(bodyForAudio, "click", audioplayer)
|
||
|
|
||
|
|