From 035c97869f73bc9cfbfb8f43fabb791e4019878f Mon Sep 17 00:00:00 2001 From: Ada Werefox Date: Mon, 8 Apr 2024 23:38:55 -0500 Subject: [PATCH] Fixed the "hide completed areas" option not working. --- .../static/tracker/assets/button-functions.js | 24 ++++++------ .../tracker/static/tracker/assets/main.js | 38 +++++++++++++++---- .../tracker/templates/tracker/index.html | 18 --------- 3 files changed, 41 insertions(+), 39 deletions(-) diff --git a/tunictracker/tracker/static/tracker/assets/button-functions.js b/tunictracker/tracker/static/tracker/assets/button-functions.js index e50f81f..fb69598 100644 --- a/tunictracker/tracker/static/tracker/assets/button-functions.js +++ b/tunictracker/tracker/static/tracker/assets/button-functions.js @@ -21,25 +21,23 @@ function hide_empty_summaries() { let summary_divs = document.getElementById("summary-list").firstElementChild.children; Array.from(summary_divs).forEach((summary) => { - let checks_undiscovered = - summary.querySelector(".summary-checks").dataset.checksUndiscovered; - let entrances_undiscovered = - summary.querySelector(".summary-entrances").dataset.entrancesUndiscovered; + let checks_remaining = + summary.querySelector(".summary-checks").dataset.checksRemaining; + let entrances_remaining = + summary.querySelector(".summary-entrances").dataset.entrancesRemaining; if ( - !( - summary.querySelector(".summary-title").textContent == "Posterity" || - summary.querySelector(".summary-title").textContent == "Resurrection" - ) && - checks_undiscovered <= 0 && - entrances_undiscovered <= 0 + summary.dataset.scene != "Posterity" && + summary.dataset.scene != "Resurrection" && + summary.dataset.scene != "Loading" && + checks_remaining <= 0 && + entrances_remaining <= 0 && + summary.dataset.current == "false" ) { - console.log(`${checks_undiscovered} and ${entrances_undiscovered}`); summary.classList.toggle("hidden"); } }); } - function notices_ur_debug() { document.getElementById("debug-block").classList.toggle("hidden"); -} \ No newline at end of file +} diff --git a/tunictracker/tracker/static/tracker/assets/main.js b/tunictracker/tracker/static/tracker/assets/main.js index 8d29460..e9c6895 100644 --- a/tunictracker/tracker/static/tracker/assets/main.js +++ b/tunictracker/tracker/static/tracker/assets/main.js @@ -15,6 +15,7 @@ var total_entrances = 0; var server_address = "localhost:51111/"; var cross_codes = {}; var can_access_api_server = true; +var hide_completed_areas = false; window.onload = async () => { await get_updated_server_address(); @@ -105,6 +106,9 @@ async function initialize_elements() { async function refresh_elements() { const response = await update.refresh_overview(server_address); + // Check if the "Hide completed areas" option is checked + hide_completed_areas = document.getElementById("hideDone").checked; + if (response.overview) { if (!can_access_api_server) { console.log("I found the server!"); @@ -155,10 +159,6 @@ async function perform_updates( changed_hints ) { if (changed_seed) { - // TODO: this at some point *needs* to initialize all the data when the seed changes, instead of relying on the initial HTML. - // update_checks(await update.refresh_checks(server_address)); - // update_entrances(await update.refresh_entrances(server_address)); - // update_hints(await update.refresh_hints(server_address)); initialize_elements(); console.log(`Seed changed to: ${current_seed}`); } else { @@ -660,13 +660,21 @@ async function initialize_summary(summary_element, scene, checks, entrances) { }) ); - // Hide summaries for scenes with no entrances and the current scene + // Hide summaries for scenes with no entrances and the current scene and completed areas if "Hide completed areas" is checked if (entrances.total <= 0 || current_scene == scene) { summary_element.dataset.current = current_scene == scene; summary_element.classList.add("hidden"); } else { - summary_element.dataset.current = false; - summary_element.classList.remove("hidden"); + if (hide_completed_areas) { + if (checks.remaining > 0 && entrances.remaining > 0) { + summary_element.classList.remove("hidden"); + } else { + summary_element.classList.add("hidden"); + } + } else { + summary_element.dataset.current = false; + summary_element.classList.remove("hidden"); + } } // Return initialized summary @@ -937,7 +945,21 @@ async function update_scene(scene) { // Update the current summary current_summary_old.dataset.current = false; - current_summary_old.classList.remove("hidden"); + if (hide_completed_areas) { + const checks_remaining = parseInt( + current_summary_old.dataset.checksRemaining + ); + const entrances_remaining = parseInt( + current_summary_old.dataset.entrancesRemaining + ); + if (checks_remaining > 0 && entrances_remaining > 0) { + current_summary_old.classList.remove("hidden"); + } else { + current_summary_old.classList.add("hidden"); + } + } else { + current_summary_old.classList.remove("hidden"); + } current_summary.dataset.current = true; current_summary.classList.add("hidden"); } diff --git a/tunictracker/tracker/templates/tracker/index.html b/tunictracker/tracker/templates/tracker/index.html index df96848..b26c2ed 100644 --- a/tunictracker/tracker/templates/tracker/index.html +++ b/tunictracker/tracker/templates/tracker/index.html @@ -114,24 +114,6 @@ {% else %}
{% endif %}
- {% comment %} {% endcomment %} {% comment %}
{% endcomment %} {% include "tracker/src/index.html" with tracker_fe_link="https://gitea.werefox.cafe/ada/tunic-tracker-redux" tracker_be_link="https://github.com/spaceglace/TunicTransitionTracker" %}