mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Cookie saving of the theme
This commit is contained in:
@@ -556,6 +556,11 @@ function var_changed(data) {
|
|||||||
do_ai_busy(data);
|
do_ai_busy(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//set the selected theme to the cookie value
|
||||||
|
if ((data.classname == "system") && (data.name == "theme_list")) {
|
||||||
|
Change_Theme(getCookie("theme", "Monochrome"));
|
||||||
|
}
|
||||||
|
|
||||||
//Set all options before the next chunk to hidden
|
//Set all options before the next chunk to hidden
|
||||||
if ((data.classname == "actions") && (data.name == "Action Count")) {
|
if ((data.classname == "actions") && (data.name == "Action Count")) {
|
||||||
var option_container = document.getElementById("Select Options");
|
var option_container = document.getElementById("Select Options");
|
||||||
@@ -1615,12 +1620,22 @@ function send_world_info(uid) {
|
|||||||
|
|
||||||
//--------------------------------------------General UI Functions------------------------------------
|
//--------------------------------------------General UI Functions------------------------------------
|
||||||
function Change_Theme(theme) {
|
function Change_Theme(theme) {
|
||||||
//console.log(theme);
|
console.log(theme);
|
||||||
var css = document.getElementById("CSSTheme");
|
var css = document.getElementById("CSSTheme");
|
||||||
css.setAttribute("href", "/themes/"+theme+".css");
|
css.setAttribute("href", "/themes/"+theme+".css");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
create_theming_elements();
|
create_theming_elements();
|
||||||
}, "1000")
|
}, "1000")
|
||||||
|
setCookie("theme", theme);
|
||||||
|
select = document.getElementById("selected_theme");
|
||||||
|
for (element of select.childNodes) {
|
||||||
|
if (element.value == theme) {
|
||||||
|
element.selected = true;
|
||||||
|
console.log(element);
|
||||||
|
} else {
|
||||||
|
element.selected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function palette_color(item) {
|
function palette_color(item) {
|
||||||
@@ -2456,7 +2471,7 @@ function setCookie(cname, cvalue, exdays=60) {
|
|||||||
document.cookie = cname + "=" + cvalue + ";" + expires + ";";
|
document.cookie = cname + "=" + cvalue + ";" + expires + ";";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCookie(cname) {
|
function getCookie(cname, default_return=null) {
|
||||||
let name = cname + "=";
|
let name = cname + "=";
|
||||||
let ca = document.cookie.split(';');
|
let ca = document.cookie.split(';');
|
||||||
for(let i = 0; i < ca.length; i++) {
|
for(let i = 0; i < ca.length; i++) {
|
||||||
@@ -2468,7 +2483,7 @@ function getCookie(cname) {
|
|||||||
return c.substring(name.length, c.length);
|
return c.substring(name.length, c.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return default_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function detect_enter_submit(e) {
|
function detect_enter_submit(e) {
|
||||||
|
@@ -228,7 +228,7 @@
|
|||||||
<h4 style="width:var(--flyout_menu_width);"><span class="material-icons-outlined cursor">expand_more</span> Theme</h4>
|
<h4 style="width:var(--flyout_menu_width);"><span class="material-icons-outlined cursor">expand_more</span> Theme</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting_tile_area" id="Theme">
|
<div class="setting_tile_area" id="Theme">
|
||||||
<select class="var_sync_system_theme_list" autocomplete="off" style="color: black;" onchange="Change_Theme(this.value);">
|
<select id="selected_theme" class="var_sync_system_theme_list" autocomplete="off" style="color: black;" onchange="Change_Theme(this.value);">
|
||||||
</select><span class="material-icons-outlined cursor" title="Refresh List" onclick="socket.emit('theme_list_refresh', '');">autorenew</span>
|
</select><span class="material-icons-outlined cursor" title="Refresh List" onclick="socket.emit('theme_list_refresh', '');">autorenew</span>
|
||||||
<div class="collapsable_header" onclick="toggle_setting_category(this);">
|
<div class="collapsable_header" onclick="toggle_setting_category(this);">
|
||||||
<h4 style="width:var(--flyout_menu_width);"><span class="material-icons-outlined cursor">expand_more</span> Palette</h4>
|
<h4 style="width:var(--flyout_menu_width);"><span class="material-icons-outlined cursor">expand_more</span> Palette</h4>
|
||||||
|
Reference in New Issue
Block a user