Fixed the "hide completed areas" option not working.

This commit is contained in:
Ada Werefox 2024-04-08 23:38:55 -05:00
parent 08cae8765e
commit 035c97869f
3 changed files with 41 additions and 39 deletions

View File

@ -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");
}
}

View File

@ -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");
}

View File

@ -114,24 +114,6 @@
</div>
{% else %}
<div id="no_data" />{% endif %}</div>
{% comment %} <div class="flex flex-col hidden max-w-full p-2 space-y-2 bg-white rounded-lg shadow-lg bg-opacity-10 shadow-bluelight-background-dark" id="debug-block">
<div class="px-2 text-lg">Tracker Debug</div>
<div class="grid max-w-full grid-flow-row gap-2 space-y-2 break-words md:grid-cols-2 xl:grid-cols-3 debug-list">
<div class="flex flex-col-reverse hidden max-h-full align-bottom">
<hr class="mt-1 border-2 border-[#24242480] rounded-xl" />
<ul class="px-2 break-all sm:break-word debug-item">
</ul>
</div>
{% for name, value in debug.items %}
<div class="flex flex-col-reverse max-h-full align-bottom">
<hr class="mt-1 border-2 border-[#24242480] rounded-xl" />
<ul class="px-2 break-all sm:break-word debug-item">
{{ name }}: {{ value }}
</ul>
</div>
{% endfor %}
</div>
</div> {% endcomment %}
{% comment %} <div class="order-1 order-2 order-3 order-4 order-5 order-6 order-7 order-8 order-9 order-10 order-11 order-12 order-13 order-14 order-15 order-16 order-17 order-18 order-19 order-20 bg-[#ffe28558]"></div> {% 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" %}
</div>