rename locations to spoilers

This commit is contained in:
ReznoRMichael 2021-01-30 14:58:14 +01:00
parent 81fdb717e3
commit 13c27ad060
4 changed files with 29 additions and 29 deletions

File diff suppressed because one or more lines are too long

View file

@ -80,8 +80,8 @@
<input type="checkbox" name="checkboxes" id="checkbox-hints" value="hints-off" onclick="CheckboxHintsToggle();"> <input type="checkbox" name="checkboxes" id="checkbox-hints" value="hints-off" onclick="CheckboxHintsToggle();">
<span class="checkmark"></span>Hints <span class="checkmark"></span>Hints
</label> </label>
<label for="checkbox-locations" class="checkbox-label" title="Check to show every item's locations and costs. Hidden by default."> <label for="checkbox-spoilers" class="checkbox-label" title="Check to show every item's locations and costs. Hidden by default.">
<input type="checkbox" name="checkboxes" id="checkbox-locations" value="locations-off" onclick="CheckboxLocationsToggle();"> <input type="checkbox" name="checkboxes" id="checkbox-spoilers" value="spoilers-off" onclick="CheckboxSpoilersToggle();">
<span class="checkmark"></span>Spoilers <span class="checkmark"></span>Spoilers
</label> </label>
</div> </div>

View file

@ -80,8 +80,8 @@
<input type="checkbox" name="checkboxes" id="checkbox-hints" value="hints-off" onclick="CheckboxHintsToggle();"> <input type="checkbox" name="checkboxes" id="checkbox-hints" value="hints-off" onclick="CheckboxHintsToggle();">
<span class="checkmark"></span>Hints <span class="checkmark"></span>Hints
</label> </label>
<label for="checkbox-locations" class="checkbox-label" title="Check to show every item's locations and costs. Hidden by default."> <label for="checkbox-spoilers" class="checkbox-label" title="Check to show every item's locations and costs. Hidden by default.">
<input type="checkbox" name="checkboxes" id="checkbox-locations" value="locations-off" onclick="CheckboxLocationsToggle();"> <input type="checkbox" name="checkboxes" id="checkbox-spoilers" value="spoilers-off" onclick="CheckboxSpoilersToggle();">
<span class="checkmark"></span>Spoilers <span class="checkmark"></span>Spoilers
</label> </label>
</div> </div>

View file

@ -246,7 +246,7 @@ function HKCheckCompletion(jsonObject) {
// Prevents wrong checkbox behaviour (must run after everything is finished) // Prevents wrong checkbox behaviour (must run after everything is finished)
CheckboxHintsToggle(); CheckboxHintsToggle();
CheckboxLocationsToggle(); CheckboxSpoilersToggle();
// finish and show benchmark // finish and show benchmark
benchHKCCEnd = new Date(); benchHKCCEnd = new Date();
@ -323,14 +323,14 @@ function CompletionHTML(jsObj) {
* Generates and appends a new entry inside the HTML of a given ID * Generates and appends a new entry inside the HTML of a given ID
* @param {object} divId object containing div ID and h2 title of the HTML element * @param {object} divId object containing div ID and h2 title of the HTML element
* @param {string} textPrefix Main name of the entry * @param {string} textPrefix Main name of the entry
* @param {string} textSuffix Optional suffix after the main name (locations, costs etc.) * @param {string} textSuffix Optional suffix after the main name (spoilers: locations, costs etc.)
*/ */
function FillHTML(divId, textPrefix = "Unknown Completion Element: ", textSuffix = "Unknown Description Element") { function FillHTML(divId, textPrefix = "Unknown Completion Element: ", textSuffix = "Unknown Description Element") {
let icon = completionSymbol; let icon = completionSymbol;
let b = ["<b>", "</b>"]; let b = ["<b>", "</b>"];
if (!textPrefix.length) b = ["", ""]; if (!textPrefix.length) b = ["", ""];
let span = ["<span class='location'>", "</span>"]; let span = ["<span class='spoiler-span'>", "</span>"];
let spoilerSpan = ["<span class='spoiler-text'>", "</span>"]; let spoilerSpan = ["<span class='spoiler-text'>", "</span>"];
if (divId === HK.DIV_ID.hints) { if (divId === HK.DIV_ID.hints) {
span[0] = "<span>"; span[0] = "<span>";
@ -922,12 +922,12 @@ function InitialHTMLPopulate(divIdObj) {
AppendHTML(divIdObj.achievements, FLEUR_DIVIDE); AppendHTML(divIdObj.achievements, FLEUR_DIVIDE);
// Check local storage first to set proper checkbox state before the below functions start (default is always unchecked) // Check local storage first to set proper checkbox state before the below functions start (default is always unchecked)
if (localStorage.getItem("checkboxHints") === "checked") document.getElementById("checkbox-hints").checked = true; if (localStorage.getItem("hkCheckboxHints") === "checked") document.getElementById("checkbox-hints").checked = true;
if (localStorage.getItem("checkboxSpoilers") === "checked") document.getElementById("checkbox-locations").checked = true; if (localStorage.getItem("hkCheckboxSpoilers") === "checked") document.getElementById("checkbox-spoilers").checked = true;
// Prevents wrong checkbox behaviour (must run after everything is finished) // Prevents wrong checkbox behaviour (must run after everything is finished)
CheckboxHintsToggle(); CheckboxHintsToggle();
CheckboxLocationsToggle(); CheckboxSpoilersToggle();
} }
/** /**
@ -944,7 +944,7 @@ function CheckboxHintsToggle(param = "none") {
checkboxId.checked = false; checkboxId.checked = false;
// remember this choice for subsequent page visits and browser restarts // remember this choice for subsequent page visits and browser restarts
localStorage.setItem("checkboxHints", "unchecked"); localStorage.setItem("hkCheckboxHints", "unchecked");
break; break;
case "show": case "show":
document.getElementById("hk-hints").classList.remove("hidden"); document.getElementById("hk-hints").classList.remove("hidden");
@ -952,7 +952,7 @@ function CheckboxHintsToggle(param = "none") {
checkboxId.checked = true; checkboxId.checked = true;
// remember this choice for subsequent page visits and browser restarts // remember this choice for subsequent page visits and browser restarts
localStorage.setItem("checkboxHints", "checked"); localStorage.setItem("hkCheckboxHints", "checked");
break; break;
default: default:
// This runs when the checkbox is not checked // This runs when the checkbox is not checked
@ -961,7 +961,7 @@ function CheckboxHintsToggle(param = "none") {
checkboxId.value = "hints-off"; checkboxId.value = "hints-off";
// remember this choice for subsequent page visits and browser restarts // remember this choice for subsequent page visits and browser restarts
localStorage.setItem("checkboxHints", "unchecked"); localStorage.setItem("hkCheckboxHints", "unchecked");
} }
// This runs when the checkbox is checked // This runs when the checkbox is checked
else { else {
@ -969,18 +969,18 @@ function CheckboxHintsToggle(param = "none") {
checkboxId.value = "hints-on"; checkboxId.value = "hints-on";
// remember this choice for subsequent page visits and browser restarts // remember this choice for subsequent page visits and browser restarts
localStorage.setItem("checkboxHints", "checked"); localStorage.setItem("hkCheckboxHints", "checked");
} }
} }
} }
/** /**
* Toggles display of ".location" class. On click with no parameters or on demand when called with a parameter * Toggles display of ".spoiler-span" class. On click with no parameters or on demand when called with a parameter
* @param {string} param "hide", "show" or none (optional) * @param {string} param "hide", "show" or none (optional)
*/ */
function CheckboxLocationsToggle(param = "none") { function CheckboxSpoilersToggle(param = "none") {
let checkboxId = document.getElementById("checkbox-locations"); let checkboxId = document.getElementById("checkbox-spoilers");
let allClassElements = document.querySelectorAll(".location"); let allClassElements = document.querySelectorAll(".spoiler-span");
let length = allClassElements.length; let length = allClassElements.length;
switch (param) { switch (param) {
@ -988,21 +988,21 @@ function CheckboxLocationsToggle(param = "none") {
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
allClassElements[i].classList.add("hidden"); allClassElements[i].classList.add("hidden");
} }
checkboxId.value = "locations-off"; checkboxId.value = "spoilers-off";
checkboxId.checked = false; checkboxId.checked = false;
// remember this choice for subsequent page visits and browser restarts // remember this choice for subsequent page visits and browser restarts
localStorage.setItem("checkboxSpoilers", "unchecked"); localStorage.setItem("hkCheckboxSpoilers", "unchecked");
break; break;
case "show": case "show":
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
allClassElements[i].classList.remove("hidden"); allClassElements[i].classList.remove("hidden");
} }
checkboxId.value = "locations-on"; checkboxId.value = "spoilers-on";
checkboxId.checked = true; checkboxId.checked = true;
// remember this choice for subsequent page visits and browser restarts // remember this choice for subsequent page visits and browser restarts
localStorage.setItem("checkboxSpoilers", "checked"); localStorage.setItem("hkCheckboxSpoilers", "checked");
break; break;
default: default:
// This runs when the checkbox is not checked // This runs when the checkbox is not checked
@ -1010,20 +1010,20 @@ function CheckboxLocationsToggle(param = "none") {
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
allClassElements[i].classList.add("hidden"); allClassElements[i].classList.add("hidden");
} }
checkboxId.value = "locations-off"; checkboxId.value = "spoilers-off";
// remember this choice for subsequent page visits and browser restarts // remember this choice for subsequent page visits and browser restarts
localStorage.setItem("checkboxSpoilers", "unchecked"); localStorage.setItem("hkCheckboxSpoilers", "unchecked");
} }
// This runs when the checkbox is checked // This runs when the checkbox is checked
else { else {
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
allClassElements[i].classList.remove("hidden"); allClassElements[i].classList.remove("hidden");
} }
checkboxId.value = "locations-on"; checkboxId.value = "spoilers-on";
// remember this choice for subsequent page visits and browser restarts // remember this choice for subsequent page visits and browser restarts
localStorage.setItem("checkboxSpoilers", "checked"); localStorage.setItem("hkCheckboxSpoilers", "checked");
} }
} }
} }
@ -1045,5 +1045,5 @@ document.addEventListener("DOMContentLoaded", InitialHTMLPopulate(HK.DIV_ID));
// Make functions global so they can be used on click and change events (for Webpack) // Make functions global so they can be used on click and change events (for Webpack)
window.HKReadTextArea = HKReadTextArea; window.HKReadTextArea = HKReadTextArea;
window.InitialHTMLPopulate = InitialHTMLPopulate; window.InitialHTMLPopulate = InitialHTMLPopulate;
window.CheckboxLocationsToggle = CheckboxLocationsToggle; window.CheckboxSpoilersToggle = CheckboxSpoilersToggle;
window.CheckboxHintsToggle = CheckboxHintsToggle; window.CheckboxHintsToggle = CheckboxHintsToggle;