plugin-backend #1
@ -4,7 +4,7 @@ var current_seed = Number.MAX_VALUE;
|
|||||||
var current_checks = 0;
|
var current_checks = 0;
|
||||||
var current_entrances = 0;
|
var current_entrances = 0;
|
||||||
var current_hints = 0;
|
var current_hints = 0;
|
||||||
var current_codes = { total: 0, codes: { name: "", distance: 0 } };
|
var current_codes = 0;
|
||||||
var total_checks = 0;
|
var total_checks = 0;
|
||||||
var total_entrances = 0;
|
var total_entrances = 0;
|
||||||
|
|
||||||
@ -80,27 +80,6 @@ function notices_ur_debug() {
|
|||||||
document.getElementById("debug-block").classList.toggle("hidden");
|
document.getElementById("debug-block").classList.toggle("hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
async function get_updated_filepath() {
|
|
||||||
fetch(`${document.URL}get/settings`)
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then(
|
|
||||||
(data) => {
|
|
||||||
backend_filepath = JSON.parse(JSON.stringify(data));
|
|
||||||
fetch(`${server_address}settings`, {
|
|
||||||
method: "post",
|
|
||||||
headers: { "Content-type": "application/json" },
|
|
||||||
body: JSON.stringify({
|
|
||||||
secretLegend: backend_filepath,
|
|
||||||
address: ":8000",
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
},
|
|
||||||
(error) => {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function get_updated_server_address() {
|
async function get_updated_server_address() {
|
||||||
fetch(`${document.URL}get/address`)
|
fetch(`${document.URL}get/address`)
|
||||||
.then(
|
.then(
|
||||||
@ -124,21 +103,15 @@ async function get_updated_server_address() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function refresh_overview() {
|
async function refresh_overview() {
|
||||||
fetch(`${server_address}overview`)
|
const response = await fetch(`${server_address}overview`);
|
||||||
.then((response) => response.json())
|
const data = await response.json();
|
||||||
.then((data) => {
|
|
||||||
// Attempt to receive response JSON.
|
|
||||||
return data;
|
return data;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refresh_hints() {
|
async function refresh_hints() {
|
||||||
fetch(`${server_address}hints`)
|
const response = await fetch(`${server_address}hints`);
|
||||||
.then((response) => response.json())
|
const data = await response.json();
|
||||||
.then((data) => {
|
|
||||||
// Attempt to receive response JSON.
|
|
||||||
return data;
|
return data;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refresh_checks() {
|
async function refresh_checks() {
|
||||||
@ -148,10 +121,12 @@ async function refresh_checks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function refresh_entrances() {
|
async function refresh_entrances() {
|
||||||
fetch(`${server_address}doors`).then((response) => response.json());
|
const response = await fetch(`${server_address}doors`);
|
||||||
|
const data = await response.json();
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function update_overview(overview) {
|
async function update_overview(overview, changed_scene, changed_codes) {
|
||||||
let overview_checks_title = document
|
let overview_checks_title = document
|
||||||
.getElementById("overview-totals")
|
.getElementById("overview-totals")
|
||||||
.querySelector(".overview-checks");
|
.querySelector(".overview-checks");
|
||||||
@ -160,19 +135,227 @@ async function update_overview(overview) {
|
|||||||
.querySelector(".overview-entrances");
|
.querySelector(".overview-entrances");
|
||||||
|
|
||||||
// Set content to updated data.
|
// Set content to updated data.
|
||||||
overview_checks_title.textContent = `Checks: ${current_checks}/${total_checks}`;
|
overview_checks_title.textContent = `Checks: ${overview.items}/${total_checks}`;
|
||||||
overview_entrances_title.textContent = `Entrances: ${current_entrances}/${total_entrances}`;
|
overview_entrances_title.textContent = `Entrances: ${
|
||||||
|
overview.entrances * 2
|
||||||
|
}/${total_entrances}`;
|
||||||
|
|
||||||
|
current_seed = overview.seed;
|
||||||
|
current_scene = overview.scene;
|
||||||
|
current_checks = overview.items;
|
||||||
|
current_entrances = overview.entrances;
|
||||||
|
current_hints = overview.hints;
|
||||||
|
current_codes = Object.keys(overview.codes).length;
|
||||||
|
|
||||||
|
if (changed_scene) {
|
||||||
|
await update_scene(overview.scene);
|
||||||
|
}
|
||||||
|
if (changed_codes) {
|
||||||
|
console.log(Object.keys(overview.codes).length);
|
||||||
|
await update_codes(overview.codes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function update_codes(codes) {
|
async function update_codes(codes) {
|
||||||
|
// Codes that are always active
|
||||||
const default_cross_codes = cross_codes.Default;
|
const default_cross_codes = cross_codes.Default;
|
||||||
|
|
||||||
|
// One time codes independent of scene
|
||||||
const global_cross_codes = cross_codes.Global;
|
const global_cross_codes = cross_codes.Global;
|
||||||
|
|
||||||
|
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 = "";
|
||||||
|
new_cross_codes_block_list.appendChild(
|
||||||
|
cross_codes_block_list_item.cloneNode(true)
|
||||||
|
);
|
||||||
|
cross_codes_block_list_item.classList.remove("hidden");
|
||||||
|
|
||||||
|
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, "⬅️");
|
||||||
|
new_cross_codes_block_list.appendChild(
|
||||||
|
cross_codes_block_list_item.cloneNode(true)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
Object.keys(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 = cross_codes[current_scene][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)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
console.log(codes);
|
||||||
|
document.getElementById("codes-list").replaceWith(new_cross_codes_block_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function update_summary() {}
|
async function apply_summary_colors(summary) {
|
||||||
|
// Apply color coding to summary block
|
||||||
|
summary.element.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"
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(summary);
|
||||||
|
if (summary.checks_total > 0 && summary.entrances_total > 0) {
|
||||||
|
if (
|
||||||
|
summary.checks_collected == summary.checks_total &&
|
||||||
|
summary.entrances_found == summary.entrances_total
|
||||||
|
) {
|
||||||
|
summary.element.classList.add(
|
||||||
|
"from-highlight-empty-light",
|
||||||
|
"to-highlight-empty-dark",
|
||||||
|
"text-highlight-empty-text"
|
||||||
|
);
|
||||||
|
} else if (
|
||||||
|
summary.checks_collected <= 0 &&
|
||||||
|
summary.entrances_found <= 0 &&
|
||||||
|
summary.entrances_total > 0
|
||||||
|
) {
|
||||||
|
summary.element.classList.add(
|
||||||
|
"from-highlight-undiscovered-light",
|
||||||
|
"to-highlight-undiscovered-dark",
|
||||||
|
"text-highlight-undiscovered-text"
|
||||||
|
);
|
||||||
|
} else if (summary.checks_collected >= summary.checks_total) {
|
||||||
|
summary.element.classList.add(
|
||||||
|
"from-highlight-checks-light",
|
||||||
|
"to-highlight-checks-dark",
|
||||||
|
"text-highlight-checks-text"
|
||||||
|
);
|
||||||
|
} else if (summary.entrances_found >= summary.entrances_total) {
|
||||||
|
summary.element.classList.add(
|
||||||
|
"from-highlight-entrances-light",
|
||||||
|
"to-highlight-entrances-dark",
|
||||||
|
"text-highlight-entrances-text"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
summary.element.classList.add(
|
||||||
|
"from-highlight-both-light",
|
||||||
|
"to-highlight-both-dark",
|
||||||
|
"text-highlight-both-text"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function update_summary(updates) {
|
||||||
|
if ("checks" in updates) {
|
||||||
|
const summary_checks = document
|
||||||
|
.getElementById("summary-list")
|
||||||
|
.querySelector(`[data-scene="${updates.scene}"]`)
|
||||||
|
.querySelector(".summary-checks");
|
||||||
|
summary_checks.textContent = `Checks: ${updates.checks}/${summary_checks.dataset.checksTotal}`;
|
||||||
|
summary_checks.dataset.checksUndiscovered = updates.checks;
|
||||||
|
apply_summary_colors({
|
||||||
|
element: document
|
||||||
|
.getElementById("summary-list")
|
||||||
|
.querySelector(`[data-scene="${updates.scene}"]`).firstElementChild,
|
||||||
|
checks_collected: updates.checks,
|
||||||
|
checks_total: summary_checks.dataset.checksTotal,
|
||||||
|
entrances_found: document
|
||||||
|
.getElementById("summary-list")
|
||||||
|
.querySelector(`[data-scene="${updates.scene}"]`)
|
||||||
|
.querySelector(".summary-entrances").dataset.entrancesUndiscovered,
|
||||||
|
entrances_total: document
|
||||||
|
.getElementById("summary-list")
|
||||||
|
.querySelector(`[data-scene="${updates.scene}"]`)
|
||||||
|
.querySelector(".summary-entrances").dataset.entrancesTotal,
|
||||||
|
});
|
||||||
|
} else if ("entrances" in updates) {
|
||||||
|
console.log(
|
||||||
|
`scene: ${document
|
||||||
|
.getElementById("summary-list")
|
||||||
|
.querySelector(`[data-scene="${updates.scene}"]`)}\n${
|
||||||
|
updates.entrances
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
const summary_entrances = document
|
||||||
|
.getElementById("summary-list")
|
||||||
|
.querySelector(`[data-scene="${updates.scene}"]`)
|
||||||
|
.querySelector(".summary-entrances");
|
||||||
|
summary_entrances.textContent = `Entrances: ${updates.entrances}/${summary_entrances.dataset.entrancesTotal}`;
|
||||||
|
summary_entrances.dataset.entrancesUndiscovered = updates.entrances;
|
||||||
|
apply_summary_colors({
|
||||||
|
element: document
|
||||||
|
.getElementById("summary-list")
|
||||||
|
.querySelector(`[data-scene="${updates.scene}"]`).firstElementChild,
|
||||||
|
checks_collected: document
|
||||||
|
.getElementById("summary-list")
|
||||||
|
.querySelector(`[data-scene="${updates.scene}"]`)
|
||||||
|
.querySelector(".summary-checks").dataset.checksUndiscovered,
|
||||||
|
checks_total: document
|
||||||
|
.getElementById("summary-list")
|
||||||
|
.querySelector(`[data-scene="${updates.scene}"]`)
|
||||||
|
.querySelector(".summary-checks").dataset.checksTotal,
|
||||||
|
entrances_found: updates.entrances,
|
||||||
|
entrances_total: summary_entrances.dataset.entrancesTotal,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log("What the heck is this");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function update_checks(checks) {
|
async function update_checks(checks) {
|
||||||
total_checks = checks.total;
|
total_checks = checks.total;
|
||||||
|
|
||||||
|
let new_breakdown_block_checks_list = document
|
||||||
|
.getElementById("breakdown-list")
|
||||||
|
.firstElementChild.querySelector(".breakdown-block-checks-list")
|
||||||
|
.cloneNode(true);
|
||||||
|
let breakdown_block_checks_list_item = document
|
||||||
|
.getElementById("breakdown-list")
|
||||||
|
.firstElementChild.querySelector(".breakdown-block-checks-list")
|
||||||
|
.firstElementChild.cloneNode(true);
|
||||||
|
|
||||||
// Create new lists with updated data.
|
// Create new lists with updated data.
|
||||||
let breakdown_list = Array.from(
|
let breakdown_list = Array.from(
|
||||||
document.getElementById("breakdown-list").children
|
document.getElementById("breakdown-list").children
|
||||||
@ -181,19 +364,24 @@ async function update_checks(checks) {
|
|||||||
// Create variables for element pointers.
|
// Create variables for element pointers.
|
||||||
let scene_title = scene.querySelector(".breakdown-block-title").textContent;
|
let scene_title = scene.querySelector(".breakdown-block-title").textContent;
|
||||||
if (scene_title) {
|
if (scene_title) {
|
||||||
|
const scene_checks = parseInt(
|
||||||
|
scene.querySelector(".breakdown-block-checks-title").dataset.checks
|
||||||
|
);
|
||||||
|
if (scene_checks != checks.scenes[scene_title].collected) {
|
||||||
|
scene.querySelector(".breakdown-block-checks-title").dataset.checks =
|
||||||
|
scene_checks;
|
||||||
|
update_summary({
|
||||||
|
scene: scene_title,
|
||||||
|
checks: checks.scenes[scene_title].collected,
|
||||||
|
});
|
||||||
scene.querySelector(
|
scene.querySelector(
|
||||||
".breakdown-block-checks-title"
|
".breakdown-block-checks-title"
|
||||||
).textContent = `Checks: ${checks.scenes[scene_title].collected}/${checks.scenes[scene_title].total}`;
|
).textContent = `Checks: ${checks.scenes[scene_title].collected}/${checks.scenes[scene_title].total}`;
|
||||||
|
|
||||||
let new_breakdown_block_checks_list = scene
|
new_breakdown_block_checks_list.innerHTML = "";
|
||||||
.querySelector(".breakdown-block-checks-list")
|
breakdown_block_checks_list_item.classList.remove("hidden");
|
||||||
.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) => {
|
Object.keys(checks.scenes[scene_title].checks).forEach((check) => {
|
||||||
if (!check.name) {
|
if (checks.scenes[scene_title].checks[check].name == "") {
|
||||||
breakdown_block_checks_list_item.textContent = `❌ ${check}`;
|
breakdown_block_checks_list_item.textContent = `❌ ${check}`;
|
||||||
new_breakdown_block_checks_list.appendChild(
|
new_breakdown_block_checks_list.appendChild(
|
||||||
breakdown_block_checks_list_item.cloneNode(true)
|
breakdown_block_checks_list_item.cloneNode(true)
|
||||||
@ -208,20 +396,97 @@ async function update_checks(checks) {
|
|||||||
.getElementById("breakdown-list")
|
.getElementById("breakdown-list")
|
||||||
.querySelector(`[data-breakdown-scene="${scene_title}"]`)
|
.querySelector(`[data-breakdown-scene="${scene_title}"]`)
|
||||||
.querySelector(".breakdown-block-checks-list")
|
.querySelector(".breakdown-block-checks-list")
|
||||||
.replaceWith(new_breakdown_block_checks_list);
|
.replaceWith(new_breakdown_block_checks_list.cloneNode(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
current_checks = checks.collected;
|
// current_checks = checks.collected;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function update_entrances(entrances) {
|
async function update_entrances(entrances) {
|
||||||
total_checks = entrances.total;
|
total_entrances = entrances.total;
|
||||||
|
|
||||||
|
let new_breakdown_block_entrances_list = document
|
||||||
|
.getElementById("breakdown-list")
|
||||||
|
.firstElementChild.querySelector(".breakdown-block-entrances-list")
|
||||||
|
.cloneNode(true);
|
||||||
|
let breakdown_block_entrances_list_item = document
|
||||||
|
.getElementById("breakdown-list")
|
||||||
|
.firstElementChild.querySelector(".breakdown-block-entrances-list")
|
||||||
|
.firstElementChild.cloneNode(true);
|
||||||
|
let new_breakdown_block_mapped_list = document
|
||||||
|
.getElementById("breakdown-list")
|
||||||
|
.firstElementChild.querySelector(".breakdown-block-mapped-list")
|
||||||
|
.cloneNode(true);
|
||||||
|
let breakdown_block_mapped_list_item = document
|
||||||
|
.getElementById("breakdown-list")
|
||||||
|
.firstElementChild.querySelector(".breakdown-block-mapped-list")
|
||||||
|
.firstElementChild.cloneNode(true);
|
||||||
// Create new lists with updated data.
|
// Create new lists with updated data.
|
||||||
Object.keys(current_entrances_list).forEach((scene) => {
|
let breakdown_list = Array.from(
|
||||||
|
document.getElementById("breakdown-list").children
|
||||||
|
);
|
||||||
|
breakdown_list.forEach((scene) => {
|
||||||
// Create variables for element pointers.
|
// Create variables for element pointers.
|
||||||
|
let scene_title = scene.querySelector(".breakdown-block-title").textContent;
|
||||||
|
if (scene_title) {
|
||||||
|
const scene_entrances = parseInt(
|
||||||
|
scene.querySelector(".breakdown-block-entrances-title").dataset
|
||||||
|
.entrances
|
||||||
|
);
|
||||||
|
if (scene_entrances != entrances.scenes[scene_title].found) {
|
||||||
|
scene.querySelector(".breakdown-block-checks-title").dataset.entrances =
|
||||||
|
scene_entrances;
|
||||||
|
update_summary({
|
||||||
|
scene: scene_title,
|
||||||
|
entrances: entrances.scenes[scene_title].found,
|
||||||
|
});
|
||||||
|
scene.querySelector(
|
||||||
|
".breakdown-block-entrances-title"
|
||||||
|
).textContent = `Entrances: ${entrances.scenes[scene_title].found}/${entrances.scenes[scene_title].total}`;
|
||||||
|
|
||||||
|
new_breakdown_block_entrances_list.innerHTML = "";
|
||||||
|
breakdown_block_entrances_list_item.classList.remove("hidden");
|
||||||
|
new_breakdown_block_mapped_list.innerHTML = "";
|
||||||
|
breakdown_block_mapped_list_item.classList.remove("hidden");
|
||||||
|
|
||||||
|
Object.keys(entrances.scenes[scene_title].doors).forEach((entrance) => {
|
||||||
|
if (entrances.scenes[scene_title].doors[entrance].door == "") {
|
||||||
|
breakdown_block_entrances_list_item.textContent = `❌ ${entrance}`;
|
||||||
|
new_breakdown_block_entrances_list.appendChild(
|
||||||
|
breakdown_block_entrances_list_item.cloneNode(true)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
breakdown_block_mapped_list_item.textContent = `✔️ ${entrance} -> ${entrances.scenes[scene_title].doors[entrance].door}`;
|
||||||
|
breakdown_block_mapped_list_item.id = `${entrance}-mapped`;
|
||||||
|
breakdown_block_mapped_list_item.dataset.scene =
|
||||||
|
entrances.scenes[scene_title].doors[entrance].scene;
|
||||||
|
new_breakdown_block_mapped_list.appendChild(
|
||||||
|
breakdown_block_mapped_list_item.cloneNode(true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document
|
||||||
|
.getElementById("breakdown-list")
|
||||||
|
.querySelector(`[data-breakdown-scene="${scene_title}"]`)
|
||||||
|
.querySelector(".breakdown-block-entrances-list").innerHTML = "";
|
||||||
|
document
|
||||||
|
.getElementById("breakdown-list")
|
||||||
|
.querySelector(`[data-breakdown-scene="${scene_title}"]`)
|
||||||
|
.querySelector(".breakdown-block-entrances-list")
|
||||||
|
.replaceWith(new_breakdown_block_entrances_list.cloneNode(true));
|
||||||
|
document
|
||||||
|
.getElementById("breakdown-list")
|
||||||
|
.querySelector(`[data-breakdown-scene="${scene_title}"]`)
|
||||||
|
.querySelector(".breakdown-block-mapped-list").innerHTML = "";
|
||||||
|
document
|
||||||
|
.getElementById("breakdown-list")
|
||||||
|
.querySelector(`[data-breakdown-scene="${scene_title}"]`)
|
||||||
|
.querySelector(".breakdown-block-mapped-list")
|
||||||
|
.replaceWith(new_breakdown_block_mapped_list.cloneNode(true));
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function update_hints(hints) {
|
async function update_hints(hints) {
|
||||||
@ -231,61 +496,112 @@ async function update_hints(hints) {
|
|||||||
async function update_scene(scene) {
|
async function update_scene(scene) {
|
||||||
Array.from(document.getElementById("breakdown-list").children).forEach(
|
Array.from(document.getElementById("breakdown-list").children).forEach(
|
||||||
(breakdown) => {
|
(breakdown) => {
|
||||||
if (
|
const breakdown_title = breakdown.querySelector(
|
||||||
breakdown.querySelector(".breakdown-block-title").textContent == scene
|
".breakdown-block-title"
|
||||||
) {
|
).textContent;
|
||||||
breakdown.classList.remove("hidden");
|
if (breakdown_title == scene) {
|
||||||
breakdown.dataset.current = "true";
|
document
|
||||||
} else if (breakdown.dataset.current == "true") {
|
.getElementById("breakdown-list")
|
||||||
breakdown.dataset.current = "false";
|
.querySelector(`[data-breakdown-scene="${scene}"]`)
|
||||||
breakdown.classList.add("hidden");
|
.classList.remove("hidden");
|
||||||
|
document
|
||||||
|
.getElementById("breakdown-list")
|
||||||
|
.querySelector(`[data-breakdown-scene="${scene}"]`).dataset.current =
|
||||||
|
"true";
|
||||||
|
document
|
||||||
|
.getElementById("breakdown-list")
|
||||||
|
.querySelector(`[data-breakdown-scene="${scene}"]`)
|
||||||
|
.classList.add("order-last");
|
||||||
|
} else {
|
||||||
|
document
|
||||||
|
.getElementById("breakdown-list")
|
||||||
|
.querySelector(
|
||||||
|
`[data-breakdown-scene="${breakdown_title}"]`
|
||||||
|
).dataset.current = "false";
|
||||||
|
|
||||||
|
document
|
||||||
|
.getElementById("breakdown-list")
|
||||||
|
.querySelector(`[data-breakdown-scene="${breakdown_title}"]`)
|
||||||
|
.classList.add("hidden");
|
||||||
|
document
|
||||||
|
.getElementById("breakdown-list")
|
||||||
|
.querySelector(`[data-breakdown-scene="${breakdown_title}"]`)
|
||||||
|
.classList.remove("order-last");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
Array.from(
|
Array.from(
|
||||||
document.getElementById("summary-list").firstElementChild.children
|
document.getElementById("summary-list").firstElementChild.children
|
||||||
).forEach((summary) => {
|
).forEach((summary) => {
|
||||||
if (summary.dataset.scene == scene) {
|
const summary_scene = summary.dataset.scene;
|
||||||
summary.classList.add("hidden");
|
if (summary_scene == scene) {
|
||||||
} else if (!(summary.dataset.scene == "")) {
|
document
|
||||||
summary.classList.remove("hidden");
|
.getElementById("summary-list")
|
||||||
|
.firstElementChild.querySelector(`[data-scene="${scene}"]`)
|
||||||
|
.classList.add("hidden");
|
||||||
|
} else if (!(summary_scene == "")) {
|
||||||
|
document
|
||||||
|
.getElementById("summary-list")
|
||||||
|
.firstElementChild.querySelector(`[data-scene="${summary_scene}"]`)
|
||||||
|
.classList.remove("hidden");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
current_scene = scene;
|
}
|
||||||
|
|
||||||
|
async function perform_updates(
|
||||||
|
changed_seed,
|
||||||
|
changed_checks,
|
||||||
|
changed_entrances,
|
||||||
|
changed_hints
|
||||||
|
) {
|
||||||
|
if (changed_seed) {
|
||||||
|
console.log("Seed changed.");
|
||||||
|
update_checks(await refresh_checks());
|
||||||
|
update_entrances(await refresh_entrances());
|
||||||
|
update_hints(await refresh_hints());
|
||||||
|
} else {
|
||||||
|
if (changed_checks) {
|
||||||
|
refresh_checks().then((data) => update_checks(data));
|
||||||
|
}
|
||||||
|
if (changed_entrances) {
|
||||||
|
refresh_entrances().then((data) => update_entrances(data));
|
||||||
|
}
|
||||||
|
if (changed_hints) {
|
||||||
|
refresh_hints().then((data) => update_hints(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refresh_elements() {
|
async function refresh_elements() {
|
||||||
fetch(`${server_address}overview`)
|
const overview = await refresh_overview();
|
||||||
.then((response) => response.json())
|
|
||||||
.then(
|
|
||||||
(data) => {
|
|
||||||
// Attempt to receive response JSON.
|
|
||||||
const overview = JSON.parse(JSON.stringify(data));
|
|
||||||
document.getElementById("status-block").classList.add("hidden");
|
document.getElementById("status-block").classList.add("hidden");
|
||||||
if (overview.seed != current_seed) {
|
|
||||||
current_seed = overview.seed;
|
const changed_seed = overview.seed != current_seed;
|
||||||
current_scene = overview.scene;
|
const changed_scene = overview.scene != current_scene;
|
||||||
current_checks = overview.items;
|
const changed_checks = overview.items != current_checks;
|
||||||
current_entrances = overview.entrances;
|
const changed_entrances = overview.entrances != current_entrances;
|
||||||
current_hints = overview.hints;
|
const changed_codes = Object.keys(overview.codes).length != current_codes;
|
||||||
current_codes = overview.codes.length;
|
const changed_hints = overview.hints != current_hints;
|
||||||
refresh_checks().then((data) => update_checks(data));
|
const any_change =
|
||||||
update_entrances(refresh_entrances());
|
changed_seed ||
|
||||||
update_hints(refresh_hints());
|
changed_scene ||
|
||||||
} else {
|
changed_checks ||
|
||||||
if (overview.scene != current_scene) {
|
changed_entrances ||
|
||||||
update_scene(overview.scene);
|
changed_codes ||
|
||||||
}
|
changed_hints;
|
||||||
if (overview.items != current_checks) {
|
|
||||||
refresh_checks().then((data) => update_checks(data));
|
if (any_change) {
|
||||||
}
|
await perform_updates(
|
||||||
if (overview.entraces != current_entrances) {
|
changed_seed,
|
||||||
update_entrances(refresh_entrances);
|
changed_checks,
|
||||||
}
|
changed_entrances,
|
||||||
if (overview.hints != current_hints) {
|
changed_hints
|
||||||
update_hints(refresh_hints);
|
);
|
||||||
}
|
update_overview(overview, changed_scene, changed_codes);
|
||||||
}
|
}
|
||||||
|
// refresh_overview().then(
|
||||||
|
// (overview) => {
|
||||||
|
|
||||||
// let summary_block = document
|
// let summary_block = document
|
||||||
// .getElementById("summary-list")
|
// .getElementById("summary-list")
|
||||||
@ -623,13 +939,13 @@ async function refresh_elements() {
|
|||||||
// // .getElementById("debug-block")
|
// // .getElementById("debug-block")
|
||||||
// // .querySelector(".debug-list")
|
// // .querySelector(".debug-list")
|
||||||
// // .replaceWith(new_debug_block.cloneNode(true));
|
// // .replaceWith(new_debug_block.cloneNode(true));
|
||||||
},
|
// },
|
||||||
(error) => {
|
// (error) => {
|
||||||
document.getElementById("status-block").classList.remove("hidden");
|
// document.getElementById("status-block").classList.remove("hidden");
|
||||||
get_updated_server_address();
|
// get_updated_server_address();
|
||||||
return error;
|
// return error;
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Outdated funcion to log the data gathered from the backend.
|
// Outdated funcion to log the data gathered from the backend.
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
"Default": {
|
"Default": {
|
||||||
"Speedrunner Code": "RULDDRULU",
|
"Speedrunner Code": "RULDDRULU",
|
||||||
"Seeking Spell": "ULURDR",
|
"Seeking Spell": "ULURDR",
|
||||||
"Healing Spell": "DRDLURU"
|
"Healing Spell": "DRDLURU",
|
||||||
|
"Plushie Code": "URRDLDRURRDLDRULDRDLLULDRDLLL"
|
||||||
},
|
},
|
||||||
"Cathedral": {
|
"Cathedral": {
|
||||||
"Secret Legend Door": "LULURULURDRRURDLDRDLDL"
|
"Secret Legend Door": "LULURULURDRRURDLDRDLDL"
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
<div class="flex flex-col space-y-2 max-w-full {{ extra_classes }}" data-current="{{ is_current_scene }}" data-breakdown-scene="{{ scene_title }}">
|
<div class="flex flex-col space-y-2 max-w-full {{ extra_classes }}"
|
||||||
|
data-current="{{ is_current_scene }}"
|
||||||
|
data-breakdown-scene="{{ scene_title }}">
|
||||||
<div class="px-2">
|
<div class="px-2">
|
||||||
<div class="flex text-xl breakdown-block-title">{{ scene_title }}</div>
|
<div class="flex text-xl breakdown-block-title">{{ scene_title }}</div>
|
||||||
<div class="flex flex-col justify-center md:flex-row md:space-x-4">
|
<div class="flex flex-col justify-center md:flex-row md:space-x-4">
|
||||||
<div class="flex flex-col overflow-hidden basis-1/2">
|
<div class="flex flex-col overflow-hidden basis-1/2">
|
||||||
<div class="flex flex-col my-2 space-y-2">
|
<div class="flex flex-col my-2 space-y-2">
|
||||||
<div class="text-md breakdown-block-checks-title">
|
<div class="text-md breakdown-block-checks-title"
|
||||||
|
data-checks="{{ scene_data.checks.collected }}">
|
||||||
Checks: {{ scene_data.checks.collected }}/{{ scene_data.checks.total }}
|
Checks: {{ scene_data.checks.collected }}/{{ scene_data.checks.total }}
|
||||||
</div>
|
</div>
|
||||||
<hr class="border-2 border-bluelight-translucent-dark rounded-xl" />
|
<hr class="border-2 border-bluelight-translucent-dark rounded-xl" />
|
||||||
@ -23,7 +26,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col overflow-hidden basis-1/2">
|
<div class="flex flex-col overflow-hidden basis-1/2">
|
||||||
<div class="flex flex-col my-2 space-y-2">
|
<div class="flex flex-col my-2 space-y-2">
|
||||||
<div class="text-md breakdown-block-entrances-title">
|
<div class="text-md breakdown-block-entrances-title"
|
||||||
|
data-entrances="{{ scene_data.entrances.found }}">
|
||||||
Entrances: {{ scene_data.entrances.found }}/{{ scene_data.entrances.total }}
|
Entrances: {{ scene_data.entrances.found }}/{{ scene_data.entrances.total }}
|
||||||
</div>
|
</div>
|
||||||
<hr class="border-2 border-bluelight-translucent-dark rounded-xl" />
|
<hr class="border-2 border-bluelight-translucent-dark rounded-xl" />
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{% if not is_entered %}
|
{% if not is_entered %}
|
||||||
<ul class="p-2 flex flex-col rounded-xl">
|
<ul class="p-2 flex flex-col rounded-xl {{ extra_classes }}">
|
||||||
<div class="pl-2 codes-list-item-title text-base">{{ name }}</div>
|
<div class="pl-2 text-base codes-list-item-title">{{ name }}</div>
|
||||||
<hr class="mb-2 border-2 border-holy-cross opacity-30 rounded-xl" />
|
<hr class="mb-2 border-2 border-holy-cross opacity-30 rounded-xl" />
|
||||||
<div class="min-x-full">
|
<div class="min-x-full">
|
||||||
<div class="codes-list-item-code text-2xl text-justify break-all mx-2 align-top">{{ code }}</div>
|
<div class="mx-2 text-2xl text-justify break-all align-top codes-list-item-code">{{ code }}</div>
|
||||||
</div>
|
</div>
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
<summary>Holy Cross Codes</summary>
|
<summary>Holy Cross Codes</summary>
|
||||||
<hr class="border-2 border-holy-cross opacity-30 rounded-xl" />
|
<hr class="border-2 border-holy-cross opacity-30 rounded-xl" />
|
||||||
<div class="flex flex-col space-y-2 overflow-y-scroll max-h-96 rounded-xl">
|
<div class="flex flex-col space-y-2 overflow-y-scroll max-h-96 rounded-xl">
|
||||||
<div class="grid grid-flow-row gap-2 md:grid-cols-3 xl:grid-cols-5 rounded-xl" id="codes-list">
|
<div class="grid grid-flow-row gap-2 md:grid-cols-3 xl:grid-cols-5 rounded-xl"
|
||||||
|
id="codes-list">
|
||||||
|
{% include "tracker/codes/block.html" with is_entered=False name="" code="" extra_classes="hidden" %}
|
||||||
{% for name, code in default_codes.items %}
|
{% for name, code in default_codes.items %}
|
||||||
{% include "tracker/codes/block.html" with is_entered=False %}
|
{% include "tracker/codes/block.html" with is_entered=False %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -43,12 +43,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col space-y-2">
|
<div class="flex flex-col space-y-2">
|
||||||
{% include "tracker/status/index.html" %}
|
{% include "tracker/status/index.html" %}
|
||||||
<div class="flex-col max-w-full space-y-2 p-flex">
|
<div class="flex flex-col max-w-full space-y-2">
|
||||||
<div id="breakdown-list">
|
<div class="flex flex-col space-y-2" id="breakdown-list">
|
||||||
{% include "tracker/breakdown/block.html" with extra_classes="hidden" is_current_scene="false" %}
|
{% include "tracker/breakdown/block.html" with extra_classes="hidden" is_current_scene="false" %}
|
||||||
{% for scene_title, scene_data in scenes.items %}
|
{% for scene_title, scene_data in scenes.items %}
|
||||||
{% if scene_title == current_scene %}
|
{% if scene_title == current_scene %}
|
||||||
{% include "tracker/breakdown/block.html" with extra_classes="" is_current_scene="true" %}
|
{% include "tracker/breakdown/block.html" with extra_classes="order-last" is_current_scene="true" %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% include "tracker/breakdown/block.html" with extra_classes="hidden" is_current_scene="false" %}
|
{% include "tracker/breakdown/block.html" with extra_classes="hidden" is_current_scene="false" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -1,20 +1,38 @@
|
|||||||
<div class="grid grid-flow-row gap-2 p-1 overflow-y-scroll md:grid-cols-3 xl:grid-cols-5 max-h-96 rounded-xl scrollbar scrollbar-thumb-bluelight-dark scrollbar-track-bluelight">
|
<div class="grid grid-flow-row gap-2 p-1 overflow-y-scroll md:grid-cols-3 xl:grid-cols-5 max-h-96 rounded-xl scrollbar scrollbar-thumb-bluelight-dark scrollbar-track-bluelight">
|
||||||
{% include "tracker/summary/block.html" with extra_classes="" is_hidden="hidden" %}
|
{% include "tracker/summary/block.html" with extra_classes="" is_hidden="hidden" %}
|
||||||
{% for scene, scene_data in scenes.items %}
|
{% for scene, scene_data in scenes.items %}
|
||||||
{% if scene == current_scene.title %}
|
{% if scene != "Posterity" and scene != "Resurrection" and scene != "Loading" %}
|
||||||
{% include "tracker/summary/block.html" with extra_classes="" is_hidden="hidden" %}
|
|
||||||
{% elif scene != "Entrances" and scene != "Checks" %}
|
|
||||||
{% if scene_data.checks.collected == scene_data.checks.total and scene_data.entrances.found == scene_data.entrances.total %}
|
{% if scene_data.checks.collected == scene_data.checks.total and scene_data.entrances.found == scene_data.entrances.total %}
|
||||||
|
{% if scene == current_scene.title %}
|
||||||
|
{% include "tracker/summary/block.html" with extra_classes="from-highlight-empty-light to-highlight-empty-dark text-highlight-empty-text" is_hidden="hidden" %}
|
||||||
|
{% else %}
|
||||||
{% include "tracker/summary/block.html" with extra_classes="from-highlight-empty-light to-highlight-empty-dark text-highlight-empty-text" is_hidden="" %}
|
{% include "tracker/summary/block.html" with extra_classes="from-highlight-empty-light to-highlight-empty-dark text-highlight-empty-text" is_hidden="" %}
|
||||||
|
{% endif %}
|
||||||
{% elif scene_data.checks.collected <= 0 and scene_data.entrances.found <= 0 and scene_data.entrances.total > 0 %}
|
{% elif scene_data.checks.collected <= 0 and scene_data.entrances.found <= 0 and scene_data.entrances.total > 0 %}
|
||||||
|
{% if scene == current_scene.title %}
|
||||||
|
{% include "tracker/summary/block.html" with extra_classes="from-highlight-undiscovered-light to-highlight-undiscovered-dark text-highlight-undiscovered-text" is_hidden="hidden" %}
|
||||||
|
{% else %}
|
||||||
{% include "tracker/summary/block.html" with extra_classes="from-highlight-undiscovered-light to-highlight-undiscovered-dark text-highlight-undiscovered-text" is_hidden="" %}
|
{% include "tracker/summary/block.html" with extra_classes="from-highlight-undiscovered-light to-highlight-undiscovered-dark text-highlight-undiscovered-text" is_hidden="" %}
|
||||||
|
{% endif %}
|
||||||
{% elif scene_data.checks.collected >= scene_data.checks.total %}
|
{% elif scene_data.checks.collected >= scene_data.checks.total %}
|
||||||
|
{% if scene == current_scene.title %}
|
||||||
|
{% include "tracker/summary/block.html" with extra_classes="from-highlight-checks-light to-highlight-checks-dark text-highlight-checks-text" is_hidden="hidden" %}
|
||||||
|
{% else %}
|
||||||
{% include "tracker/summary/block.html" with extra_classes="from-highlight-checks-light to-highlight-checks-dark text-highlight-checks-text" is_hidden="" %}
|
{% include "tracker/summary/block.html" with extra_classes="from-highlight-checks-light to-highlight-checks-dark text-highlight-checks-text" is_hidden="" %}
|
||||||
|
{% endif %}
|
||||||
{% elif scene_data.entrances.found >= scene_data.entrances.total %}
|
{% elif scene_data.entrances.found >= scene_data.entrances.total %}
|
||||||
|
{% if scene == current_scene.title %}
|
||||||
|
{% include "tracker/summary/block.html" with extra_classes="from-highlight-entrances-light to-highlight-entrances-dark text-highlight-entrances-text" is_hidden="hidden" %}
|
||||||
|
{% else %}
|
||||||
{% include "tracker/summary/block.html" with extra_classes="from-highlight-entrances-light to-highlight-entrances-dark text-highlight-entrances-text" is_hidden="" %}
|
{% include "tracker/summary/block.html" with extra_classes="from-highlight-entrances-light to-highlight-entrances-dark text-highlight-entrances-text" is_hidden="" %}
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{% if scene == current_scene.title %}
|
||||||
|
{% include "tracker/summary/block.html" with extra_classes="from-highlight-both-light to-highlight-both-dark text-highlight-both-text" is_hidden="hidden" %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% include "tracker/summary/block.html" with extra_classes="from-highlight-both-light to-highlight-both-dark text-highlight-both-text" is_hidden="" %}
|
{% include "tracker/summary/block.html" with extra_classes="from-highlight-both-light to-highlight-both-dark text-highlight-both-text" is_hidden="" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user