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