User:Willowisp/vector-2022.js

From Baldur's Gate 3 Wiki
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
let spoilerElement = document.getElementById("spoiler");
function updateHiddenStatus({ status }) {
	spoilerElement.setAttribute("hidden-status", status);
}

let spoilerButton = document.getElementById("spoiler-button");
spoilerButton.addEventListener("click", (event) => {
	const newHiddenStatus = currentHiddenStatus === "hidden" ? "notHidden" : "hidden";
	localStorage.setItem("hidden-status", newHiddenStatus);
	updateHiddenStatus({ status: newHiddenStatus });
	currentHiddenStatus = newHiddenStatus;
});

const localStorageHiddenStatus = localStorage.getItem("spoler-status");

let currentHiddenStatus = checkHiddenStatus({ localStorageHiddenStatus });
updateHiddenStatus({ status: currentHiddenStatus });

function checkHiddenStatus({ localStorageHiddenStatus }) {
	if (localStorageHiddenStatus !== null) {
		return localStorageHiddenStatus;
	}
	return "notHidden";
}