Move cookies to local storage

Fixes #7.
This commit is contained in:
Florine W. Dekker 2020-08-10 20:26:51 +02:00
parent 666a4f9244
commit 4cef9c30fd
Signed by untrusted user: FWDekker
GPG Key ID: B1B567AF58D6EE0F
3 changed files with 5 additions and 9 deletions

BIN
package-lock.json generated

Binary file not shown.

View File

@ -1,6 +1,6 @@
{
"name": "doomsday",
"version": "1.3.6",
"version": "1.3.7",
"description": "Test your mastery of Conway's Doomsday rule.",
"author": "Felix W. Dekker",
"browser": "dist/bundle.js",
@ -16,11 +16,9 @@
"deploy": "grunt deploy"
},
"dependencies": {
"@fwdekker/template": "^0.0.18",
"js-cookie": "^2.2.1"
"@fwdekker/template": "^0.0.20"
},
"devDependencies": {
"@types/js-cookie": "^2.2.6",
"grunt": "^1.2.1",
"grunt-cli": "^1.3.2",
"grunt-contrib-clean": "^2.0.0",

View File

@ -1,5 +1,4 @@
import {$, doAfterLoad, footer, header, nav} from "@fwdekker/template";
import Cookies from "js-cookie";
/**
@ -152,7 +151,7 @@ class ValidatableInput {
}
/**
* A wrapper around a `<details>` element that persists the state in a cookie.
* A wrapper around a `<details>` element that persists the state in local storage.
*/
class ToggleableSection {
/**
@ -204,8 +203,7 @@ class ToggleableSection {
* @private
*/
_storeToggle() {
Cookies.set(`toggle-${this._name}`, "" + this.isOpened(),
{expires: 365 * 10, secure: true, sameSite: "lax", path: ""});
localStorage.setItem(`/tools/doomsday//toggle-${this._name}`, "" + this.isOpened());
}
/**
@ -214,7 +212,7 @@ class ToggleableSection {
* @private
*/
_loadToggle() {
const target = Cookies.get(`toggle-${this._name}`);
const target = localStorage.getItem(`/tools/doomsday//toggle-${this._name}`);
if (target === undefined) {
this._storeToggle();
return;