From cdbed83138ed33a1ecc0e0104c0e3b22c3a69894 Mon Sep 17 00:00:00 2001 From: ReznoRMichael Date: Sun, 6 Sep 2020 01:46:26 +0200 Subject: [PATCH] add CheckboxLocationsToggle(), hide locations --- HKCheckCompletion.js | 45 ++++++++++++++++++++++++++++++++++++++++---- index.html | 21 +++++++++++++++------ loadJson.js | 2 +- style.css | 12 ++++++++---- 4 files changed, 65 insertions(+), 15 deletions(-) diff --git a/HKCheckCompletion.js b/HKCheckCompletion.js index c125c55..f8c551f 100644 --- a/HKCheckCompletion.js +++ b/HKCheckCompletion.js @@ -110,7 +110,7 @@ const DIV_ID = { }; const HK_HINTS = { - fireballLevel: ["", "...a powerful spell learned below the town of Dirtmouth"], + fireballLevel: ["", "...a mysterious shaman living in a dwelling below the town of Dirtmouth"], hornet1Defeated: ["", "...a skilled protector guarding ruins in a lush green forest"], hasDash: ["", "...an old cloak lying on a green path by a broken shell"], hasWalljump: ["", "...a sharp claw lying forgotten somewhere amidst the insect village"], @@ -330,8 +330,9 @@ function HKCheckCompletion(jsonObject) { // start benchmark let countBegin = new Date(); - // Always hide and uncheck the Hints checkbox by default, prevents wrong checkbox behaviour + // Prevents wrong checkbox behaviour CheckboxHintsToggle("hide"); + CheckboxLocationsToggle("show"); // Pre-Cleaning and filling initial data PrefillHTML(DIV_ID); @@ -873,13 +874,49 @@ function CheckboxHintsToggle(param) { checkboxId.checked = true; break; default: - if (checkboxId.checked !== true) { + if (checkboxId.checked === false) { document.getElementById("hk-hints").classList.add("hidden"); checkboxId.value = "hints-off"; } else { document.getElementById("hk-hints").classList.remove("hidden"); checkboxId.value = "hints-on"; } - break; } +} + +function CheckboxLocationsToggle(param) { + let checkboxId = document.getElementById("checkbox-locations"); + let allClassElements = document.querySelectorAll(".location"); + let length = allClassElements.length; + + switch (param) { + case "hide": + for (let i = 0; i < length; i++) { + allClassElements[i].classList.add("hidden"); + } + checkboxId.value = "locations-off"; + checkboxId.checked = false; + break; + case "show": + for (let i = 0; i < length; i++) { + allClassElements[i].classList.remove("hidden"); + } + checkboxId.value = "locations-on"; + checkboxId.checked = true; + break; + default: + if (checkboxId.checked === false) { + for (let i = 0; i < length; i++) { + allClassElements[i].classList.add("hidden"); + } + checkboxId.value = "locations-off"; + } else { + for (let i = 0; i < length; i++) { + allClassElements[i].classList.remove("hidden"); + } + checkboxId.value = "locations-on"; + } + } + + } \ No newline at end of file diff --git a/index.html b/index.html index 4e2b6e1..87ce5b6 100644 --- a/index.html +++ b/index.html @@ -46,18 +46,27 @@
+
+ + +
+ + +
+
-
- -
+
diff --git a/loadJson.js b/loadJson.js index 07dc2d4..920a6d9 100644 --- a/loadJson.js +++ b/loadJson.js @@ -42,7 +42,7 @@ function loadJSON(filename, callback) { xobj.send(null); } -loadJSON("save/" + fileName[8], +loadJSON("save/" + fileName[5], function JSONparse(response) { // Parse JSON string into object jsonObj = JSON.parse(response); diff --git a/style.css b/style.css index b29a0a1..0f1fa37 100644 --- a/style.css +++ b/style.css @@ -58,7 +58,7 @@ h1 { .buttons { display: flex; align-items: center; - justify-content: center; + justify-content: space-between; } .button { display: flex; @@ -70,7 +70,7 @@ h1 { color: #e3ebf7; border: 2px solid #122c4e; padding: 0.3rem 1rem; - margin: 0 .5rem; + margin: 0; } .button:hover { background-color: #285188; @@ -142,9 +142,10 @@ input[type="radio"] .radio-label, .checkbox-label { - display: block; + display: inline-block; position: relative; - padding: 0px 0px 0px 35px; + padding: 0 0 0 1.8rem; + margin: 0 1rem 0 0; cursor: pointer; font-size: 1rem; -webkit-user-select: none; @@ -153,6 +154,9 @@ input[type="radio"] user-select: none; width: max-content; } +.checkbox-label:last-child { + margin-right: 0; +} .radiomark, .checkmark {