Saving and loading tracked drops
parent
cf7edba39f
commit
a1319396b6
|
|
@ -5,6 +5,7 @@ name = "Arendelle"
|
|||
|
||||
[[world]]
|
||||
name = "San Fransokyo"
|
||||
rooms = ["Battlegate 11"]
|
||||
|
||||
[[drops]]
|
||||
name = "Writhing Gem"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,19 @@
|
|||
const TRACKED_STORAGE_NAME = "/drops/tracked/";
|
||||
|
||||
let gameName;
|
||||
|
||||
export let showOnlyTracked = false;
|
||||
export let kindFilter = new Set();
|
||||
|
||||
export function init() {
|
||||
const url = window.location.href;
|
||||
const firstPoint = url.indexOf("/", 8);
|
||||
const subUrl = url.substring(firstPoint + 1);
|
||||
const finalPoint = subUrl.indexOf("/");
|
||||
gameName = subUrl.substring(0, finalPoint);
|
||||
|
||||
loadTracked();
|
||||
|
||||
const onlyTrackedFilter = document.querySelector(
|
||||
'input[name="onlyTracked"]',
|
||||
);
|
||||
|
|
@ -49,12 +61,49 @@ function filter() {
|
|||
}
|
||||
}
|
||||
|
||||
function loadTracked() {
|
||||
const categories = document.querySelectorAll(".category-wrapper");
|
||||
let updates = 0;
|
||||
|
||||
for (const category of categories) {
|
||||
let id =
|
||||
category.dataset["matKind"] + "-" + category.dataset["matType"];
|
||||
id = gameName + TRACKED_STORAGE_NAME + id;
|
||||
|
||||
let isTracked = localStorage.getItem(id) === "true";
|
||||
if (isTracked) {
|
||||
category.dataset["isTracked"] = true;
|
||||
let trackButton = category.querySelector(".category button");
|
||||
updateTrackedState(trackButton, isTracked);
|
||||
updates += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (updates > 0) {
|
||||
filter();
|
||||
}
|
||||
}
|
||||
|
||||
export function track(element) {
|
||||
let parent = element.parentElement.parentElement;
|
||||
let id = parent.dataset["matKind"] + "-" + parent.dataset["matType"];
|
||||
id = gameName + TRACKED_STORAGE_NAME + id;
|
||||
|
||||
let isTracked = parent.dataset["isTracked"] ?? false;
|
||||
isTracked = isTracked === "true" ? false : true;
|
||||
|
||||
if (isTracked) {
|
||||
localStorage.setItem(id, true);
|
||||
} else {
|
||||
localStorage.removeItem(id);
|
||||
}
|
||||
|
||||
parent.dataset["isTracked"] = isTracked;
|
||||
element.innerHTML = isTracked ? "Stop tracking" : "Start tracking";
|
||||
element.style["border-bottom-color"] = isTracked ? "#a00" : "#0a0";
|
||||
updateTrackedState(element, isTracked);
|
||||
filter();
|
||||
}
|
||||
|
||||
function updateTrackedState(element, isTracked) {
|
||||
element.innerHTML = isTracked ? "Stop tracking" : "Start tracking";
|
||||
element.style["border-bottom-color"] = isTracked ? "#a00" : "#0a0";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import "../common/prototypes.js";
|
||||
|
||||
const RECIPE_STORAGE_NAME = "kh1/synth/recipe.";
|
||||
const LIST_STORAGE_NAME = "kh1/synth/needed-maths";
|
||||
const RECIPE_STORAGE_NAME = "kh1/synth/";
|
||||
const LIST_STORAGE_NAME = "kh1/synth/needed-mats";
|
||||
|
||||
let markedNeededMaterials = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -107,8 +107,6 @@ function selectRecipe(item, index) {
|
|||
}
|
||||
|
||||
let recipeName = item.querySelector(".title").innerText;
|
||||
console.log(item);
|
||||
console.log(item.querySelectorAll(".title"));
|
||||
localStorage.setItem(STORAGE_NAME + index, recipeName);
|
||||
|
||||
let stats = JSON.parse(item.dataset["stats"]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue