Update for basic compatibility with sd-webui-v1.5
parent
778876dcd0
commit
6f95dd201a
|
|
@ -19,7 +19,7 @@ function ch_gradio_version(){
|
|||
let versions = foot.querySelector(".versions");
|
||||
if (!versions){return null;}
|
||||
|
||||
if (versions.innerHTML.indexOf("gradio: 3.16.2")>0) {
|
||||
if (versions.textContent.indexOf("gradio: 3.16.2")>0) {
|
||||
return "3.16.2";
|
||||
} else {
|
||||
return "3.23.0";
|
||||
|
|
@ -493,7 +493,9 @@ onUiLoaded(() => {
|
|||
extra_network_id = tab_prefix+"_"+js_model_type+"_"+cardid_suffix;
|
||||
// console.log("searching extra_network_node: " + extra_network_id);
|
||||
extra_network_node = gradioApp().getElementById(extra_network_id);
|
||||
|
||||
// check if extr network is under thumbnail mode
|
||||
// XXX thumbnail mode removed in sd-webui v1.5.0
|
||||
is_thumb_mode = false
|
||||
if (extra_network_node) {
|
||||
if (extra_network_node.className == "extra-network-thumbs") {
|
||||
|
|
@ -519,50 +521,57 @@ onUiLoaded(() => {
|
|||
// replace preview text button
|
||||
replace_preview_btn = card.querySelector(".actions .additional a");
|
||||
|
||||
if (replace_preview_btn==null) {
|
||||
replace_preview_btn = document.createElement("a");
|
||||
}
|
||||
|
||||
// check thumb mode
|
||||
if (is_thumb_mode) {
|
||||
additional_node.style.display = null;
|
||||
|
||||
if (!ul_node) {
|
||||
// nothing to do.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch_show_btn_on_thumb) {
|
||||
ul_node.style.background = btn_thumb_background;
|
||||
} else {
|
||||
//reset
|
||||
ul_node.style.background = null;
|
||||
// console.log("remove existed buttons");
|
||||
// remove existed buttons
|
||||
if (ul_node) {
|
||||
// find all .a child nodes
|
||||
let atags = ul_node.querySelectorAll("a");
|
||||
//reset
|
||||
ul_node.style.background = null;
|
||||
// find all .a child nodes
|
||||
let atags = ul_node.querySelectorAll("a");
|
||||
|
||||
for (let atag of atags) {
|
||||
//reset display
|
||||
for (let atag of atags) {
|
||||
//reset display
|
||||
atag.style.display = null;
|
||||
//remove extension's button
|
||||
if (ch_btn_txts.indexOf(atag.textContent)>=0) {
|
||||
//need to remove
|
||||
ul_node.removeChild(atag);
|
||||
} else {
|
||||
//do not remove, just reset
|
||||
atag.textContent = replace_preview_text;
|
||||
atag.style.display = null;
|
||||
//remove extension's button
|
||||
if (ch_btn_txts.indexOf(atag.innerHTML)>=0) {
|
||||
//need to remove
|
||||
ul_node.removeChild(atag);
|
||||
} else {
|
||||
//do not remove, just reset
|
||||
atag.innerHTML = replace_preview_text;
|
||||
atag.style.display = null;
|
||||
atag.style.fontSize = null;
|
||||
atag.style.position = null;
|
||||
atag.style.backgroundImage = null;
|
||||
}
|
||||
atag.style.fontSize = null;
|
||||
atag.style.position = null;
|
||||
atag.style.backgroundImage = null;
|
||||
}
|
||||
|
||||
//also remove br tag in ul
|
||||
let brtag = ul_node.querySelector("br");
|
||||
if (brtag) {
|
||||
ul_node.removeChild(brtag);
|
||||
}
|
||||
|
||||
}
|
||||
//just reset and remove nodes, do nothing else
|
||||
continue;
|
||||
|
||||
//also remove br tag in ul
|
||||
let brtag = ul_node.querySelector("br");
|
||||
if (brtag) {
|
||||
ul_node.removeChild(brtag);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//just reset and remove nodes, do nothing else
|
||||
continue;
|
||||
|
||||
} else {
|
||||
// full preview mode
|
||||
if (ch_always_display) {
|
||||
|
|
@ -571,19 +580,25 @@ onUiLoaded(() => {
|
|||
additional_node.style.display = null;
|
||||
}
|
||||
|
||||
// remove br tag
|
||||
let brtag = ul_node.querySelector("br");
|
||||
if (brtag) {
|
||||
ul_node.removeChild(brtag);
|
||||
|
||||
if (!ul_node) {
|
||||
ul_node = document.createElement("ul");
|
||||
} else {
|
||||
// remove br tag
|
||||
let brtag = ul_node.querySelector("br");
|
||||
if (brtag) {
|
||||
ul_node.removeChild(brtag);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// change replace preview text button into icon
|
||||
if (replace_preview_btn) {
|
||||
if (replace_preview_btn.innerHTML !== "🖼️") {
|
||||
if (replace_preview_btn.textContent !== "🖼️") {
|
||||
ul_node.appendChild(replace_preview_btn);
|
||||
need_to_add_buttons = true;
|
||||
replace_preview_btn.innerHTML = "🖼️";
|
||||
replace_preview_btn.textContent = "🖼️";
|
||||
if (!is_thumb_mode) {
|
||||
replace_preview_btn.style.fontSize = btn_fontSize;
|
||||
replace_preview_btn.style.margin = btn_margin;
|
||||
|
|
@ -601,7 +616,6 @@ onUiLoaded(() => {
|
|||
continue;
|
||||
}
|
||||
|
||||
|
||||
// search_term node
|
||||
// search_term = subfolder path + model name + ext
|
||||
search_term_node = card.querySelector(".actions .additional .search_term");
|
||||
|
|
@ -611,7 +625,7 @@ onUiLoaded(() => {
|
|||
}
|
||||
|
||||
// get search_term
|
||||
search_term = search_term_node.innerHTML;
|
||||
search_term = search_term_node.textContent;
|
||||
if (!search_term) {
|
||||
console.log("search_term is empty for cards in " + extra_network_id);
|
||||
continue;
|
||||
|
|
@ -626,7 +640,7 @@ onUiLoaded(() => {
|
|||
// then we need to add 3 buttons to each ul node:
|
||||
let open_url_node = document.createElement("a");
|
||||
open_url_node.href = "#";
|
||||
open_url_node.innerHTML = "🌐";
|
||||
open_url_node.textContent = "🌐";
|
||||
if (!is_thumb_mode) {
|
||||
open_url_node.style.fontSize = btn_fontSize;
|
||||
open_url_node.style.margin = btn_margin;
|
||||
|
|
@ -641,7 +655,7 @@ onUiLoaded(() => {
|
|||
|
||||
let add_trigger_words_node = document.createElement("a");
|
||||
add_trigger_words_node.href = "#";
|
||||
add_trigger_words_node.innerHTML = "💡";
|
||||
add_trigger_words_node.textContent = "💡";
|
||||
if (!is_thumb_mode) {
|
||||
add_trigger_words_node.style.fontSize = btn_fontSize;
|
||||
add_trigger_words_node.style.margin = btn_margin;
|
||||
|
|
@ -657,7 +671,7 @@ onUiLoaded(() => {
|
|||
|
||||
let use_preview_prompt_node = document.createElement("a");
|
||||
use_preview_prompt_node.href = "#";
|
||||
use_preview_prompt_node.innerHTML = "🏷️";
|
||||
use_preview_prompt_node.textContent = "🏷️";
|
||||
if (!is_thumb_mode) {
|
||||
use_preview_prompt_node.style.fontSize = btn_fontSize;
|
||||
use_preview_prompt_node.style.margin = btn_margin;
|
||||
|
|
@ -679,8 +693,9 @@ onUiLoaded(() => {
|
|||
ul_node.appendChild(add_trigger_words_node);
|
||||
ul_node.appendChild(use_preview_prompt_node);
|
||||
|
||||
|
||||
|
||||
if (!ul_node.parentElement) {
|
||||
additional_node.appendChild(ul_node);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -713,7 +728,7 @@ onUiLoaded(() => {
|
|||
|
||||
// add refresh button to toolbar
|
||||
let ch_refresh = document.createElement("button");
|
||||
ch_refresh.innerHTML = "🔁";
|
||||
ch_refresh.textContent = "🔁";
|
||||
ch_refresh.title = "Refresh Civitai Helper's additional buttons";
|
||||
ch_refresh.className = "lg secondary gradio-button";
|
||||
ch_refresh.style.fontSize = "200%";
|
||||
|
|
|
|||
|
|
@ -43,8 +43,11 @@ def get_custom_model_folder():
|
|||
if shared.cmd_opts.lora_dir and os.path.isdir(shared.cmd_opts.lora_dir):
|
||||
folders["lora"] = shared.cmd_opts.lora_dir
|
||||
|
||||
if shared.cmd_opts.lyco_dir and os.path.isdir(shared.cmd_opts.lyco_dir):
|
||||
folders["lycoris"] = shared.cmd_opts.lyco_dir
|
||||
try:
|
||||
if shared.cmd_opts.lyco_dir and os.path.isdir(shared.cmd_opts.lyco_dir):
|
||||
folders["lycoris"] = shared.cmd_opts.lyco_dir
|
||||
except:
|
||||
pass # XXX sd-webui v1.5.0 handles the lyco directory differently.
|
||||
|
||||
|
||||
# write model info to file
|
||||
|
|
|
|||
Loading…
Reference in New Issue