bump
This commit is contained in:
parent
88ad123bc3
commit
bf6e6c7226
1 changed files with 21 additions and 7 deletions
|
@ -75,11 +75,13 @@
|
||||||
const previousButton = document.getElementById("previousButton");
|
const previousButton = document.getElementById("previousButton");
|
||||||
const nextButton = document.getElementById("nextButton");
|
const nextButton = document.getElementById("nextButton");
|
||||||
const resultWrapper = document.getElementById("resultWrapper");
|
const resultWrapper = document.getElementById("resultWrapper");
|
||||||
|
const quizIntro = document.getElementById("quiz_intro");
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
const params = getParams();
|
const params = getParams();
|
||||||
|
|
||||||
state.question.index = 'vraag' in params ? parseInt(params['vraag']) : 1;
|
state.question.index = 'vraag' in params ? parseInt(params['vraag']) : 0;
|
||||||
|
state.question.index = Math.max(state.question.index, 0);
|
||||||
state.question.id = "question_"+state.question.index;
|
state.question.id = "question_"+state.question.index;
|
||||||
state.question.element = document.getElementById(state.question.id);
|
state.question.element = document.getElementById(state.question.id);
|
||||||
|
|
||||||
|
@ -115,8 +117,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRelativeUrl(newQuestionIndex) {
|
function createRelativeUrl(newQuestionIndex) {
|
||||||
|
if(newQuestionIndex < 1) {
|
||||||
|
return window.location.pathname;
|
||||||
|
} else {
|
||||||
return window.location.pathname + "?vraag="+newQuestionIndex;
|
return window.location.pathname + "?vraag="+newQuestionIndex;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function showCorrectElements() {
|
function showCorrectElements() {
|
||||||
// This part resets to the original state;
|
// This part resets to the original state;
|
||||||
|
@ -124,11 +130,15 @@
|
||||||
question.classList.add("hidden");
|
question.classList.add("hidden");
|
||||||
}
|
}
|
||||||
resultWrapper.parentNode.classList.add("hidden");
|
resultWrapper.parentNode.classList.add("hidden");
|
||||||
|
quizIntro.classList.add("hidden");
|
||||||
if(state.question.index == 1) {
|
|
||||||
previousButton.style.display = "none";
|
|
||||||
} else {
|
|
||||||
previousButton.style.display = "";
|
previousButton.style.display = "";
|
||||||
|
|
||||||
|
console.log("here "+state.question.index)
|
||||||
|
if(state.question.index == 0) {
|
||||||
|
previousButton.style.display = "none";
|
||||||
|
nextButton.style.display = "none";
|
||||||
|
quizIntro.classList.remove("hidden");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!state.question.element) {
|
if(!state.question.element) {
|
||||||
|
@ -206,11 +216,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function goPrevious() {
|
function goPrevious() {
|
||||||
if(depth > 1) {
|
if(depth > 0) {
|
||||||
depth -= 1;
|
depth -= 1;
|
||||||
window.history.replaceState("", "", createRelativeUrl(state.question.index - 1));
|
window.history.replaceState("", "", createRelativeUrl(state.question.index - 1));
|
||||||
} else {
|
} else {
|
||||||
|
if(state.question.index - 1 != 0)
|
||||||
window.location.search = "vraag="+ (state.question.index - 1);
|
window.location.search = "vraag="+ (state.question.index - 1);
|
||||||
|
else {
|
||||||
|
window.location.search = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
|
|
Loading…
Reference in a new issue