25 lines
546 B
JavaScript
25 lines
546 B
JavaScript
|
const initAlign = () => {
|
||
|
const cur = localStorage.getItem("align");
|
||
|
const prev = cur == "center" ? "left" : "center";
|
||
|
document.body.classList.add("align-" + cur);
|
||
|
document.body.classList.remove("align-" + prev);
|
||
|
};
|
||
|
|
||
|
if (localStorage.getItem("align") === null) {
|
||
|
localStorage.setItem("align", "center");
|
||
|
}
|
||
|
|
||
|
initAlign();
|
||
|
|
||
|
const toggleAlign = (ev) => {
|
||
|
localStorage.setItem(
|
||
|
"align",
|
||
|
localStorage.getItem("align") == "center" ? "left" : "center",
|
||
|
);
|
||
|
initAlign();
|
||
|
if (!!ev.target) ev.preventDefault();
|
||
|
return false;
|
||
|
};
|
||
|
|
||
|
|