Upload descToPromptsHelper.js
Browse files
javascript/descToPromptsHelper.js
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function setupDTPEvent(){
|
2 |
+
onClickDescEvent("txt2img")
|
3 |
+
onClickDescEvent("img2img")
|
4 |
+
}
|
5 |
+
|
6 |
+
function onClickDescEvent(tab){
|
7 |
+
gradioApp().querySelector("div[id='" + tab + "_extra_networks']").addEventListener("click", function(e){
|
8 |
+
elem = (e.target.parentElement?.className == "card" ? e.target.parentElement : (e.target.parentElement?.parentElement?.parentElement?.className == "card" ? e.target.parentElement.parentElement.parentElement : null))
|
9 |
+
if (!elem) {
|
10 |
+
return
|
11 |
+
}
|
12 |
+
|
13 |
+
textarea = gradioApp().querySelector("#" + tab + "_prompt > label > textarea")
|
14 |
+
description = elem.querySelector(".actions > .description").textContent
|
15 |
+
if (description == ''){
|
16 |
+
return
|
17 |
+
}
|
18 |
+
|
19 |
+
textarea.value = textarea.value + opts.extra_networks_add_text_separator + description
|
20 |
+
updateInput(textarea)
|
21 |
+
})
|
22 |
+
}
|
23 |
+
|
24 |
+
onUiLoaded(setupDTPEvent)
|