add: ability to mute phrases
add: ability to disable gpa experiment
This commit is contained in:
parent
9d839a1a63
commit
f034cc4f27
7 changed files with 212 additions and 63 deletions
|
@ -856,27 +856,29 @@ media_theme_pref();
|
|||
}
|
||||
});
|
||||
|
||||
self.define("render_settings_ui_field", (_, into_element, option) => {
|
||||
if (option.input_element_type === "divider") {
|
||||
into_element.innerHTML += `<hr class="margin" />`;
|
||||
return;
|
||||
}
|
||||
self.define(
|
||||
"render_settings_ui_field",
|
||||
(_, into_element, option, id_key) => {
|
||||
if (option.input_element_type === "divider") {
|
||||
into_element.innerHTML += `<hr class="margin" />`;
|
||||
return;
|
||||
}
|
||||
|
||||
if (option.input_element_type === "title") {
|
||||
into_element.innerHTML += `<hr class="margin" /><b>${option.value}</b>`;
|
||||
return;
|
||||
}
|
||||
if (option.input_element_type === "title") {
|
||||
into_element.innerHTML += `<hr class="margin" /><b>${option.value}</b>`;
|
||||
return;
|
||||
}
|
||||
|
||||
if (option.input_element_type === "text") {
|
||||
into_element.innerHTML += `<p>${option.value}</p>`;
|
||||
return;
|
||||
}
|
||||
if (option.input_element_type === "text") {
|
||||
into_element.innerHTML += `<p>${option.value}</p>`;
|
||||
return;
|
||||
}
|
||||
|
||||
if (option.input_element_type === "checkbox") {
|
||||
into_element.innerHTML += `<div class="card flex gap-2">
|
||||
if (option.input_element_type === "checkbox") {
|
||||
into_element.innerHTML += `<div class="card flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
onchange="window.set_setting_field('${option.key}', event.target.checked)"
|
||||
onchange="window.set_setting_field${id_key}('${option.key}', event.target.checked)"
|
||||
placeholder="${option.key}"
|
||||
name="${option.key}"
|
||||
id="${option.key}"
|
||||
|
@ -887,11 +889,11 @@ media_theme_pref();
|
|||
<label for="${option.key}"><b>${option.label.replaceAll("_", " ")}</b></label>
|
||||
</div>`;
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (option.input_element_type === "color") {
|
||||
into_element.innerHTML += `<div class="flex flex-col gap-2">
|
||||
if (option.input_element_type === "color") {
|
||||
into_element.innerHTML += `<div class="flex flex-col gap-2">
|
||||
<label for="${option.key}"><b>${option.label.replaceAll("_", " ")}</b></label>
|
||||
|
||||
<div class="card flex flex-row gap-2">
|
||||
|
@ -905,7 +907,7 @@ media_theme_pref();
|
|||
|
||||
<input
|
||||
type="text"
|
||||
onchange="window.set_setting_field('${option.key}', event.target.value); window.update_color_field('${option.key}', event.target.value)"
|
||||
onchange="window.set_setting_field${id_key}('${option.key}', event.target.value); window.update_color_field('${option.key}', event.target.value)"
|
||||
placeholder="${option.key}"
|
||||
name="${option.key}"
|
||||
id="${option.key}"
|
||||
|
@ -918,10 +920,10 @@ media_theme_pref();
|
|||
<span class="fade">${(option.attributes || { description: "" }).description}</span>
|
||||
</div>`;
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
into_element.innerHTML += `<div class="card-nest">
|
||||
into_element.innerHTML += `<div class="card-nest">
|
||||
<div class="card small">
|
||||
<label for="${option.key}"><b>${option.label.replaceAll("_", " ")}</b></label>
|
||||
</div>
|
||||
|
@ -929,7 +931,7 @@ media_theme_pref();
|
|||
<div class="card flex flex-col gap-2">
|
||||
<${option.input_element_type || "input"}
|
||||
type="text"
|
||||
onchange="window.set_setting_field('${option.key}', event.target.value)"
|
||||
onchange="window.set_setting_field${id_key}('${option.key}', event.target.value)"
|
||||
placeholder="${option.key}"
|
||||
name="${option.key}"
|
||||
id="${option.key}"
|
||||
|
@ -939,26 +941,37 @@ ${option.input_element_type === "textarea" ? `${option.value}</textarea>` : ""}
|
|||
${(option.attributes || { embed_html: "" }).embed_html}
|
||||
</div>
|
||||
</div>`;
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
self.define(
|
||||
"generate_settings_ui",
|
||||
({ $ }, into_element, options, settings_ref, key_map = {}) => {
|
||||
const id_key = `a${crypto.randomUUID().replaceAll("-", "")}`;
|
||||
for (const option of options) {
|
||||
$.render_settings_ui_field(into_element, {
|
||||
key: Array.isArray(option[0]) ? option[0][0] : option[0],
|
||||
label: Array.isArray(option[0]) ? option[0][1] : option[0],
|
||||
value: option[1],
|
||||
input_element_type: option[2],
|
||||
attributes: option[3],
|
||||
});
|
||||
$.render_settings_ui_field(
|
||||
into_element,
|
||||
{
|
||||
key: Array.isArray(option[0])
|
||||
? option[0][0]
|
||||
: option[0],
|
||||
label: Array.isArray(option[0])
|
||||
? option[0][1]
|
||||
: option[0],
|
||||
value: option[1],
|
||||
input_element_type: option[2],
|
||||
attributes: option[3],
|
||||
},
|
||||
id_key,
|
||||
);
|
||||
}
|
||||
|
||||
window.set_setting_field = (key, value) => {
|
||||
window[`set_setting_field${id_key}`] = (key, value) => {
|
||||
if (settings_ref && !key_map[key]) {
|
||||
settings_ref[key] = value;
|
||||
} else {
|
||||
key_map[key](value);
|
||||
console.log("custom_update", key);
|
||||
}
|
||||
|
||||
console.log("update", key);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue