From 599e5bb3b9cf774d4c3680644cf4bd0596fd34c0 Mon Sep 17 00:00:00 2001 From: altaf-creator Date: Thu, 18 Jul 2024 10:39:11 +0700 Subject: Start migrating (and rewriting) lessons, NEW FEATURE: quizzes (unfinished) --- scripts/onload/lesson.js | 22 ++++++++++++---------- scripts/onload/quiz.js | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 scripts/onload/quiz.js (limited to 'scripts/onload') diff --git a/scripts/onload/lesson.js b/scripts/onload/lesson.js index 389cbf0..0a0f548 100644 --- a/scripts/onload/lesson.js +++ b/scripts/onload/lesson.js @@ -3,17 +3,19 @@ // * /scripts/toc.js // * /scripts/global.js window.onload = function() { - loadLesson(getUrlVars()['subject'], getUrlVars()['chapter'], getUrlVars()['id']); - updateGlobalElements(); + loadLesson(getUrlVars()['subject'], getUrlVars()['chapter'], getUrlVars()['id']); + updateGlobalElements(); + var btn = document.getElementById("top-back-btn"); + btn.setAttribute("href", `../?id=${getUrlVars()['subject']}`) } function getUrlVars() { - var vars = [], hash; - var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); - for (var i = 0; i < hashes.length; i++) { - hash = hashes[i].split('='); - vars.push(hash[0]); - vars[hash[0]] = hash[1]; - } - return vars; + var vars = [], hash; + var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); + for (var i = 0; i < hashes.length; i++) { + hash = hashes[i].split('='); + vars.push(hash[0]); + vars[hash[0]] = hash[1]; + } + return vars; } diff --git a/scripts/onload/quiz.js b/scripts/onload/quiz.js new file mode 100644 index 0000000..bf3e729 --- /dev/null +++ b/scripts/onload/quiz.js @@ -0,0 +1,20 @@ +// DEPENDENCIES +// * /scripts/lesson.js +// * /scripts/toc.js +// * /scripts/global.js +window.onload = function() { + updateGlobalElements(); + var btn = document.getElementById("top-back-btn"); + btn.setAttribute("href", `../?id=${getUrlVars()['subject']}`) +} + +function getUrlVars() { + var vars = [], hash; + var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); + for (var i = 0; i < hashes.length; i++) { + hash = hashes[i].split('='); + vars.push(hash[0]); + vars[hash[0]] = hash[1]; + } + return vars; +} -- cgit v1.2.3