remember current active tab

This commit is contained in:
ReznoRMichael 2021-08-01 20:46:33 +02:00
parent ae8ca4e07d
commit baef97fbed
3 changed files with 104 additions and 65 deletions

View file

@ -6073,60 +6073,60 @@ __webpack_require__.r(__webpack_exports__);
var MAP = { var MAP = {
"Tutorial_01": "King's Pass", "Tutorial_01": "King's Pass",
"Town": "Dirtmouth", "Town": "Dirtmouth",
"Room_shop": "Sly's Shop", "Room_shop": "Dirtmouth: Sly's Shop",
"Room_Sly_Storeroom": "Sly's Shop Basement", "Room_Sly_Storeroom": "Dirtmouth: Sly's Shop Basement",
"Room_Town_Stag_Station": "Dirtmouth Stag Station", "Room_Town_Stag_Station": "Dirtmouth: Stag Station",
"Room_mapper": "Iselda's Shop", "Room_mapper": "Dirtmouth: Iselda's Shop",
"Room_Bretta": "Bretta's Room", "Room_Bretta": "Dirtmouth: Bretta's Room",
"Room_Bretta_Basement": "Bretta's Room Basement", "Room_Bretta_Basement": "Dirtmouth: Bretta's Room Basement",
"Room_Ouiji": "Jiji's Hut", "Room_Ouiji": "Dirtmouth: Jiji's Hut",
"Room_Jinn": "Jinn's Hut", "Room_Jinn": "Dirtmouth: Jinn's Hut",
"Room_Tram_RG": "Upper Tram", "Room_Tram_RG": "Upper Tram",
"Room_Tram": "Lower Tram", "Room_Tram": "Lower Tram",
"Crossroads_01": "Crossroads Well", "Crossroads_01": "Forgotten Crossroads: Well",
"Crossroads_02": "Crossroads Outside Temple", "Crossroads_02": "Forgotten Crossroads: Outside Temple",
"Crossroads_03": "Crossroads Outside Stag", "Crossroads_03": "Forgotten Crossroads: Outside Stag",
"Crossroads_04": "Crossroads Gruz Mother", "Crossroads_04": "Forgotten Crossroads: Gruz Mother",
"Crossroads_05": "Crossroads Central Grub", "Crossroads_05": "Forgotten Crossroads: Central Grub",
"Crossroads_06": "Crossroads Outside Mound", "Crossroads_06": "Forgotten Crossroads: Outside Ancestral Mound",
"Crossroads_07": "Crossroads Gruzzer", "Crossroads_07": "Forgotten Crossroads: Gruzzer",
"Crossroads_08": "Crossroads Aspid Arena", "Crossroads_08": "Forgotten Crossroads: Aspid Arena",
"Crossroads_09": "Crossroads Mawlek Boss", "Crossroads_09": "Forgotten Crossroads: Brooding Mawlek Boss",
"Crossroads_10": "Crossroads False Knight Arena", "Crossroads_10": "Forgotten Crossroads: False Knight Arena",
"Crossroads_11_alt": "Crossroads Greenpath Entrance", "Crossroads_11_alt": "Forgotten Crossroads: Greenpath Entrance",
"Crossroads_12": "Crossroads Corridor to Acid Grub", "Crossroads_12": "Forgotten Crossroads: Corridor to Acid Grub",
"Crossroads_13": "Crossroads Goam Mask Shard", "Crossroads_13": "Forgotten Crossroads: Goam Mask Shard",
"Crossroads_14": "Crossroads Outside Myla", "Crossroads_14": "Forgotten Crossroads: Outside Myla",
"Crossroads_15": "Crossroads Corridor to Tram", "Crossroads_15": "Forgotten Crossroads: Corridor to Tram",
"Crossroads_16": "Crossroads Above Lever", "Crossroads_16": "Forgotten Crossroads: Above Lever",
"Crossroads_18": "Crossroads Fungal Entrance", "Crossroads_18": "Forgotten Crossroads: Fungal Entrance",
"Crossroads_19": "Crossroads Before Gruz Mother", "Crossroads_19": "Forgotten Crossroads: Before Gruz Mother",
"Crossroads_21": "Crossroads Outside False Knight", "Crossroads_21": "Forgotten Crossroads: Outside False Knight",
"Crossroads_22": "Crossroads Glowing Womb Arena", "Crossroads_22": "Forgotten Crossroads: Glowing Womb Arena",
"Crossroads_25": "Crossroads Mawlek Entrance", "Crossroads_25": "Forgotten Crossroads: Brooding Mawlek Entrance",
"Crossroads_27": "Crossroads Outside Tram", "Crossroads_27": "Forgotten Crossroads: Outside Tram",
"Crossroads_30": "Crossroads Hot Spring", "Crossroads_30": "Forgotten Crossroads: Hot Spring",
"Crossroads_31": "Crossroads Spike Grub", "Crossroads_31": "Forgotten Crossroads: Spike Grub",
"Crossroads_33": "Crossroads Cornifer", "Crossroads_33": "Forgotten Crossroads: Cornifer",
"Crossroads_35": "Crossroads Acid Grub", "Crossroads_35": "Forgotten Crossroads: Acid Grub",
"Crossroads_36": "Crossroads Mawlek Middle", "Crossroads_36": "Forgotten Crossroads: Brooding Mawlek Middle",
"Crossroads_37": "Crossroads Vessel Fragment", "Crossroads_37": "Forgotten Crossroads: Vessel Fragment",
"Crossroads_38": "Crossroads Grubfather", "Crossroads_38": "Forgotten Crossroads: Grubfather",
"Crossroads_39": "Crossroads Corridor Right of Temple", "Crossroads_39": "Forgotten Crossroads: Corridor Right of Temple",
"Crossroads_40": "Crossroads Corridor Right of Central Grub", "Crossroads_40": "Forgotten Crossroads: Corridor Right of Central Grub",
"Crossroads_42": "Crossroads Right Of Mask Shard", "Crossroads_42": "Forgotten Crossroads: Right of Mask Shard",
"Crossroads_43": "Crossroads Corridor to Elevator", "Crossroads_43": "Forgotten Crossroads: Corridor to Elevator",
"Crossroads_45": "Crossroads Myla", "Crossroads_45": "Forgotten Crossroads: Myla",
"Crossroads_46": "Crossroads Tram", "Crossroads_46": "Forgotten Crossroads: Tram",
"Crossroads_47": "Crossroads Stag", "Crossroads_47": "Forgotten Crossroads: Stag",
"Crossroads_48": "Crossroads Guarded Grub", "Crossroads_48": "Forgotten Crossroads: Guarded Grub",
"Crossroads_49": "Crossroads Elevator", "Crossroads_49": "Forgotten Crossroads: Elevator",
"Crossroads_52": "Crossroads Goam Journal", "Crossroads_52": "Forgotten Crossroads: Goam Journal",
"Crossroads_ShamanTemple": "Crossroads Ancestral Mound", "Crossroads_ShamanTemple": "Forgotten Crossroads: Ancestral Mound",
"Room_Mender_House": "Crossroads Menderbug", "Room_Mender_House": "Forgotten Crossroads: Menderbug",
"Room_Charm_Shop": "Crossroads Salubra", "Room_Charm_Shop": "Forgotten Crossroads: Salubra",
"Room_ruinhouse": "Crossroads Rescue Sly", "Room_ruinhouse": "Forgotten Crossroads: Rescue Sly",
"Room_temple": "Crossroads Inside Temple", "Room_temple": "Forgotten Crossroads: Inside Temple",
"Fungus1_01": "Greenpath Entrance", "Fungus1_01": "Greenpath Entrance",
"Fungus1_01b": "Greenpath Waterfall Bench", "Fungus1_01b": "Greenpath Waterfall Bench",
"Fungus1_02": "Greenpath First Hornet Sighting", "Fungus1_02": "Greenpath First Hornet Sighting",
@ -6239,7 +6239,7 @@ var MAP = {
"Mines_30": "Crystal Cornifer", "Mines_30": "Crystal Cornifer",
"Mines_31": "Crystal Crystal Heart Gauntlet", "Mines_31": "Crystal Crystal Heart Gauntlet",
"Mines_32": "Crystal Enraged Guardian Arena", "Mines_32": "Crystal Enraged Guardian Arena",
"Mines_33": "Crossroads Peak Dark Toll", "Mines_33": "Forgotten Crossroads: Crystal Peak Dark Toll",
"Mines_34": "Crystal Crown Peak", "Mines_34": "Crystal Crown Peak",
"Mines_35": "Crystal Mound", "Mines_35": "Crystal Mound",
"Mines_36": "Crystal Deep Focus", "Mines_36": "Crystal Deep Focus",
@ -7056,23 +7056,33 @@ function GenerateInnerHTML(db) {
console.log(finalHTMLFill); console.log(finalHTMLFill);
console.groupEnd(); */ console.groupEnd(); */
/* Final single HTML access and fill here */ /* --------------- Final single HTML access and fill here ------------------ */
document.getElementById("generated").innerHTML = finalHTMLFill; document.getElementById("generated").innerHTML = finalHTMLFill;
/* make tab switch buttons working (on click) */ /* make tab switch buttons working (on click) - must run after inner HTML generation is finished */
document.querySelectorAll(".tab-switch").forEach(function (button) { document.querySelectorAll(".tab-switch").forEach(function (button) {
button.addEventListener("click", function (e) { button.addEventListener("click", function (e) {
PageSwitchTab(e.target); PageSwitchTab(e.target.name);
}); });
}); // finish benchmarking });
/* Check local storage first, and set the last selected Tab on the page */
if (StorageAvailable('localStorage')) {
if (localStorage.getItem("hkTabActive")) {
PageSwitchTab(localStorage.getItem("hkTabActive"));
} else {
PageSwitchTab("main");
}
} // finish benchmarking
_HKCheckCompletion_js__WEBPACK_IMPORTED_MODULE_0__.benchmarkTimes.GenerateInnerHTML.timeEnd = performance.now(); _HKCheckCompletion_js__WEBPACK_IMPORTED_MODULE_0__.benchmarkTimes.GenerateInnerHTML.timeEnd = performance.now();
} }
/** /**
* Hides all other tabs, except the one which button was clicked (shows only the chosen tab) * Hides all other tabs, except the one which button was clicked (shows only the chosen tab)
* @param {EventTarget} clickedButton The click target (button clicked) * @param {String} clickedButton The click target (button clicked)
*/ */
@ -7080,7 +7090,7 @@ function PageSwitchTab(clickedButton) {
var sectionList = document.querySelectorAll(".large-section"); var sectionList = document.querySelectorAll(".large-section");
for (var i = 0, length = sectionList.length; i < length; i++) { for (var i = 0, length = sectionList.length; i < length; i++) {
if (sectionList[i].id !== "tab-".concat(clickedButton.name)) { if (sectionList[i].id !== "tab-".concat(clickedButton)) {
if (!sectionList[i].classList.contains("hidden")) { if (!sectionList[i].classList.contains("hidden")) {
sectionList[i].classList.add("hidden"); sectionList[i].classList.add("hidden");
} }
@ -7090,6 +7100,14 @@ function PageSwitchTab(clickedButton) {
} }
} }
} }
/* remember this choice for subsequent page visits and browser restarts */
if (StorageAvailable('localStorage')) {
if (clickedButton) {
localStorage.setItem("hkTabActive", clickedButton);
}
}
} }
function SectionDescription(section) { function SectionDescription(section) {

File diff suppressed because one or more lines are too long

View file

@ -574,24 +574,37 @@ function GenerateInnerHTML(db) {
console.log(finalHTMLFill); console.log(finalHTMLFill);
console.groupEnd(); */ console.groupEnd(); */
/* Final single HTML access and fill here */ /* --------------- Final single HTML access and fill here ------------------ */
document.getElementById("generated").innerHTML = finalHTMLFill; document.getElementById("generated").innerHTML = finalHTMLFill;
/* make tab switch buttons working (on click) */ /* make tab switch buttons working (on click) - must run after inner HTML generation is finished */
document.querySelectorAll(".tab-switch").forEach( (button) => { document.querySelectorAll(".tab-switch").forEach( (button) => {
button.addEventListener("click", (e) => { button.addEventListener("click", (e) => {
PageSwitchTab(e.target); PageSwitchTab(e.target.name);
}); });
}); });
/* Check local storage first, and set the last selected Tab on the page */
if (StorageAvailable('localStorage')) {
if (localStorage.getItem("hkTabActive")) {
PageSwitchTab(localStorage.getItem("hkTabActive"));
} else {
PageSwitchTab("main");
}
}
// finish benchmarking // finish benchmarking
benchmarkTimes.GenerateInnerHTML.timeEnd = performance.now(); benchmarkTimes.GenerateInnerHTML.timeEnd = performance.now();
} }
/** /**
* Hides all other tabs, except the one which button was clicked (shows only the chosen tab) * Hides all other tabs, except the one which button was clicked (shows only the chosen tab)
* @param {EventTarget} clickedButton The click target (button clicked) * @param {String} clickedButton The click target (button clicked)
*/ */
function PageSwitchTab(clickedButton) { function PageSwitchTab(clickedButton) {
@ -599,7 +612,7 @@ function PageSwitchTab(clickedButton) {
for (let i = 0, length = sectionList.length; i < length; i++) { for (let i = 0, length = sectionList.length; i < length; i++) {
if (sectionList[i].id !== `tab-${clickedButton.name}`) { if (sectionList[i].id !== `tab-${clickedButton}`) {
if (!sectionList[i].classList.contains("hidden")) { if (!sectionList[i].classList.contains("hidden")) {
sectionList[i].classList.add("hidden"); sectionList[i].classList.add("hidden");
@ -611,6 +624,14 @@ function PageSwitchTab(clickedButton) {
} }
} }
} }
/* remember this choice for subsequent page visits and browser restarts */
if (StorageAvailable('localStorage')) {
if (clickedButton) {
localStorage.setItem("hkTabActive", clickedButton);
}
}
} }
function SectionDescription(section) { function SectionDescription(section) {