diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/globalElements.js | 12 | ||||
-rw-r--r-- | scripts/onload/lesson.js | 22 | ||||
-rw-r--r-- | scripts/onload/quiz.js | 20 | ||||
-rw-r--r-- | scripts/quiz.js | 21 | ||||
-rw-r--r-- | scripts/sidebar.js | 24 |
5 files changed, 83 insertions, 16 deletions
diff --git a/scripts/globalElements.js b/scripts/globalElements.js index 381f564..05b2f71 100644 --- a/scripts/globalElements.js +++ b/scripts/globalElements.js @@ -3,13 +3,21 @@ // * /scripts/sidebar.js function updateGlobalElements() { if (isLangIndonesia()) { - document.getElementById("lang-switcher-text").innerHTML = "Baca dalam Bahasa Inggris"; + try { + document.getElementById("lang-switcher-text").innerHTML = "Read in Indonesia"; + } catch { + console.log("lang switcher button not found, moving on...") + } document.getElementById("link-author").innerHTML = "Tentang Penulis"; document.getElementById("link-school").innerHTML = "Tentang Sekolah"; document.getElementById("link-lessons").innerHTML = "Mata Pelajaran"; document.getElementById("toc-title").innerHTML = "Daftar Isi" } else { - document.getElementById("lang-switcher-text").innerHTML = "Read in Indonesia"; + try { + document.getElementById("lang-switcher-text").innerHTML = "Read in Indonesia"; + } catch { + console.log("lang switcher button not found, moving on...") + } } if (isSidebarOpen() && document.body.clientWidth >= 1000) { 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; +} diff --git a/scripts/quiz.js b/scripts/quiz.js new file mode 100644 index 0000000..95e6586 --- /dev/null +++ b/scripts/quiz.js @@ -0,0 +1,21 @@ +var questions = [] + +function initialise() { + +} + +function start() { + +} + +function answer() { + +} + +function skip() { + +} + +function finish() { + +} diff --git a/scripts/sidebar.js b/scripts/sidebar.js index 542eb4d..bc70334 100644 --- a/scripts/sidebar.js +++ b/scripts/sidebar.js @@ -14,14 +14,22 @@ function openSidebar(useAnim) { document.getElementById("main").style.removeProperty("transition"); document.getElementById("banner").style.removeProperty("transition"); document.getElementById("topbtn").style.removeProperty("transition"); - document.getElementById("chip-container").style.removeProperty("transition"); document.getElementById("sidebar").style.removeProperty("transition"); + try { + document.getElementById("chip-container").style.removeProperty("transition"); + } catch { + + } } else { document.getElementById("main").style.transition = "none"; document.getElementById("banner").style.transition = "none"; document.getElementById("topbtn").style.transition = "none"; - document.getElementById("chip-container").style.transition = "none"; document.getElementById("sidebar").style.transition = "none"; + try { + document.getElementById("chip-container").style.transition = "none"; + } catch { + + } } if (document.body.clientWidth >= 1000) { @@ -52,14 +60,22 @@ function closeSidebar(useAnim) { document.getElementById("main").style.removeProperty("transition"); document.getElementById("banner").style.removeProperty("transition"); document.getElementById("topbtn").style.removeProperty("transition"); - document.getElementById("chip-container").style.removeProperty("transition"); document.getElementById("sidebar").style.removeProperty("transition"); + try { + document.getElementById("chip-container").style.removeProperty("transition"); + } catch { + + } } else { document.getElementById("main").style.transition = "none"; document.getElementById("banner").style.transition = "none"; document.getElementById("topbtn").style.transition = "none"; - document.getElementById("chip-container").style.transition = "none"; document.getElementById("sidebar").style.transition = "none"; + try { + document.getElementById("chip-container").style.transition = "none"; + } catch { + + } } document.getElementById("main").style.marginLeft = "0"; |