From 8901a97fcbb8cb78c38729a9281a1ef5c026313d Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Mon, 20 Feb 2023 11:46:33 +0000 Subject: [PATCH] Add optional allowQuery parameter. --- src/main.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.js b/src/main.js index 37148852..8bcade0c 100644 --- a/src/main.js +++ b/src/main.js @@ -125,10 +125,10 @@ const mixin = { if (!disableAlert) alert(this.$t("info.local_storage")); } }, - getPreferenceBoolean(key, defaultVal) { + getPreferenceBoolean(key, defaultVal, allowQuery = true) { var value; if ( - (value = new URLSearchParams(window.location.search).get(key)) !== null || + (allowQuery && (value = new URLSearchParams(window.location.search).get(key)) !== null) || (this.testLocalStorage && (value = localStorage.getItem(key)) !== null) ) { switch (String(value).toLowerCase()) { @@ -142,29 +142,29 @@ const mixin = { } } else return defaultVal; }, - getPreferenceString(key, defaultVal) { + getPreferenceString(key, defaultVal, allowQuery = true) { var value; if ( - (value = new URLSearchParams(window.location.search).get(key)) !== null || + (allowQuery && (value = new URLSearchParams(window.location.search).get(key)) !== null) || (this.testLocalStorage && (value = localStorage.getItem(key)) !== null) ) { return value; } else return defaultVal; }, - getPreferenceNumber(key, defaultVal) { + getPreferenceNumber(key, defaultVal, allowQuery = true) { var value; if ( - (value = new URLSearchParams(window.location.search).get(key)) !== null || + (allowQuery && (value = new URLSearchParams(window.location.search).get(key)) !== null) || (this.testLocalStorage && (value = localStorage.getItem(key)) !== null) ) { const num = Number(value); return isNaN(num) ? defaultVal : num; } else return defaultVal; }, - getPreferenceJSON(key, defaultVal) { + getPreferenceJSON(key, defaultVal, allowQuery = true) { var value; if ( - (value = new URLSearchParams(window.location.search).get(key)) !== null || + (allowQuery && (value = new URLSearchParams(window.location.search).get(key)) !== null) || (this.testLocalStorage && (value = localStorage.getItem(key)) !== null) ) { return JSON.parse(value);