parse settings from querystring

This commit is contained in:
Matt Walsh
2024-04-19 21:05:52 -05:00
parent 5d0f41f207
commit 6d4ec8b958
3 changed files with 16 additions and 2 deletions

View File

@@ -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"
}
} }

View File

@@ -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;
} }

View File

@@ -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"
} }