From 6de642b104fd546e4cb6db8a3b653ff18b9a7a67 Mon Sep 17 00:00:00 2001 From: Arkerthan <arkerthan@gmail.com> Date: Mon, 18 May 2020 14:15:54 +0200 Subject: [PATCH] cleanup and documentation --- src/gui/quicklinks.js | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/gui/quicklinks.js b/src/gui/quicklinks.js index 85c83e8845d..45b9b1f5f23 100644 --- a/src/gui/quicklinks.js +++ b/src/gui/quicklinks.js @@ -1,6 +1,11 @@ /** * Generate a list of links the player can safely jump to. * + * Tags are: + * jump-to-safe: Allow to jump to this passage from anywhere + * jump-from-safe: Allow to jump from this passage to anywhere + * no-history: Do not record history for this passage, act as if was never opened; mutually exclusive with the jump tags + * * @returns {DocumentFragment} */ App.UI.quickMenu = (function() { @@ -27,21 +32,14 @@ App.UI.quickMenu = (function() { "Servants' Quarters": true, Spa: true }, - deepTest: { - Options: true, - deeper: { - "Summary Options": true, - "Description Options": true - }, - "Costs Budget": true, - } }); /** - * The DOM element of name of the currently played passage + * The DOM element of name of the currently played passage or any of it's parents. Used during generation to + * uncollapse the category with the current passage. * @type {HTMLElement} */ - let currentPassageDOM = null; + let currentPassage = null; // true means hidden const hiddenPassages = cleanPassageMapping({ @@ -113,7 +111,7 @@ App.UI.quickMenu = (function() { const div = document.createElement("div"); div.classList.add("menu-link"); const a = document.createElement("a"); - a.append("Back"); + a.append("Return"); a.onclick = goBack; div.append(a, " ", App.UI.DOM.makeElement("span", "[backspace]", "hotkey")); // insert at second position @@ -135,10 +133,10 @@ App.UI.quickMenu = (function() { addBackLink(div); // traverse from current passage up to uncollapse. - if (currentPassageDOM !== null) { - while (!currentPassageDOM.classList.contains("quick-links")) { - currentPassageDOM.classList.remove("collapsed"); - currentPassageDOM = currentPassageDOM.parentElement; + if (currentPassage !== null) { + while (!currentPassage.classList.contains("quick-links")) { + currentPassage.classList.remove("collapsed"); + currentPassage = currentPassage.parentElement; } } @@ -180,6 +178,7 @@ App.UI.quickMenu = (function() { // passage is hidden let hidden = false; if (hiddenPassages.hasOwnProperty(passage) && hiddenPassages[passage]()) { + // only return if the passage is not a category, if it's a category, we handle it like a deco element if (!toggle) { return; } @@ -194,7 +193,7 @@ App.UI.quickMenu = (function() { // we are already on this passage if (State.passage === passage) { div.append(uiName(passage)); - currentPassageDOM = div; + currentPassage = div; return; } // That is not a passage we can safely jump to, it's a deco element -- GitLab