2022-10-17 09:14:05 +02:00
|
|
|
|
// Saving settings
|
|
|
|
|
let saveSettingsConfigTable = document.getElementById("save-settings-config-table")
|
|
|
|
|
let saveSettingsConfigOverlay = document.getElementById("save-settings-config")
|
2022-10-20 06:12:01 +02:00
|
|
|
|
let resetImageSettingsButton = document.getElementById("reset-image-settings")
|
2022-10-17 09:14:05 +02:00
|
|
|
|
|
2022-10-20 06:12:01 +02:00
|
|
|
|
const SETTINGS_KEY = "user_settings_v2"
|
|
|
|
|
|
|
|
|
|
const SETTINGS = {} // key=id. dict initialized in initSettings. { element, default, value, ignore }
|
|
|
|
|
const SETTINGS_IDS_LIST = [
|
|
|
|
|
"prompt",
|
2022-10-17 09:14:05 +02:00
|
|
|
|
"seed",
|
|
|
|
|
"random_seed",
|
|
|
|
|
"num_outputs_total",
|
|
|
|
|
"num_outputs_parallel",
|
|
|
|
|
"stable_diffusion_model",
|
2023-05-18 13:55:45 +02:00
|
|
|
|
"clip_skip",
|
2022-11-08 12:24:15 +01:00
|
|
|
|
"vae_model",
|
2022-12-07 06:54:16 +01:00
|
|
|
|
"hypernetwork_model",
|
2023-03-21 13:29:20 +01:00
|
|
|
|
"lora_model",
|
2022-12-12 10:51:02 +01:00
|
|
|
|
"sampler_name",
|
2022-10-17 09:14:05 +02:00
|
|
|
|
"width",
|
|
|
|
|
"height",
|
|
|
|
|
"num_inference_steps",
|
2022-10-20 06:12:01 +02:00
|
|
|
|
"guidance_scale",
|
|
|
|
|
"prompt_strength",
|
2022-12-07 06:54:16 +01:00
|
|
|
|
"hypernetwork_strength",
|
2023-03-21 13:29:20 +01:00
|
|
|
|
"lora_alpha",
|
2022-10-17 09:14:05 +02:00
|
|
|
|
"output_format",
|
2022-12-05 06:32:33 +01:00
|
|
|
|
"output_quality",
|
2023-03-25 03:46:03 +01:00
|
|
|
|
"output_lossless",
|
2022-10-17 09:14:05 +02:00
|
|
|
|
"negative_prompt",
|
|
|
|
|
"stream_image_progress",
|
|
|
|
|
"use_face_correction",
|
2023-01-19 20:49:54 +01:00
|
|
|
|
"gfpgan_model",
|
2022-10-17 09:14:05 +02:00
|
|
|
|
"use_upscale",
|
2022-12-27 11:50:16 +01:00
|
|
|
|
"upscale_amount",
|
2023-02-18 10:31:13 +01:00
|
|
|
|
"block_nsfw",
|
2022-10-17 09:14:05 +02:00
|
|
|
|
"show_only_filtered_image",
|
|
|
|
|
"upscale_model",
|
|
|
|
|
"preview-image",
|
2022-10-18 08:00:08 +02:00
|
|
|
|
"modifier-card-size-slider",
|
2022-10-19 05:49:58 +02:00
|
|
|
|
"theme",
|
|
|
|
|
"save_to_disk",
|
|
|
|
|
"diskPath",
|
|
|
|
|
"sound_toggle",
|
2022-12-16 07:04:49 +01:00
|
|
|
|
"vram_usage_level",
|
2022-11-23 23:05:30 +01:00
|
|
|
|
"confirm_dangerous_actions",
|
2022-12-12 09:36:20 +01:00
|
|
|
|
"metadata_output_format",
|
2022-12-09 15:09:56 +01:00
|
|
|
|
"auto_save_settings",
|
2022-12-29 02:50:18 +01:00
|
|
|
|
"apply_color_correction",
|
2023-02-22 15:02:00 +01:00
|
|
|
|
"process_order_toggle",
|
2023-03-01 13:57:48 +01:00
|
|
|
|
"thumbnail_size",
|
2023-03-14 06:10:24 +01:00
|
|
|
|
"auto_scroll",
|
|
|
|
|
"zip_toggle",
|
|
|
|
|
"tree_toggle",
|
2023-04-28 12:20:44 +02:00
|
|
|
|
"json_toggle",
|
2022-10-17 09:14:05 +02:00
|
|
|
|
]
|
|
|
|
|
|
2023-04-27 19:56:56 +02:00
|
|
|
|
const IGNORE_BY_DEFAULT = ["prompt"]
|
2022-10-20 06:12:01 +02:00
|
|
|
|
|
2023-04-27 19:56:56 +02:00
|
|
|
|
const SETTINGS_SECTIONS = [
|
|
|
|
|
// gets the "keys" property filled in with an ordered list of settings in this section via initSettings
|
|
|
|
|
{ id: "editor-inputs", name: "Prompt" },
|
2022-10-20 06:12:01 +02:00
|
|
|
|
{ id: "editor-settings", name: "Image Settings" },
|
|
|
|
|
{ id: "system-settings", name: "System Settings" },
|
2023-04-28 12:20:44 +02:00
|
|
|
|
{ id: "container", name: "Other" },
|
2022-10-20 06:12:01 +02:00
|
|
|
|
]
|
|
|
|
|
|
2022-10-17 09:14:05 +02:00
|
|
|
|
async function initSettings() {
|
2023-04-27 19:56:56 +02:00
|
|
|
|
SETTINGS_IDS_LIST.forEach((id) => {
|
2022-10-20 06:12:01 +02:00
|
|
|
|
var element = document.getElementById(id)
|
2022-10-29 03:25:54 +02:00
|
|
|
|
if (!element) {
|
|
|
|
|
console.error(`Missing settings element ${id}`)
|
|
|
|
|
}
|
2023-04-27 19:56:56 +02:00
|
|
|
|
if (id in SETTINGS) {
|
|
|
|
|
// don't create it again
|
2022-11-30 11:15:30 +01:00
|
|
|
|
return
|
|
|
|
|
}
|
2022-10-20 06:12:01 +02:00
|
|
|
|
SETTINGS[id] = {
|
|
|
|
|
key: id,
|
|
|
|
|
element: element,
|
|
|
|
|
label: getSettingLabel(element),
|
|
|
|
|
default: getSetting(element),
|
|
|
|
|
value: getSetting(element),
|
2023-04-28 12:20:44 +02:00
|
|
|
|
ignore: IGNORE_BY_DEFAULT.includes(id),
|
2022-10-20 06:12:01 +02:00
|
|
|
|
}
|
2022-10-17 09:14:05 +02:00
|
|
|
|
element.addEventListener("input", settingChangeHandler)
|
|
|
|
|
element.addEventListener("change", settingChangeHandler)
|
|
|
|
|
})
|
2022-10-20 06:12:01 +02:00
|
|
|
|
var unsorted_settings_ids = [...SETTINGS_IDS_LIST]
|
2023-04-27 19:56:56 +02:00
|
|
|
|
SETTINGS_SECTIONS.forEach((section) => {
|
2022-10-20 06:12:01 +02:00
|
|
|
|
var name = section.name
|
|
|
|
|
var element = document.getElementById(section.id)
|
2023-04-27 19:56:56 +02:00
|
|
|
|
var unsorted_ids = unsorted_settings_ids.map((id) => `#${id}`).join(",")
|
|
|
|
|
var children = unsorted_ids == "" ? [] : Array.from(element.querySelectorAll(unsorted_ids))
|
2022-10-20 06:12:01 +02:00
|
|
|
|
section.keys = []
|
2023-04-27 19:56:56 +02:00
|
|
|
|
children.forEach((e) => {
|
2022-10-20 06:12:01 +02:00
|
|
|
|
section.keys.push(e.id)
|
|
|
|
|
})
|
2023-04-27 19:56:56 +02:00
|
|
|
|
unsorted_settings_ids = unsorted_settings_ids.filter((id) => children.find((e) => e.id == id) == undefined)
|
2022-10-20 06:12:01 +02:00
|
|
|
|
})
|
2022-10-17 09:14:05 +02:00
|
|
|
|
loadSettings()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSetting(element) {
|
2023-04-27 19:56:56 +02:00
|
|
|
|
if (element.dataset && "path" in element.dataset) {
|
2023-02-12 10:18:09 +01:00
|
|
|
|
return element.dataset.path
|
|
|
|
|
}
|
2022-10-20 06:12:01 +02:00
|
|
|
|
if (typeof element === "string" || element instanceof String) {
|
|
|
|
|
element = SETTINGS[element].element
|
2022-10-19 05:49:58 +02:00
|
|
|
|
}
|
2022-10-17 09:14:05 +02:00
|
|
|
|
if (element.type == "checkbox") {
|
|
|
|
|
return element.checked
|
|
|
|
|
}
|
|
|
|
|
return element.value
|
|
|
|
|
}
|
|
|
|
|
function setSetting(element, value) {
|
2023-04-27 19:56:56 +02:00
|
|
|
|
if (element.dataset && "path" in element.dataset) {
|
2023-02-12 10:18:09 +01:00
|
|
|
|
element.dataset.path = value
|
|
|
|
|
return // no need to dispatch any event here because the models are not loaded yet
|
|
|
|
|
}
|
2022-10-19 07:13:45 +02:00
|
|
|
|
if (typeof element === "string" || element instanceof String) {
|
2022-10-20 06:12:01 +02:00
|
|
|
|
element = SETTINGS[element].element
|
2022-10-19 07:13:45 +02:00
|
|
|
|
}
|
2022-10-20 06:12:01 +02:00
|
|
|
|
SETTINGS[element.id].value = value
|
2022-10-17 09:14:05 +02:00
|
|
|
|
if (getSetting(element) == value) {
|
|
|
|
|
return // no setting necessary
|
|
|
|
|
}
|
|
|
|
|
if (element.type == "checkbox") {
|
|
|
|
|
element.checked = value
|
2023-04-27 19:56:56 +02:00
|
|
|
|
} else {
|
2022-10-17 09:14:05 +02:00
|
|
|
|
element.value = value
|
|
|
|
|
}
|
|
|
|
|
element.dispatchEvent(new Event("input"))
|
|
|
|
|
element.dispatchEvent(new Event("change"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function saveSettings() {
|
2023-04-27 19:56:56 +02:00
|
|
|
|
var saved_settings = Object.values(SETTINGS).map((setting) => {
|
2022-10-20 06:12:01 +02:00
|
|
|
|
return {
|
|
|
|
|
key: setting.key,
|
|
|
|
|
value: setting.value,
|
2023-04-28 12:20:44 +02:00
|
|
|
|
ignore: setting.ignore,
|
2022-10-20 06:12:01 +02:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
localStorage.setItem(SETTINGS_KEY, JSON.stringify(saved_settings))
|
2022-10-17 09:14:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var CURRENTLY_LOADING_SETTINGS = false
|
|
|
|
|
function loadSettings() {
|
2022-10-20 06:12:01 +02:00
|
|
|
|
var saved_settings_text = localStorage.getItem(SETTINGS_KEY)
|
|
|
|
|
if (saved_settings_text) {
|
|
|
|
|
var saved_settings = JSON.parse(saved_settings_text)
|
2023-04-27 19:56:56 +02:00
|
|
|
|
if (saved_settings.find((s) => s.key == "auto_save_settings")?.value == false) {
|
2022-10-20 06:12:01 +02:00
|
|
|
|
setSetting("auto_save_settings", false)
|
|
|
|
|
return
|
|
|
|
|
}
|
2022-10-17 09:14:05 +02:00
|
|
|
|
CURRENTLY_LOADING_SETTINGS = true
|
2023-04-27 19:56:56 +02:00
|
|
|
|
saved_settings.forEach((saved_setting) => {
|
2022-10-20 06:12:01 +02:00
|
|
|
|
var setting = SETTINGS[saved_setting.key]
|
2022-10-29 03:25:54 +02:00
|
|
|
|
if (!setting) {
|
2023-04-27 19:56:56 +02:00
|
|
|
|
console.warn(`Attempted to load setting ${saved_setting.key}, but no setting found`)
|
|
|
|
|
return null
|
2022-10-29 03:25:54 +02:00
|
|
|
|
}
|
2022-10-20 06:12:01 +02:00
|
|
|
|
setting.ignore = saved_setting.ignore
|
|
|
|
|
if (!setting.ignore) {
|
|
|
|
|
setting.value = saved_setting.value
|
|
|
|
|
setSetting(setting.element, setting.value)
|
2022-10-17 09:14:05 +02:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
CURRENTLY_LOADING_SETTINGS = false
|
2023-05-21 17:42:47 +02:00
|
|
|
|
} else if (localStorage.length < 2) {
|
|
|
|
|
// localStorage is too short for OldSettings
|
|
|
|
|
// So this is likely the first time Easy Diffusion is running.
|
|
|
|
|
// Initialize vram_usage_level based on the available VRAM
|
|
|
|
|
function initGPUProfile(event) {
|
|
|
|
|
if ( "detail" in event
|
|
|
|
|
&& "active" in event.detail
|
|
|
|
|
&& "cuda:0" in event.detail.active
|
|
|
|
|
&& event.detail.active["cuda:0"].mem_total <4.5 )
|
|
|
|
|
{
|
|
|
|
|
vramUsageLevelField.value = "low"
|
|
|
|
|
vramUsageLevelField.dispatchEvent(new Event("change"))
|
|
|
|
|
}
|
|
|
|
|
document.removeEventListener("system_info_update", initGPUProfile)
|
|
|
|
|
}
|
|
|
|
|
document.addEventListener("system_info_update", initGPUProfile)
|
2023-04-27 19:56:56 +02:00
|
|
|
|
} else {
|
2022-10-22 02:13:13 +02:00
|
|
|
|
CURRENTLY_LOADING_SETTINGS = true
|
2023-04-27 19:56:56 +02:00
|
|
|
|
tryLoadOldSettings()
|
2022-10-22 02:13:13 +02:00
|
|
|
|
CURRENTLY_LOADING_SETTINGS = false
|
2022-10-17 09:14:05 +02:00
|
|
|
|
saveSettings()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 06:12:01 +02:00
|
|
|
|
function loadDefaultSettingsSection(section_id) {
|
2022-10-17 09:14:05 +02:00
|
|
|
|
CURRENTLY_LOADING_SETTINGS = true
|
2023-04-27 19:56:56 +02:00
|
|
|
|
var section = SETTINGS_SECTIONS.find((s) => s.id == section_id)
|
|
|
|
|
section.keys.forEach((key) => {
|
|
|
|
|
var setting = SETTINGS[key]
|
2022-10-20 06:12:01 +02:00
|
|
|
|
setting.value = setting.default
|
|
|
|
|
setSetting(setting.element, setting.value)
|
2022-10-17 09:14:05 +02:00
|
|
|
|
})
|
|
|
|
|
CURRENTLY_LOADING_SETTINGS = false
|
|
|
|
|
saveSettings()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function settingChangeHandler(event) {
|
|
|
|
|
if (!CURRENTLY_LOADING_SETTINGS) {
|
|
|
|
|
var element = event.target
|
|
|
|
|
var value = getSetting(element)
|
2022-10-20 06:12:01 +02:00
|
|
|
|
if (value != SETTINGS[element.id].value) {
|
|
|
|
|
SETTINGS[element.id].value = value
|
2022-10-17 09:14:05 +02:00
|
|
|
|
saveSettings()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 06:12:01 +02:00
|
|
|
|
function getSettingLabel(element) {
|
|
|
|
|
var labelElement = document.querySelector(`label[for='${element.id}']`)
|
|
|
|
|
var label = labelElement?.innerText || element.id
|
|
|
|
|
var truncate_length = 30
|
|
|
|
|
if (label.includes(" (")) {
|
|
|
|
|
label = label.substring(0, label.indexOf(" ("))
|
|
|
|
|
}
|
|
|
|
|
if (label.length > truncate_length) {
|
|
|
|
|
label = label.substring(0, truncate_length - 3) + "..."
|
|
|
|
|
}
|
|
|
|
|
label = label.replace("➕", "")
|
|
|
|
|
label = label.replace("➖", "")
|
|
|
|
|
return label
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-17 09:14:05 +02:00
|
|
|
|
function fillSaveSettingsConfigTable() {
|
2022-10-20 06:12:01 +02:00
|
|
|
|
saveSettingsConfigTable.textContent = ""
|
2023-04-27 19:56:56 +02:00
|
|
|
|
SETTINGS_SECTIONS.forEach((section) => {
|
2022-10-20 06:12:01 +02:00
|
|
|
|
var section_row = `<tr><th>${section.name}</th><td></td></tr>`
|
|
|
|
|
saveSettingsConfigTable.insertAdjacentHTML("beforeend", section_row)
|
2023-04-27 19:56:56 +02:00
|
|
|
|
section.keys.forEach((key) => {
|
2022-10-20 06:12:01 +02:00
|
|
|
|
var setting = SETTINGS[key]
|
|
|
|
|
var element = setting.element
|
|
|
|
|
var checkbox_id = `shouldsave_${element.id}`
|
|
|
|
|
var is_checked = setting.ignore ? "" : "checked"
|
|
|
|
|
var value = setting.value
|
|
|
|
|
var value_truncate_length = 30
|
|
|
|
|
if ((typeof value === "string" || value instanceof String) && value.length > value_truncate_length) {
|
|
|
|
|
value = value.substring(0, value_truncate_length - 3) + "..."
|
2022-10-17 09:14:05 +02:00
|
|
|
|
}
|
2022-10-20 06:12:01 +02:00
|
|
|
|
var newrow = `<tr><td><label for="${checkbox_id}">${setting.label}</label></td><td><input id="${checkbox_id}" name="${checkbox_id}" ${is_checked} type="checkbox" ></td><td><small>(${value})</small></td></tr>`
|
|
|
|
|
saveSettingsConfigTable.insertAdjacentHTML("beforeend", newrow)
|
|
|
|
|
var checkbox = document.getElementById(checkbox_id)
|
2023-04-27 19:56:56 +02:00
|
|
|
|
checkbox.addEventListener("input", (event) => {
|
2022-10-20 06:12:01 +02:00
|
|
|
|
setting.ignore = !checkbox.checked
|
|
|
|
|
saveSettings()
|
|
|
|
|
})
|
2022-10-17 09:14:05 +02:00
|
|
|
|
})
|
|
|
|
|
})
|
2022-11-18 02:58:09 +01:00
|
|
|
|
prettifyInputs(saveSettingsConfigTable)
|
2022-10-17 09:14:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-29 03:25:54 +02:00
|
|
|
|
// configureSettingsSaveBtn
|
|
|
|
|
|
|
|
|
|
var autoSaveSettings = document.getElementById("auto_save_settings")
|
|
|
|
|
var configSettingsButton = document.createElement("button")
|
|
|
|
|
configSettingsButton.textContent = "Configure"
|
|
|
|
|
configSettingsButton.style.margin = "0px 5px"
|
2022-11-18 02:58:09 +01:00
|
|
|
|
autoSaveSettings.insertAdjacentElement("beforebegin", configSettingsButton)
|
2022-10-29 03:25:54 +02:00
|
|
|
|
autoSaveSettings.addEventListener("change", () => {
|
|
|
|
|
configSettingsButton.style.display = autoSaveSettings.checked ? "block" : "none"
|
|
|
|
|
})
|
2023-04-27 19:56:56 +02:00
|
|
|
|
configSettingsButton.addEventListener("click", () => {
|
2022-10-20 06:12:01 +02:00
|
|
|
|
fillSaveSettingsConfigTable()
|
2022-10-29 01:48:32 +02:00
|
|
|
|
saveSettingsConfigOverlay.classList.add("active")
|
2022-10-20 06:12:01 +02:00
|
|
|
|
})
|
2023-04-27 19:56:56 +02:00
|
|
|
|
resetImageSettingsButton.addEventListener("click", (event) => {
|
|
|
|
|
loadDefaultSettingsSection("editor-settings")
|
2022-10-20 06:12:01 +02:00
|
|
|
|
event.stopPropagation()
|
2022-10-22 02:13:13 +02:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function tryLoadOldSettings() {
|
|
|
|
|
console.log("Loading old user settings")
|
|
|
|
|
// load v1 auto-save.js settings
|
|
|
|
|
var old_map = {
|
2023-04-27 19:56:56 +02:00
|
|
|
|
guidance_scale_slider: "guidance_scale",
|
2023-04-28 12:20:44 +02:00
|
|
|
|
prompt_strength_slider: "prompt_strength",
|
2022-10-22 02:13:13 +02:00
|
|
|
|
}
|
|
|
|
|
var settings_key_v1 = "user_settings"
|
|
|
|
|
var saved_settings_text = localStorage.getItem(settings_key_v1)
|
|
|
|
|
if (saved_settings_text) {
|
|
|
|
|
var saved_settings = JSON.parse(saved_settings_text)
|
2023-04-27 19:56:56 +02:00
|
|
|
|
Object.keys(saved_settings.should_save).forEach((key) => {
|
2022-10-22 02:13:13 +02:00
|
|
|
|
key = key in old_map ? old_map[key] : key
|
2023-02-08 06:48:28 +01:00
|
|
|
|
if (!(key in SETTINGS)) return
|
2022-10-22 02:13:13 +02:00
|
|
|
|
SETTINGS[key].ignore = !saved_settings.should_save[key]
|
2023-04-27 19:56:56 +02:00
|
|
|
|
})
|
|
|
|
|
Object.keys(saved_settings.values).forEach((key) => {
|
2022-10-22 02:13:13 +02:00
|
|
|
|
key = key in old_map ? old_map[key] : key
|
2023-02-08 06:48:28 +01:00
|
|
|
|
if (!(key in SETTINGS)) return
|
2022-10-22 02:13:13 +02:00
|
|
|
|
var setting = SETTINGS[key]
|
|
|
|
|
if (!setting.ignore) {
|
|
|
|
|
setting.value = saved_settings.values[key]
|
|
|
|
|
setSetting(setting.element, setting.value)
|
|
|
|
|
}
|
2023-04-27 19:56:56 +02:00
|
|
|
|
})
|
2022-10-22 02:13:13 +02:00
|
|
|
|
localStorage.removeItem(settings_key_v1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// load old individually stored items
|
2023-04-27 19:56:56 +02:00
|
|
|
|
var individual_settings_map = {
|
|
|
|
|
// maps old localStorage-key to new SETTINGS-key
|
|
|
|
|
soundEnabled: "sound_toggle",
|
|
|
|
|
saveToDisk: "save_to_disk",
|
|
|
|
|
useCPU: "use_cpu",
|
|
|
|
|
diskPath: "diskPath",
|
|
|
|
|
useFaceCorrection: "use_face_correction",
|
|
|
|
|
useUpscaling: "use_upscale",
|
|
|
|
|
showOnlyFilteredImage: "show_only_filtered_image",
|
|
|
|
|
streamImageProgress: "stream_image_progress",
|
|
|
|
|
outputFormat: "output_format",
|
2023-04-28 12:20:44 +02:00
|
|
|
|
autoSaveSettings: "auto_save_settings",
|
2023-04-27 19:56:56 +02:00
|
|
|
|
}
|
|
|
|
|
Object.keys(individual_settings_map).forEach((localStorageKey) => {
|
|
|
|
|
var localStorageValue = localStorage.getItem(localStorageKey)
|
2022-10-22 02:13:13 +02:00
|
|
|
|
if (localStorageValue !== null) {
|
2022-11-16 06:49:10 +01:00
|
|
|
|
let key = individual_settings_map[localStorageKey]
|
|
|
|
|
var setting = SETTINGS[key]
|
|
|
|
|
if (!setting) {
|
2023-04-27 19:56:56 +02:00
|
|
|
|
console.warn(`Attempted to map old setting ${key}, but no setting found`)
|
|
|
|
|
return null
|
2022-11-14 13:39:25 +01:00
|
|
|
|
}
|
2023-04-27 19:56:56 +02:00
|
|
|
|
if (
|
|
|
|
|
setting.element.type == "checkbox" &&
|
|
|
|
|
(typeof localStorageValue === "string" || localStorageValue instanceof String)
|
|
|
|
|
) {
|
2022-10-22 02:13:13 +02:00
|
|
|
|
localStorageValue = localStorageValue == "true"
|
|
|
|
|
}
|
|
|
|
|
setting.value = localStorageValue
|
|
|
|
|
setSetting(setting.element, setting.value)
|
2023-04-27 19:56:56 +02:00
|
|
|
|
localStorage.removeItem(localStorageKey)
|
2022-10-22 02:13:13 +02:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|