diff --git a/tunictracker/tracker/static/tracker/assets/refresh.js b/tunictracker/tracker/static/tracker/assets/refresh.js index e19a439..53fb778 100644 --- a/tunictracker/tracker/static/tracker/assets/refresh.js +++ b/tunictracker/tracker/static/tracker/assets/refresh.js @@ -1,5 +1,24 @@ -var current_hash = ""; +// Global state for overview +var current_scene = ""; +var current_seed = Number.MAX_VALUE; +var current_checks = 0; +var current_entrances = 0; +var current_hints = 0; +var current_codes = { total: 0, codes: { name: "", distance: 0 } }; +var total_checks = 0; +var total_entrances = 0; + +// Global state for all entrances +// This should hold numbers for how many entrances are mapped/total per scene. +var current_entrances_list = {}; + +// Global state for all checks +// This should hold numbers for how many checks are cleared/total per scene. +var current_checks_list = {}; + +// Global state internal var server_address = ""; +var cross_codes = {}; window.onload = () => { get_updated_server_address(); @@ -7,12 +26,8 @@ window.onload = () => { .then((response) => response.json()) .then( (data) => { - const cross_codes = JSON.parse(JSON.stringify(data)); - const refresh_interval = setInterval( - refresh_elements, - 500, - cross_codes - ); + cross_codes = JSON.parse(JSON.stringify(data)); + const refresh_interval = setInterval(refresh_elements, 500); }, (error) => { console.log(error); @@ -24,16 +39,14 @@ function open_breakdown(event) { let scene = event.dataset.scene; Array.from(document.getElementById("breakdown-list").children).forEach( (breakdown) => { - if (breakdown.id == `${scene}-breakdown`) { - if ( - !( - document - .getElementById("breakdown-current") - .querySelector(".breakdown-block-title").textContent == scene - ) - ) { - breakdown.classList.remove("hidden"); - } + let breakdown_scene_title = breakdown.querySelector( + ".breakdown-block-title" + ).textContent; + if ( + breakdown_scene_title == scene || + breakdown.dataset.current == "true" + ) { + breakdown.classList.remove("hidden"); } else { breakdown.classList.add("hidden"); } @@ -54,10 +67,10 @@ function hide_empty_summaries() { summary.querySelector(".summary-title").textContent == "Posterity" || summary.querySelector(".summary-title").textContent == "Resurrection" ) && - (checks_undiscovered <= 0 && - entrances_undiscovered <= 0) + checks_undiscovered <= 0 && + entrances_undiscovered <= 0 ) { - console.log(`${checks_undiscovered} and ${entrances_undiscovered}`) + console.log(`${checks_undiscovered} and ${entrances_undiscovered}`); summary.classList.toggle("hidden"); } }); @@ -110,383 +123,506 @@ async function get_updated_server_address() { ); } -async function refresh_elements(cross_codes) { - fetch(`${server_address}spoiler`) +async function refresh_overview() { + fetch(`${server_address}overview`) + .then((response) => response.json()) + .then((data) => { + // Attempt to receive response JSON. + return data; + }); +} + +async function refresh_hints() { + fetch(`${server_address}hints`) + .then((response) => response.json()) + .then((data) => { + // Attempt to receive response JSON. + return data; + }); +} + +async function refresh_checks() { + const response = await fetch(`${server_address}items`); + const data = await response.json(); + return data; +} + +async function refresh_entrances() { + fetch(`${server_address}doors`).then((response) => response.json()); +} + +async function update_overview(overview) { + let overview_checks_title = document + .getElementById("overview-totals") + .querySelector(".overview-checks"); + let overview_entrances_title = document + .getElementById("overview-totals") + .querySelector(".overview-entrances"); + + // Set content to updated data. + overview_checks_title.textContent = `Checks: ${current_checks}/${total_checks}`; + overview_entrances_title.textContent = `Entrances: ${current_entrances}/${total_entrances}`; +} + +async function update_codes(codes) { + const default_cross_codes = cross_codes.Default; + const global_cross_codes = cross_codes.Global; +} + +async function update_summary() {} + +async function update_checks(checks) { + total_checks = checks.total; + // Create new lists with updated data. + let breakdown_list = Array.from( + document.getElementById("breakdown-list").children + ); + breakdown_list.forEach((scene) => { + // Create variables for element pointers. + let scene_title = scene.querySelector(".breakdown-block-title").textContent; + if (scene_title) { + scene.querySelector( + ".breakdown-block-checks-title" + ).textContent = `Checks: ${checks.scenes[scene_title].collected}/${checks.scenes[scene_title].total}`; + + let new_breakdown_block_checks_list = scene + .querySelector(".breakdown-block-checks-list") + .cloneNode(true); + let breakdown_block_checks_list_item = scene + .querySelector(".breakdown-block-checks-list") + .firstElementChild.cloneNode(true); + + Object.keys(checks.scenes[scene_title].checks).forEach((check) => { + if (!check.name) { + breakdown_block_checks_list_item.textContent = `❌ ${check}`; + new_breakdown_block_checks_list.appendChild( + breakdown_block_checks_list_item.cloneNode(true) + ); + } + }); + document + .getElementById("breakdown-list") + .querySelector(`[data-breakdown-scene="${scene_title}"]`) + .querySelector(".breakdown-block-checks-list").innerHTML = ""; + document + .getElementById("breakdown-list") + .querySelector(`[data-breakdown-scene="${scene_title}"]`) + .querySelector(".breakdown-block-checks-list") + .replaceWith(new_breakdown_block_checks_list); + } + }); + current_checks = checks.collected; + return; +} + +async function update_entrances(entrances) { + total_checks = entrances.total; + // Create new lists with updated data. + Object.keys(current_entrances_list).forEach((scene) => { + // Create variables for element pointers. + }); + return; +} + +async function update_hints(hints) { + return; +} + +async function update_scene(scene) { + Array.from(document.getElementById("breakdown-list").children).forEach( + (breakdown) => { + if ( + breakdown.querySelector(".breakdown-block-title").textContent == scene + ) { + breakdown.classList.remove("hidden"); + breakdown.dataset.current = "true"; + } else if (breakdown.dataset.current == "true") { + breakdown.dataset.current = "false"; + breakdown.classList.add("hidden"); + } + } + ); + Array.from( + document.getElementById("summary-list").firstElementChild.children + ).forEach((summary) => { + if (summary.dataset.scene == scene) { + summary.classList.add("hidden"); + } else if (!(summary.dataset.scene == "")) { + summary.classList.remove("hidden"); + } + }); + current_scene = scene; +} + +async function refresh_elements() { + fetch(`${server_address}overview`) .then((response) => response.json()) .then( (data) => { // Attempt to receive response JSON. - const response_object = JSON.parse(JSON.stringify(data)); + const overview = JSON.parse(JSON.stringify(data)); document.getElementById("status-block").classList.add("hidden"); - if (response_object.Debug.Hash == current_hash) { - return; + if (overview.seed != current_seed) { + current_seed = overview.seed; + current_scene = overview.scene; + current_checks = overview.items; + current_entrances = overview.entrances; + current_hints = overview.hints; + current_codes = overview.codes.length; + refresh_checks().then((data) => update_checks(data)); + update_entrances(refresh_entrances()); + update_hints(refresh_hints()); } else { - current_hash = response_object.Debug.Hash; - get_updated_server_address(); + if (overview.scene != current_scene) { + update_scene(overview.scene); + } + if (overview.items != current_checks) { + refresh_checks().then((data) => update_checks(data)); + } + if (overview.entraces != current_entrances) { + update_entrances(refresh_entrances); + } + if (overview.hints != current_hints) { + update_hints(refresh_hints); + } } - // Parse out data from the back-end into variables. - const overview_checks_undiscovered = - response_object.Totals.Checks.Undiscovered; - const overview_checks_total = response_object.Totals.Checks.Total; - const overview_entrances_undiscovered = - response_object.Totals.Entrances.Undiscovered; - const overview_entrances_total = response_object.Totals.Entrances.Total; - const current_scene_name = response_object.Current.Scene; - const all_scenes = response_object.Scenes; - const debug_info = response_object.Debug; - const cross_codes_entered = response_object.Codes; - const default_cross_codes = cross_codes.Default; - const global_cross_codes = cross_codes.Global; + // let summary_block = document + // .getElementById("summary-list") + // .firstElementChild.firstElementChild.cloneNode(true); + // let breakdown_block = document + // .getElementById("breakdown-list") + // .firstElementChild.cloneNode(true); + // breakdown_block.id = ""; + // breakdown_block.classList.remove("hidden"); - // Refresh elements with new data from the back end. - - // Clone all the needed elements for updating. - let overview_checks_title = document - .getElementById("overview-totals") - .querySelector(".overview-checks"); - let overview_entrances_title = document - .getElementById("overview-totals") - .querySelector(".overview-entrances"); - let summary_block = document - .getElementById("summary-list") - .firstElementChild.firstElementChild.cloneNode(true); - let breakdown_block = document - .getElementById("breakdown-list") - .firstElementChild.cloneNode(true); - breakdown_block.id = ""; - breakdown_block.classList.remove("hidden"); - let debug_item = document - .getElementById("debug-block") - .querySelector(".debug-list") - .firstElementChild.cloneNode(true); - debug_item.classList.remove("hidden"); - let new_breakdown_list = document - .getElementById("breakdown-list") - .cloneNode(true); - let new_summary_list = document - .getElementById("summary-list") - .cloneNode(true); - let new_debug_block = document - .getElementById("debug-block") - .querySelector(".debug-list") - .cloneNode(true); - let current_open_breakdown = ""; - Array.from(new_breakdown_list.children).forEach((scene) => { - if (!Array.from(scene.classList).includes("hidden")) { - current_open_breakdown = scene.id; - } - }); + // let debug_item = document + // .getElementById("debug-block") + // .querySelector(".debug-list") + // .firstElementChild.cloneNode(true); + // debug_item.classList.remove("hidden"); + // let new_breakdown_list = document + // .getElementById("breakdown-list") + // .cloneNode(true); + // let new_summary_list = document + // .getElementById("summary-list") + // .cloneNode(true); + // let new_debug_block = document + // .getElementById("debug-block") + // .querySelector(".debug-list") + // .cloneNode(true); + // let current_open_breakdown = ""; + // Array.from(new_breakdown_list.children).forEach((scene) => { + // if (!Array.from(scene.classList).includes("hidden")) { + // current_open_breakdown = scene.id; + // } + // }); // Clear out the current lists. - new_breakdown_list.innerHTML = ""; - new_summary_list.firstElementChild.innerHTML = ""; - new_debug_block.innerHTML = ""; - - // Set content to updated data. - overview_checks_title.textContent = `Checks: ${overview_checks_undiscovered}/${overview_checks_total}`; - overview_entrances_title.textContent = `Entrances: ${overview_entrances_undiscovered}/${overview_entrances_total}`; + // new_breakdown_list.innerHTML = ""; + // new_summary_list.firstElementChild.innerHTML = ""; + // new_debug_block.innerHTML = ""; // Create new lists with updated data. - Object.keys(all_scenes).forEach((scene) => { - // Create variables for element pointers. - summary_block = document - .getElementById("summary-list") - .firstElementChild.firstElementChild.cloneNode(true); - summary_block.classList.remove("hidden"); - let summary_title = summary_block.querySelector(".summary-title"); - let summary_checks = summary_block.querySelector(".summary-checks"); - let summary_entrances = - summary_block.querySelector(".summary-entrances"); + // Object.keys(current_entrances_list).forEach((scene) => { + // // Create variables for element pointers. + // summary_block = document + // .getElementById("summary-list") + // .firstElementChild.firstElementChild.cloneNode(true); + // summary_block.classList.remove("hidden"); + // let summary_title = summary_block.querySelector(".summary-title"); + // let summary_checks = summary_block.querySelector(".summary-checks"); + // let summary_entrances = + // summary_block.querySelector(".summary-entrances"); - breakdown_block = document - .getElementById("breakdown-list") - .firstElementChild.cloneNode(true); - let breakdown_block_title = breakdown_block.querySelector( - ".breakdown-block-title" - ); - let breakdown_block_checks_title = breakdown_block.querySelector( - ".breakdown-block-checks-title" - ); - let new_breakdown_block_checks_list = breakdown_block - .querySelector(".breakdown-block-checks-list") - .cloneNode(true); - let breakdown_block_checks_list_item = breakdown_block - .querySelector(".breakdown-block-checks-list") - .firstElementChild.cloneNode(true); - let breakdown_block_entrances_title = breakdown_block.querySelector( - ".breakdown-block-entrances-title" - ); - let new_breakdown_block_entrances_list = breakdown_block - .querySelector(".breakdown-block-entrances-list") - .cloneNode(true); - let breakdown_block_entrances_list_item = breakdown_block - .querySelector(".breakdown-block-entrances-list") - .firstElementChild.cloneNode(true); - let new_breakdown_block_mapped_list = breakdown_block - .querySelector(".breakdown-block-mapped-list") - .cloneNode(true); - let breakdown_block_mapped_list_item = breakdown_block - .querySelector(".breakdown-block-mapped-list") - .firstElementChild.cloneNode(true); + // breakdown_block = document + // .getElementById("breakdown-list") + // .firstElementChild.cloneNode(true); + // let breakdown_block_title = breakdown_block.querySelector( + // ".breakdown-block-title" + // ); + // let breakdown_block_checks_title = breakdown_block.querySelector( + // ".breakdown-block-checks-title" + // ); + // let new_breakdown_block_checks_list = breakdown_block + // .querySelector(".breakdown-block-checks-list") + // .cloneNode(true); + // let breakdown_block_checks_list_item = breakdown_block + // .querySelector(".breakdown-block-checks-list") + // .firstElementChild.cloneNode(true); + // let breakdown_block_entrances_title = breakdown_block.querySelector( + // ".breakdown-block-entrances-title" + // ); + // let new_breakdown_block_entrances_list = breakdown_block + // .querySelector(".breakdown-block-entrances-list") + // .cloneNode(true); + // let breakdown_block_entrances_list_item = breakdown_block + // .querySelector(".breakdown-block-entrances-list") + // .firstElementChild.cloneNode(true); + // let new_breakdown_block_mapped_list = breakdown_block + // .querySelector(".breakdown-block-mapped-list") + // .cloneNode(true); + // let breakdown_block_mapped_list_item = breakdown_block + // .querySelector(".breakdown-block-mapped-list") + // .firstElementChild.cloneNode(true); - // Clear out current list content. - new_breakdown_block_checks_list.innerHTML = ""; - new_breakdown_block_entrances_list.innerHTML = ""; - new_breakdown_block_mapped_list.innerHTML = ""; - new_breakdown_block_checks_list.appendChild( - breakdown_block_checks_list_item.cloneNode(true) - ); - breakdown_block_checks_list_item.classList.remove("hidden"); - new_breakdown_block_entrances_list.appendChild( - breakdown_block_entrances_list_item.cloneNode(true) - ); - breakdown_block_entrances_list_item.classList.remove("hidden"); - new_breakdown_block_mapped_list.appendChild( - breakdown_block_mapped_list_item.cloneNode(true) - ); - breakdown_block_mapped_list_item.classList.remove("hidden"); + // // Clear out current list content. + // new_breakdown_block_checks_list.innerHTML = ""; + // new_breakdown_block_entrances_list.innerHTML = ""; + // new_breakdown_block_mapped_list.innerHTML = ""; + // new_breakdown_block_checks_list.appendChild( + // breakdown_block_checks_list_item.cloneNode(true) + // ); + // breakdown_block_checks_list_item.classList.remove("hidden"); + // new_breakdown_block_entrances_list.appendChild( + // breakdown_block_entrances_list_item.cloneNode(true) + // ); + // breakdown_block_entrances_list_item.classList.remove("hidden"); + // new_breakdown_block_mapped_list.appendChild( + // breakdown_block_mapped_list_item.cloneNode(true) + // ); + // breakdown_block_mapped_list_item.classList.remove("hidden"); - // Create variables for commonly used values. - let scene_checks_undiscovered = - all_scenes[scene].Totals.Checks.Undiscovered; - let scene_checks_total = all_scenes[scene].Totals.Checks.Total; - let scene_entrances_undiscovered = - all_scenes[scene].Totals.Entrances.Undiscovered; - let scene_entrances_total = all_scenes[scene].Totals.Entrances.Total; - let scene_has_codes = Object.keys(cross_codes).includes(scene); + // // Create variables for commonly used values. + // let scene_checks_undiscovered = 0; + // // all_items[scene]; + // let scene_checks_total = 0; //all_scenes[scene].Totals.Checks.Total; + // let scene_entrances_undiscovered = 0; + // // all_scenes[scene].Totals.Entrances.Undiscovered; + // let scene_entrances_total = 0; //all_scenes[scene].Totals.Entrances.Total; + // // let scene_has_codes = Object.keys(cross_codes).includes(scene); - // Set textContent. - summary_title.textContent = scene; - summary_checks.textContent = `Checks: ${scene_checks_undiscovered}/${scene_checks_total}`; - summary_checks.dataset.checksUndiscovered = scene_checks_undiscovered; - summary_checks.dataset.checksTotal = scene_checks_undiscovered; - summary_entrances.textContent = `Entrances: ${scene_entrances_undiscovered}/${scene_entrances_total}`; - summary_entrances.dataset.entrancesUndiscovered = - scene_entrances_undiscovered; - summary_entrances.dataset.entrancesTotal = scene_entrances_total; - breakdown_block_title.textContent = scene; - breakdown_block_checks_title.textContent = `Checks: ${all_scenes[scene].Totals.Checks.Undiscovered}/${all_scenes[scene].Totals.Checks.Total}`; - breakdown_block_entrances_title.textContent = `Entrances: ${all_scenes[scene].Totals.Entrances.Undiscovered}/${all_scenes[scene].Totals.Entrances.Total}`; + // // Set textContent. + // summary_title.textContent = scene; + // summary_checks.textContent = `Checks: ${scene_checks_undiscovered}/${scene_checks_total}`; + // summary_checks.dataset.checksUndiscovered = scene_checks_undiscovered; + // summary_checks.dataset.checksTotal = scene_checks_undiscovered; + // summary_entrances.textContent = `Entrances: ${scene_entrances_undiscovered}/${scene_entrances_total}`; + // summary_entrances.dataset.entrancesUndiscovered = + // scene_entrances_undiscovered; + // summary_entrances.dataset.entrancesTotal = scene_entrances_total; + // breakdown_block_title.textContent = scene; + // breakdown_block_checks_title.textContent = `Checks: ${all_scenes[scene].Totals.Checks.Undiscovered}/${all_scenes[scene].Totals.Checks.Total}`; + // breakdown_block_entrances_title.textContent = `Entrances: ${all_scenes[scene].Totals.Entrances.Undiscovered}/${all_scenes[scene].Totals.Entrances.Total}`; - // Create checks, entrances, mapped entrances, and cross code lists. - Object.keys(all_scenes[scene].Checks).forEach((check) => { - if (!all_scenes[scene].Checks[check]) { - breakdown_block_checks_list_item.textContent = `❌ ${check}`; - new_breakdown_block_checks_list.appendChild( - breakdown_block_checks_list_item.cloneNode(true) - ); - } - }); - Object.keys(all_scenes[scene].Entrances).forEach((entrances) => { - if (all_scenes[scene].Entrances[entrances].Door == "") { - breakdown_block_entrances_list_item.textContent = `❌ ${entrances}`; - new_breakdown_block_entrances_list.appendChild( - breakdown_block_entrances_list_item.cloneNode(true) - ); - } else { - breakdown_block_mapped_list_item.textContent = `✔️ ${entrances} -> ${all_scenes[scene].Entrances[entrances].Door}`; - breakdown_block_mapped_list_item.id = `${entrances}-mapped`; - breakdown_block_mapped_list_item.dataset.scene = - all_scenes[scene].Entrances[entrances].Scene; - new_breakdown_block_mapped_list.appendChild( - breakdown_block_mapped_list_item.cloneNode(true) - ); - } - }); + // // Create checks, entrances, mapped entrances, and cross code lists. + // Object.keys(all_scenes[scene].Checks).forEach((check) => { + // if (!all_scenes[scene].Checks[check]) { + // breakdown_block_checks_list_item.textContent = `❌ ${check}`; + // new_breakdown_block_checks_list.appendChild( + // breakdown_block_checks_list_item.cloneNode(true) + // ); + // } + // }); + // Object.keys(all_scenes[scene].Entrances).forEach((entrances) => { + // if (all_scenes[scene].Entrances[entrances].Door == "") { + // breakdown_block_entrances_list_item.textContent = `❌ ${entrances}`; + // new_breakdown_block_entrances_list.appendChild( + // breakdown_block_entrances_list_item.cloneNode(true) + // ); + // } else { + // breakdown_block_mapped_list_item.textContent = `✔️ ${entrances} -> ${all_scenes[scene].Entrances[entrances].Door}`; + // breakdown_block_mapped_list_item.id = `${entrances}-mapped`; + // breakdown_block_mapped_list_item.dataset.scene = + // all_scenes[scene].Entrances[entrances].Scene; + // new_breakdown_block_mapped_list.appendChild( + // breakdown_block_mapped_list_item.cloneNode(true) + // ); + // } + // }); - // Apply color coding to summary block - summary_block.firstElementChild.classList.remove( - "from-highlight-both-light", - "from-highlight-checks-light", - "from-highlight-entrances-light", - "from-highlight-empty-light", - "from-highlight-undiscovered-light", - "to-highlight-both-dark", - "to-highlight-checks-dark", - "to-highlight-entrances-dark", - "to-highlight-empty-dark", - "to-highlight-undiscovered-dark", - "text-highlight-both-text", - "text-highlight-checks-text", - "text-highlight-entrances-text", - "text-highlight-empty-text", - "text-highlight-undiscovered-text" - ); - if ( - scene_checks_undiscovered > 0 && - scene_entrances_undiscovered > 0 - ) { - if ( - scene_checks_total == scene_checks_undiscovered && - scene_entrances_total == scene_entrances_undiscovered - ) { - summary_block.firstElementChild.classList.add( - "from-highlight-undiscovered-light", - "to-highlight-undiscovered-dark", - "text-highlight-undiscovered-text" - ); - } else { - summary_block.firstElementChild.classList.add( - "from-highlight-both-light", - "to-highlight-both-dark", - "text-highlight-both-text" - ); - } - } else if (scene_checks_undiscovered > 0) { - summary_block.firstElementChild.classList.add( - "from-highlight-checks-light", - "to-highlight-checks-dark", - "text-highlight-checks-text" - ); - } else if (scene_entrances_undiscovered > 0) { - summary_block.firstElementChild.classList.add( - "from-highlight-entrances-light", - "to-highlight-entrances-dark", - "text-highlight-entrances-text" - ); - } else { - summary_block.firstElementChild.classList.add( - "from-highlight-empty-light", - "to-highlight-empty-dark", - "text-highlight-empty-text" - ); - } + // // Apply color coding to summary block + // summary_block.firstElementChild.classList.remove( + // "from-highlight-both-light", + // "from-highlight-checks-light", + // "from-highlight-entrances-light", + // "from-highlight-empty-light", + // "from-highlight-undiscovered-light", + // "to-highlight-both-dark", + // "to-highlight-checks-dark", + // "to-highlight-entrances-dark", + // "to-highlight-empty-dark", + // "to-highlight-undiscovered-dark", + // "text-highlight-both-text", + // "text-highlight-checks-text", + // "text-highlight-entrances-text", + // "text-highlight-empty-text", + // "text-highlight-undiscovered-text" + // ); + // if ( + // scene_checks_undiscovered > 0 && + // scene_entrances_undiscovered > 0 + // ) { + // if ( + // scene_checks_total == scene_checks_undiscovered && + // scene_entrances_total == scene_entrances_undiscovered + // ) { + // summary_block.firstElementChild.classList.add( + // "from-highlight-undiscovered-light", + // "to-highlight-undiscovered-dark", + // "text-highlight-undiscovered-text" + // ); + // } else { + // summary_block.firstElementChild.classList.add( + // "from-highlight-both-light", + // "to-highlight-both-dark", + // "text-highlight-both-text" + // ); + // } + // } else if (scene_checks_undiscovered > 0) { + // summary_block.firstElementChild.classList.add( + // "from-highlight-checks-light", + // "to-highlight-checks-dark", + // "text-highlight-checks-text" + // ); + // } else if (scene_entrances_undiscovered > 0) { + // summary_block.firstElementChild.classList.add( + // "from-highlight-entrances-light", + // "to-highlight-entrances-dark", + // "text-highlight-entrances-text" + // ); + // } else { + // summary_block.firstElementChild.classList.add( + // "from-highlight-empty-light", + // "to-highlight-empty-dark", + // "text-highlight-empty-text" + // ); + // } - // Replace lists - breakdown_block - .querySelector(".breakdown-block-checks-list") - .replaceWith(new_breakdown_block_checks_list); - breakdown_block - .querySelector(".breakdown-block-entrances-list") - .replaceWith(new_breakdown_block_entrances_list); - breakdown_block - .querySelector(".breakdown-block-mapped-list") - .replaceWith(new_breakdown_block_mapped_list); + // // Replace lists + // breakdown_block + // .querySelector(".breakdown-block-checks-list") + // .replaceWith(new_breakdown_block_checks_list); + // breakdown_block + // .querySelector(".breakdown-block-entrances-list") + // .replaceWith(new_breakdown_block_entrances_list); + // breakdown_block + // .querySelector(".breakdown-block-mapped-list") + // .replaceWith(new_breakdown_block_mapped_list); - breakdown_block.id = `${ - breakdown_block.querySelector(".breakdown-block-title").textContent - }-breakdown`; - breakdown_block.classList.add("hidden"); + // breakdown_block.id = `${ + // breakdown_block.querySelector(".breakdown-block-title").textContent + // }-breakdown`; + // breakdown_block.classList.add("hidden"); - // Append relevant elements to lists. - if (current_open_breakdown == breakdown_block.id) { - breakdown_block.classList.remove("hidden"); - } - if (scene == current_scene_name) { - summary_block.classList.add("hidden"); - breakdown_block.classList.remove("hidden"); - document - .getElementById("breakdown-current") - .firstElementChild.replaceWith(breakdown_block.cloneNode(true)); - breakdown_block.classList.add("hidden"); - } else if ( - scene_checks_undiscovered <= 0 && - scene_entrances_total <= 0 - ) { - summary_block.classList.add("hidden"); - } - if (document.getElementById("hideDone").checked) { - if ( - scene_checks_undiscovered <= 0 && - scene_entrances_undiscovered <= 0 - ) { - summary_block.classList.add("hidden"); - } - } - summary_block.dataset.scene = scene; - new_summary_list.firstElementChild.appendChild( - summary_block.cloneNode(true) - ); - new_breakdown_list.appendChild(breakdown_block.cloneNode(true)); - }); - let new_cross_codes_block_list = document - .getElementById("codes-list") - .cloneNode(true); - let cross_codes_block_list_item = document - .getElementById("codes-list") - .firstElementChild.cloneNode(true); - new_cross_codes_block_list.innerHTML = ""; + // // Append relevant elements to lists. + // if (current_open_breakdown == breakdown_block.id) { + // breakdown_block.classList.remove("hidden"); + // } + // if (scene == current_scene_name) { + // summary_block.classList.add("hidden"); + // breakdown_block.classList.remove("hidden"); + // document + // .getElementById("breakdown-current") + // .firstElementChild.replaceWith(breakdown_block.cloneNode(true)); + // breakdown_block.classList.add("hidden"); + // } else if ( + // scene_checks_undiscovered <= 0 && + // scene_entrances_total <= 0 + // ) { + // summary_block.classList.add("hidden"); + // } + // if (document.getElementById("hideDone").checked) { + // if ( + // scene_checks_undiscovered <= 0 && + // scene_entrances_undiscovered <= 0 + // ) { + // summary_block.classList.add("hidden"); + // } + // } + // summary_block.dataset.scene = scene; + // new_summary_list.firstElementChild.appendChild( + // summary_block.cloneNode(true) + // ); + // new_breakdown_list.appendChild(breakdown_block.cloneNode(true)); + // }); + // let new_cross_codes_block_list = document + // .getElementById("codes-list") + // .cloneNode(true); + // let cross_codes_block_list_item = document + // .getElementById("codes-list") + // .firstElementChild.cloneNode(true); + // new_cross_codes_block_list.innerHTML = ""; - Object.keys(default_cross_codes).forEach((code) => { - cross_codes_block_list_item.querySelector( - ".codes-list-item-title" - ).textContent = code; - cross_codes_block_list_item.querySelector( - ".codes-list-item-code" - ).textContent = default_cross_codes[code] - .replace(/U/g, "⬆️") - .replace(/R/g, "➡️") - .replace(/D/g, "⬇️") - .replace(/L/g, "⬅️"); - new_cross_codes_block_list.appendChild( - cross_codes_block_list_item.cloneNode(true) - ); - }); - Object.keys(global_cross_codes).forEach((code) => { - cross_codes_block_list_item.querySelector( - ".codes-list-item-title" - ).textContent = code; - cross_codes_block_list_item.querySelector( - ".codes-list-item-code" - ).textContent = global_cross_codes[code] - .replace(/U/g, "⬆️") - .replace(/R/g, "➡️") - .replace(/D/g, "⬇️") - .replace(/L/g, "⬅️"); - if (cross_codes_entered.Global[code]) { - cross_codes_block_list_item.classList.add("hidden"); - } else { - cross_codes_block_list_item.classList.remove("hidden"); - } - new_cross_codes_block_list.appendChild( - cross_codes_block_list_item.cloneNode(true) - ); - }); - if (!(typeof cross_codes[current_scene_name] === "undefined")) { - Object.keys(cross_codes[current_scene_name]).forEach((code) => { - cross_codes_block_list_item.querySelector( - ".codes-list-item-title" - ).textContent = code; - cross_codes_block_list_item.querySelector( - ".codes-list-item-code" - ).textContent = cross_codes[current_scene_name][code] - .replace(/U/g, "⬆️") - .replace(/R/g, "➡️") - .replace(/D/g, "⬇️") - .replace(/L/g, "⬅️"); - if (cross_codes_entered[current_scene_name][code]) { - cross_codes_block_list_item.classList.add("hidden"); - } else { - cross_codes_block_list_item.classList.remove("hidden"); - } - new_cross_codes_block_list.appendChild( - cross_codes_block_list_item.cloneNode(true) - ); - }); - } - document - .getElementById("codes-list") - .replaceWith(new_cross_codes_block_list); + // Object.keys(default_cross_codes).forEach((code) => { + // cross_codes_block_list_item.querySelector( + // ".codes-list-item-title" + // ).textContent = code; + // cross_codes_block_list_item.querySelector( + // ".codes-list-item-code" + // ).textContent = default_cross_codes[code] + // .replace(/U/g, "⬆️") + // .replace(/R/g, "➡️") + // .replace(/D/g, "⬇️") + // .replace(/L/g, "⬅️"); + // new_cross_codes_block_list.appendChild( + // cross_codes_block_list_item.cloneNode(true) + // ); + // }); + // Object.keys(global_cross_codes).forEach((code) => { + // cross_codes_block_list_item.querySelector( + // ".codes-list-item-title" + // ).textContent = code; + // cross_codes_block_list_item.querySelector( + // ".codes-list-item-code" + // ).textContent = global_cross_codes[code] + // .replace(/U/g, "⬆️") + // .replace(/R/g, "➡️") + // .replace(/D/g, "⬇️") + // .replace(/L/g, "⬅️"); + // if (cross_codes_entered.Global[code]) { + // cross_codes_block_list_item.classList.add("hidden"); + // } else { + // cross_codes_block_list_item.classList.remove("hidden"); + // } + // new_cross_codes_block_list.appendChild( + // cross_codes_block_list_item.cloneNode(true) + // ); + // }); + // if (!(typeof cross_codes[current_scene_name] === "undefined")) { + // Object.keys(cross_codes[current_scene_name]).forEach((code) => { + // cross_codes_block_list_item.querySelector( + // ".codes-list-item-title" + // ).textContent = code; + // cross_codes_block_list_item.querySelector( + // ".codes-list-item-code" + // ).textContent = cross_codes[current_scene_name][code] + // .replace(/U/g, "⬆️") + // .replace(/R/g, "➡️") + // .replace(/D/g, "⬇️") + // .replace(/L/g, "⬅️"); + // if (cross_codes_entered[current_scene_name][code]) { + // cross_codes_block_list_item.classList.add("hidden"); + // } else { + // cross_codes_block_list_item.classList.remove("hidden"); + // } + // new_cross_codes_block_list.appendChild( + // cross_codes_block_list_item.cloneNode(true) + // ); + // }); + // } + // document + // .getElementById("codes-list") + // .replaceWith(new_cross_codes_block_list); - Object.keys(debug_info).forEach((item) => { - debug_item.querySelector( - ".debug-item" - ).textContent = `${item}: ${debug_info[item]}`; - new_debug_block.appendChild(debug_item.cloneNode(true)); - }); + // // Object.keys(debug_info).forEach((item) => { + // // debug_item.querySelector( + // // ".debug-item" + // // ).textContent = `${item}: ${debug_info[item]}`; + // // new_debug_block.appendChild(debug_item.cloneNode(true)); + // // }); - // Replace with new data. - document - .getElementById("summary-list") - .replaceWith(new_summary_list.cloneNode(true)); - document - .getElementById("breakdown-list") - .replaceWith(new_breakdown_list.cloneNode(true)); - document - .getElementById("debug-block") - .querySelector(".debug-list") - .replaceWith(new_debug_block.cloneNode(true)); + // // Replace with new data. + // document + // .getElementById("summary-list") + // .replaceWith(new_summary_list.cloneNode(true)); + // document + // .getElementById("breakdown-list") + // .replaceWith(new_breakdown_list.cloneNode(true)); + // // document + // // .getElementById("debug-block") + // // .querySelector(".debug-list") + // // .replaceWith(new_debug_block.cloneNode(true)); }, (error) => { document.getElementById("status-block").classList.remove("hidden"); diff --git a/tunictracker/tracker/static/tracker/data/holy_cross_codes.json b/tunictracker/tracker/static/tracker/data/holy_cross_codes.json index 99b6fcb..7bf8252 100644 --- a/tunictracker/tracker/static/tracker/data/holy_cross_codes.json +++ b/tunictracker/tracker/static/tracker/data/holy_cross_codes.json @@ -48,7 +48,7 @@ "Fire Wand Obelisk Page": "URDLDRUL", "Fountain Cross Door": "DRULUR", "Fountain Fairy": "DLLDURD", - "Lower Flower Fairy": "URDLDLDLDLU", + "Lower Flowers Fairy": "URDLDLDLDLU", "Moss Fairy": "URULDLULURDRDRULURDRD", "Power Up Treasure": "UDRUDLUDLRDLRU", "Sacred Geometry Treasure": "DLLUURRLDRUD", diff --git a/tunictracker/tracker/templates/tracker/breakdown/block.html b/tunictracker/tracker/templates/tracker/breakdown/block.html index 052d05a..93473cc 100644 --- a/tunictracker/tracker/templates/tracker/breakdown/block.html +++ b/tunictracker/tracker/templates/tracker/breakdown/block.html @@ -1,20 +1,19 @@ -
+
{{ scene_title }}
-
-
-
+
+
+
- Checks: {{ scene_data.Totals.Checks.Undiscovered }}/{{ scene_data.Totals.Checks.Total }} + Checks: {{ scene_data.checks.collected }}/{{ scene_data.checks.total }}

-
+
- {% for check_name, check in scene_data.Checks.items %} - {% if not check %} + {% for check_name, check in scene_data.checks.checks.items %} + {% if not check.name %}
    ❌ {{ check_name }}
@@ -22,43 +21,39 @@ {% endfor %}
-
-
+
+
- Entrances: {{ scene_data.Totals.Entrances.Undiscovered }}/{{ scene_data.Totals.Entrances.Total }} + Entrances: {{ scene_data.entrances.found }}/{{ scene_data.entrances.total }}

-
+
- {% for entrance_origin, entrance_destination in scene_data.Entrances.items %} - {% if entrance_destination.Door == "" %} + {% for entrance_origin, entrance_destination in scene_data.entrances.doors.items %} + {% if entrance_destination.door == "" %}
    ❌ {{ entrance_origin }}
- {% else %} - {% endif %} {% endfor %}
-
-
+
+
- {% for entrance_origin, entrance_destination in scene_data.Entrances.items %} - {% if entrance_destination %} + {% for entrance_origin, entrance_destination in scene_data.entrances.doors.items %} + {% if entrance_destination.door %} {% endif %} {% endfor %} diff --git a/tunictracker/tracker/templates/tracker/codes/index.html b/tunictracker/tracker/templates/tracker/codes/index.html index 78acca9..6b55767 100644 --- a/tunictracker/tracker/templates/tracker/codes/index.html +++ b/tunictracker/tracker/templates/tracker/codes/index.html @@ -1,21 +1,13 @@
Holy Cross Codes
-
-
+
+
{% for name, code in default_codes.items %} {% include "tracker/codes/block.html" with is_entered=False %} {% endfor %} - {% for scene, codes in tracked_codes.items %} - {% if scene == "Global" %} - {% for name, code_tuple in codes.items %} - {% include "tracker/codes/block.html" with code=code_tuple.0 is_entered=code_tuple.1 %} - {% endfor %} - {% elif scene == scene_title %} - {% for name, code_tuple in codes.items %} - {% include "tracker/codes/block.html" with code=code_tuple.0 is_entered=code_tuple.1 %} - {% endfor %} - {% endif %} + {% for name, values in codes.items %} + {% include "tracker/codes/block.html" with code=values.code is_entered=False %} {% endfor %}
diff --git a/tunictracker/tracker/templates/tracker/index.html b/tunictracker/tracker/templates/tracker/index.html index 31fa58c..5bb4d0d 100644 --- a/tunictracker/tracker/templates/tracker/index.html +++ b/tunictracker/tracker/templates/tracker/index.html @@ -2,11 +2,11 @@ {% load static %} {% block content %}
-
+
{% if debug != '' %} -
+
-
+
A trans pride fox emoji. {% include "tracker/howto/index.html" %}
-
Checks: {{ totals.Checks.Undiscovered }}/{{ totals.Checks.Total }}
Entrances: {{ totals.Entrances.Undiscovered }}/{{ totals.Entrances.Total }}
-
- Summary +
+ Summary

{% include "tracker/summary/list.html" %}
@@ -43,39 +43,43 @@
{% include "tracker/status/index.html" %} -
+
- {% include "tracker/breakdown/block.html" with extra_classes="hidden" %} + {% include "tracker/breakdown/block.html" with extra_classes="hidden" is_current_scene="false" %} {% for scene_title, scene_data in scenes.items %} - {% include "tracker/breakdown/block.html" with extra_classes="hidden" %} + {% if scene_title == current_scene %} + {% include "tracker/breakdown/block.html" with extra_classes="" is_current_scene="true" %} + {% else %} + {% include "tracker/breakdown/block.html" with extra_classes="hidden" is_current_scene="false" %} + {% endif %} {% endfor %}
-
+ {% comment %}
{% include "tracker/breakdown/block.html" with scene_title=current_scene.title scene_data=current_scene.data %} -
+
{% endcomment %} {% include "tracker/codes/index.html" %}
-
+
Settings - {% include "tracker/settings/index.html" %} + {% comment %} {% include "tracker/settings/index.html" %} {% endcomment %} {% include "tracker/address/index.html" %} -
+
-
+
@@ -83,17 +87,16 @@
{% else %}
{% endif %}
-