let type;
let value;
- /* get default value from configuration */
if (Object.prototype.hasOwnProperty.call(Conf, key)) {
+ // get default value from configuration
value = Conf[key];
type = typeof value;
+ } else if (Object.prototype.hasOwnProperty.call(SettingsTypes, key)) {
+ type = SettingsTypes[key];
}
/* try to retrieve value from localstorage */
/* get type from localStorage if no default is set */
if (typeof type === "undefined") {
- if (Object.prototype.hasOwnProperty.call(localStorage, "trivabble" + key + "_type")) {
- type = localStorage.getItem("trivabble" + key + "_type");
- } else {
- type = "string";
- }
+ type = "string";
}
/* cast from string to type */
return value;
}
+ function unsetSetting(key) {
+ localStorage.removeItem("trivabble" + key);
+ }
+
function setSetting(key, value) {
if (getSetting(key) === value) {
return;
type = typeof Conf[key];
}
- /* try to retrieve type from localstorage */
- if (typeof type === "undefined") {
- if (Object.prototype.hasOwnProperty.call(localStorage, "trivabble" + key)) {
- type = localStorage.getItem("trivabble" + key + "_type");
- }
- }
-
/* storage value in localstorage */
if (type === typeof value) {
if (type === "object") {
if (tilesSound) {
/* migration of old settings for tiles sound */
- const oldSetting = getSetting("trivabbleTilesSound");
+ const oldSetting = getSetting("TilesSound");
if (oldSetting) {
setSetting("ENABLE_TILE_SOUND", oldSetting === "true");
delete localStorage.trivabbleTilesSound;
if (msgSound) {
/* migration of old settings for message sound */
- const oldSetting = getSetting("trivabbleMsgSound");
+ const oldSetting = getSetting("MsgSound");
if (oldSetting) {
setSetting("ENABLE_MSG_SOUND", oldSetting === "true");
delete localStorage.trivabbleMsgSound;
const disabled = !getSetting("ENABLE_SPELL_CHECKER") || document.getElementById("disable-spell-checker").checked;
document.getElementById("check-spelling").hidden = disabled;
document.getElementById("info-spell-checking").hidden = disabled;
+
if (e) {
setSetting("DisableSpellChecker", disabled);
}
+
+ if (disabled) {
+ unsetSetting("SpellCheckerEnabledOnce");
+ }
}
function initSpellChecker() {
}
function langSelectionChange(e) {
- setSetting("trivabbleLang", e.target.value);
+ setSetting("Lang", e.target.value);
location.reload();
}
}
function initLang() {
- const lang = libD.lang = getSetting("trivabbleLang") || libD.lang;
+ const lang = libD.lang = getSetting("Lang") || libD.lang;
const langSel = document.getElementById("select-lang");
langSel.value = lang;