Move results to session HTML page

This commit is contained in:
luca0N! 2021-05-30 02:42:35 -03:00
parent 49bed7259e
commit 1d14d4b6eb
Signed by: luca0N
GPG key ID: 2E7B4655CF16D7D6
3 changed files with 53 additions and 11 deletions

View file

@ -25,6 +25,8 @@
* by luca0N! <https://www.luca0n.com>
*/
let quizEl;
// Attach setUpStrings() to onReady() in order to execute the main code as soon as possible. This overwrites onReady().
onReady = setUpStrings;
@ -50,7 +52,7 @@ function setUpStrings(){
quizAuthor.style['display'] = 'unset';
let contents = quiz.contents;
let elQuiz = document.getElementById('quiz'); // quiz div element.
quizEl = document.getElementById('quiz'); // quiz div element.
for (let x = 0; x < contents.length; x++){
//console.log(contents[x].title);
@ -100,15 +102,17 @@ function setUpStrings(){
} else console.warn('Warning: unknown type "' + contents[x].type + '" for question #' + (x + 1));
elQuiz.appendChild(itemDiv);
quizEl.appendChild(itemDiv);
}
// Add the finish button.
let finish = document.createElement('button');
finish.innerText = 'Finish!';
finish.onclick = function(){
document.location = 'final.html';
// Hide quiz and then show the results.
quizEl.style['display'] = 'none';
document.getElementById('results').style['display'] = 'unset';
}
elQuiz.appendChild(finish);
quizEl.appendChild(finish);
warning.style['display'] = 'none';
});
}