mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-22 11:39:30 -07:00
parse settings from querystring
This commit is contained in:
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@@ -18,4 +18,8 @@
|
|||||||
"**/compiled.css": true,
|
"**/compiled.css": true,
|
||||||
"**/*.min.js": true,
|
"**/*.min.js": true,
|
||||||
},
|
},
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.fixAll.eslint": "explicit"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { parseQueryString } from '../share.mjs';
|
||||||
|
|
||||||
const SETTINGS_KEY = 'Settings';
|
const SETTINGS_KEY = 'Settings';
|
||||||
|
|
||||||
class Setting {
|
class Setting {
|
||||||
@@ -9,10 +11,17 @@ class Setting {
|
|||||||
this.myValue = defaultValue;
|
this.myValue = defaultValue;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
// a default blank change function is provided
|
// a default blank change function is provided
|
||||||
this.changeAction = changeAction ?? (() => {});
|
this.changeAction = changeAction ?? (() => { });
|
||||||
|
|
||||||
|
// get value from url
|
||||||
|
const urlValue = parseQueryString()?.[`settings-${shortName}-checkbox`];
|
||||||
|
let urlState;
|
||||||
|
if (urlValue !== undefined) {
|
||||||
|
urlState = urlValue === 'true';
|
||||||
|
}
|
||||||
|
|
||||||
// get existing value if present
|
// get existing value if present
|
||||||
const storedValue = this.getFromLocalStorage();
|
const storedValue = urlState ?? this.getFromLocalStorage();
|
||||||
if (sticky && storedValue !== null) {
|
if (sticky && storedValue !== null) {
|
||||||
this.myValue = storedValue;
|
this.myValue = storedValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
},
|
},
|
||||||
"files.exclude": {},
|
"files.exclude": {},
|
||||||
"files.eol": "\n",
|
"files.eol": "\n",
|
||||||
|
"editor.formatOnSave": true,
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": "explicit"
|
"source.fixAll.eslint": "explicit"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user