mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-11-28 08:27:27 +00:00
Add optional allowQuery parameter.
This commit is contained in:
parent
89e8a3b80e
commit
8901a97fcb
16
src/main.js
16
src/main.js
@ -125,10 +125,10 @@ const mixin = {
|
|||||||
if (!disableAlert) alert(this.$t("info.local_storage"));
|
if (!disableAlert) alert(this.$t("info.local_storage"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getPreferenceBoolean(key, defaultVal) {
|
getPreferenceBoolean(key, defaultVal, allowQuery = true) {
|
||||||
var value;
|
var value;
|
||||||
if (
|
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)
|
(this.testLocalStorage && (value = localStorage.getItem(key)) !== null)
|
||||||
) {
|
) {
|
||||||
switch (String(value).toLowerCase()) {
|
switch (String(value).toLowerCase()) {
|
||||||
@ -142,29 +142,29 @@ const mixin = {
|
|||||||
}
|
}
|
||||||
} else return defaultVal;
|
} else return defaultVal;
|
||||||
},
|
},
|
||||||
getPreferenceString(key, defaultVal) {
|
getPreferenceString(key, defaultVal, allowQuery = true) {
|
||||||
var value;
|
var value;
|
||||||
if (
|
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)
|
(this.testLocalStorage && (value = localStorage.getItem(key)) !== null)
|
||||||
) {
|
) {
|
||||||
return value;
|
return value;
|
||||||
} else return defaultVal;
|
} else return defaultVal;
|
||||||
},
|
},
|
||||||
getPreferenceNumber(key, defaultVal) {
|
getPreferenceNumber(key, defaultVal, allowQuery = true) {
|
||||||
var value;
|
var value;
|
||||||
if (
|
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)
|
(this.testLocalStorage && (value = localStorage.getItem(key)) !== null)
|
||||||
) {
|
) {
|
||||||
const num = Number(value);
|
const num = Number(value);
|
||||||
return isNaN(num) ? defaultVal : num;
|
return isNaN(num) ? defaultVal : num;
|
||||||
} else return defaultVal;
|
} else return defaultVal;
|
||||||
},
|
},
|
||||||
getPreferenceJSON(key, defaultVal) {
|
getPreferenceJSON(key, defaultVal, allowQuery = true) {
|
||||||
var value;
|
var value;
|
||||||
if (
|
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)
|
(this.testLocalStorage && (value = localStorage.getItem(key)) !== null)
|
||||||
) {
|
) {
|
||||||
return JSON.parse(value);
|
return JSON.parse(value);
|
||||||
|
Loading…
Reference in New Issue
Block a user