From 15ee476e467ea235566ebd4981c7577747afadf0 Mon Sep 17 00:00:00 2001 From: ReznoRMichael Date: Fri, 4 Sep 2020 21:57:15 +0200 Subject: [PATCH] checkbox Show Hints, CheckboxHintsToggle() --- HKCheckCompletion.js | 69 ++++++++++++++++++++++++++++++++++++++++---- index.html | 12 +++++++- style.css | 3 ++ 3 files changed, 77 insertions(+), 7 deletions(-) diff --git a/HKCheckCompletion.js b/HKCheckCompletion.js index 1d1519e..2499b99 100644 --- a/HKCheckCompletion.js +++ b/HKCheckCompletion.js @@ -27,6 +27,10 @@ const DIV_ID = { id: "hk-intro", maxPercent: 112 }, + hints: { + h2: "My old friend Elderbug once told me about...", + id: "hk-hints", + }, bosses: { h2: "Bosses", id: "hk-bosses", @@ -104,6 +108,28 @@ const DIV_ID = { } }; +const HK_HINTS = { + fireballLevel: ["", "...some powerful spell learned below the town of Dirtmouth"], + hornet1Defeated: ["", "...a skilled protector guarding ruins in a lush green forest"], + hasDash: ["", "...some old cloak lying deep in the lush green forest"], + hasWalljump: ["", "...some sharp claw lying forgotten somewhere amidst the insect village"], + Crossroads_04: ["", "...a mother sleeping peacefully below the town of Dirtmouth"], + slyRescued: ["", "...a fellow town bug who seems to be lost somewhere in the crossroads"], + hasLantern: ["", "...a precious item able to carry some light to even the darkest places"], + hasSuperDash: ["", "...some powerful crystal beating somewhere deep inside the mines"], + hasDreamNail: ["", "...some weapon not from this world only found where the souls can peacefully rest"], + killedInfectedKnight: ["", "...a shattered corpse forgotten in a windy cave in the depths below the city"], + hasDoubleJump: ["", "...something incredibly light dropped by a monarchfly in the depths below the city"], + killedBlackKnight: ["", "...discarded shells of black guards lying on the floor of a high spire"], + lurienDefeated: ["", "...a dreamer sleeping somewhere at the top of a high spire"], + dungDefenderOrHornet2: ["", "...a skilled combatant living at the heart of the sewers or watching over a shell amidst ash falling from the sky"], + ismaTearOrShadeCloak: ["", "...something precious in a grove accessed from the waterways or a massive door guarding a cloak behind the darkness"], + defeatedMegaJelly: ["", "...an intelligent being floating inside hidden archives behind the fog"], + monomonDefeated: ["", "...a dreamer sleeping somewhere hidden in a foggy area"], + hegemolDefeated: ["", "...a dreamer sleeping near a spider nest area"], + killedHollowKnight: ["", "...a disturbance inside a black temple"], +}; + const HK_BOSSES = { falseKnightDefeated: ["False Knight", "Forgotten Crossroads"], // "Battle Scene" - "Crossroads_10" ? hornet1Defeated: ["Hornet Protector", "Greenpath"], @@ -309,6 +335,7 @@ function HKCheckCompletion(jsonObject) { PrefillHTML(DIV_ID); // Shallow Clone const objects (used for destructive functions) + let HK_HINTS_temp = Object.assign({}, HK_HINTS); let HK_BOSSES_temp = Object.assign({}, HK_BOSSES); let HK_BOSSES_WORLD_temp = Object.assign({}, HK_BOSSES_WORLD); let HK_CHARMS_temp = Object.assign({}, HK_CHARMS); @@ -367,6 +394,10 @@ function HKCheckCompletion(jsonObject) { document.getElementById(DIV_ID.intro.id).innerHTML += divStart + icon + textFill + divEnd; } + // ---------------- Hints --------------------- // + + // function CheckHints() + // ---------------- Bosses (Base Game) --------------------- // if (HK_BOSSES_temp) CheckIfDataTrue(DIV_ID.bosses, HK_BOSSES_temp, HKPlayerData); @@ -448,7 +479,7 @@ function HKCheckCompletion(jsonObject) { } } - } + } // end for (let i in HKPlayerData) // Outside playerData checks @@ -485,10 +516,10 @@ function PrefillHTML(jsObj) { h2 = jsObj[i].h2; id = jsObj[i].id; mp = " (" + jsObj[i].maxPercent + "%)"; - if (i === "intro") mp = ""; + if (!jsObj[i].hasOwnProperty("maxPercent") || i === "intro") mp = ""; - document.getElementById("generated").innerHTML += "

" + h2 + mp + "

"; document.getElementById("generated").innerHTML += "
" + "
"; + document.getElementById(id).innerHTML += "

" + h2 + mp + "

"; } } @@ -500,7 +531,7 @@ function PrefillHTML(jsObj) { */ function FillHTML(divId, textPrefix = "Unknown Completion Element: ", textSuffix = "") { let dash = ""; - if (textSuffix.length) dash = " — "; + if (textSuffix.length && textPrefix.length) dash = " — "; document.getElementById(divId.id).innerHTML += divStart + completionSymbol + "" + textPrefix + "" + dash + textSuffix + divEnd; } @@ -650,10 +681,10 @@ function InitialHTMLPopulate(divIdObj) { document.getElementById(divIdObj.intro.id).innerHTML += divStart + completionSymbol + textFill + divEnd; // Temp arrays storing references (addresses) to objects for looping through them (duplicates important) - let hkObjArray = [HK_BOSSES, HK_BOSSES_WORLD, HK_CHARMS, HK_EQUIPMENT, HK_NAILARTS, HK_MASKSHARDS, HK_MASKSHARDS_WORLD, HK_VESSELFRAGMENTS, HK_VESSELFRAGMENTS_WORLD, HK_DREAMERS, HK_COLOSSEUM, HK_DREAMNAIL, HK_WARRIORDREAMS, HK_GRIMMTROUPE, HK_LIFEBLOOD, HK_GODMASTER]; + let hkObjArray = [HK_HINTS, HK_BOSSES, HK_BOSSES_WORLD, HK_CHARMS, HK_EQUIPMENT, HK_NAILARTS, HK_MASKSHARDS, HK_MASKSHARDS_WORLD, HK_VESSELFRAGMENTS, HK_VESSELFRAGMENTS_WORLD, HK_DREAMERS, HK_COLOSSEUM, HK_DREAMNAIL, HK_WARRIORDREAMS, HK_GRIMMTROUPE, HK_LIFEBLOOD, HK_GODMASTER]; // duplicates and order important - must be the same as in hkObjArray[] - let divObjArray = [divIdObj.bosses, divIdObj.bosses, divIdObj.charms, divIdObj.equipment, divIdObj.nailArts, divIdObj.maskShards, divIdObj.maskShards, divIdObj.vesselFragments, divIdObj.vesselFragments, divIdObj.dreamers, divIdObj.colosseum, divIdObj.dreamNail, divIdObj.warriorDreams, divIdObj.grimmTroupe, divIdObj.lifeblood, divIdObj.godmaster]; + let divObjArray = [divIdObj.hints, divIdObj.bosses, divIdObj.bosses, divIdObj.charms, divIdObj.equipment, divIdObj.nailArts, divIdObj.maskShards, divIdObj.maskShards, divIdObj.vesselFragments, divIdObj.vesselFragments, divIdObj.dreamers, divIdObj.colosseum, divIdObj.dreamNail, divIdObj.warriorDreams, divIdObj.grimmTroupe, divIdObj.lifeblood, divIdObj.godmaster]; // Looped filling to reduce redundancy do { @@ -682,4 +713,30 @@ function InitialHTMLPopulate(divIdObj) { for (let i = 0; i < ObjectLength(HK_GODMASTER_DOORS); i++) { FillHTML(divIdObj.godmaster, HK_GODMASTER_DOORS[i][0], HK_GODMASTER_DOORS[i][1]); } +} + +function CheckboxHintsToggle(param) { + let checkboxId = document.getElementById("checkbox-hints"); + + switch (param) { + case "hide": + document.getElementById("hk-hints").setAttribute("style", "display: none;"); + checkboxId.value = "hints-off"; + checkboxId.checked = false; + break; + case "show": + document.getElementById("hk-hints").setAttribute("style", "display: block;"); + checkboxId.value = "hints-on"; + checkboxId.checked = true; + break; + default: + if (checkboxId.checked !== true) { + document.getElementById("hk-hints").setAttribute("style", "display: none;"); + checkboxId.value = "hints-off"; + } else { + document.getElementById("hk-hints").setAttribute("style", "display: block;"); + checkboxId.value = "hints-on"; + } + break; + } } \ No newline at end of file diff --git a/index.html b/index.html index ec46dd8..ea0516c 100644 --- a/index.html +++ b/index.html @@ -25,10 +25,13 @@
@@ -49,6 +52,13 @@
+
+ +
+
@@ -66,7 +76,7 @@ - + diff --git a/style.css b/style.css index 2d6f433..edd3064 100644 --- a/style.css +++ b/style.css @@ -57,6 +57,9 @@ h1 { outline: 2px solid #529dff; outline-offset: -2px; } +#hk-hints { + /* display: none */; +} h2 { margin: 0.6rem 0; color: #737373;