From fe983f30e6078d87a22d2e7068fb3da8e5ebcfb2 Mon Sep 17 00:00:00 2001 From: Ada Werefox Date: Fri, 26 Apr 2024 00:06:05 -0500 Subject: [PATCH] Added a few more parseInt cases where I am fairly certain they would have been needed, fixed an issue where dummy data objects were not being given a "found" attribute, which would sometimes cause the resulting output to be "undefined" in the summary block. --- .../tracker/static/tracker/assets/main.js | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tunictracker/tracker/static/tracker/assets/main.js b/tunictracker/tracker/static/tracker/assets/main.js index 12c8ef7..44ce947 100644 --- a/tunictracker/tracker/static/tracker/assets/main.js +++ b/tunictracker/tracker/static/tracker/assets/main.js @@ -728,12 +728,14 @@ async function initialize_summary(summary_element, scene, checks, entrances) { summary_element.querySelector(".summary-title").textContent = scene; const summary_checks = summary_element.querySelector(".summary-checks"); - summary_checks.dataset.checksCollected = parseInt(checks.collected + checks.found); + summary_checks.dataset.checksCollected = parseInt( + checks.collected + checks.found + ); summary_checks.dataset.checksRemaining = checks.remaining; summary_checks.dataset.checksTotal = checks.total; - summary_checks.textContent = `Checks: ${parseInt(checks.collected + checks.found)}/${ - checks.total - } (${checks.remaining})`; + summary_checks.textContent = `Checks: ${parseInt( + checks.collected + checks.found + )}/${checks.total} (${checks.remaining})`; const summary_entrances = summary_element.querySelector(".summary-entrances"); summary_entrances.dataset.entrancesFound = entrances.found; @@ -786,18 +788,22 @@ async function update_summary(scene, checks, entrances) { // Make variables for whether checks or entrances updated const checks_changed = - summary_checks.dataset.checksCollected != parseInt(checks.collected + checks.found); + parseInt(summary_checks.dataset.checksCollected) != + parseInt(checks.collected + checks.found); const entrances_changed = - summary_entrances.dataset.entrancesFound != entrances.found; + parseInt(summary_entrances.dataset.entrancesFound) != + parseInt(entrances.found); // Check for changes, and if so, update if (checks_changed) { - summary_checks.dataset.checksCollected = parseInt(checks.collected + checks.found); + summary_checks.dataset.checksCollected = parseInt( + checks.collected + checks.found + ); summary_checks.dataset.checksRemaining = checks.remaining; summary_checks.dataset.checksTotal = checks.total; - summary_checks.textContent = `Checks: ${parseInt(checks.collected + checks.found)}/${ - checks.total - } (${checks.remaining})`; + summary_checks.textContent = `Checks: ${parseInt( + checks.collected + checks.found + )}/${checks.total} (${checks.remaining})`; } if (entrances_changed) { summary_entrances.dataset.entrancesFound = entrances.found; @@ -849,6 +855,7 @@ async function update_summary_list(data, changed) { collected: document.querySelector( `.summary[data-scene="${scene}"] .summary-checks` ).dataset.checksCollected, + found: 0, remaining: document.querySelector( `.summary[data-scene="${scene}"] .summary-checks` ).dataset.checksRemaining,