clear on the client-side again
This commit is contained in:
parent
25de9df364
commit
401350cd59
|
@ -142,22 +142,33 @@ function selected_tab_id() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear_prompt(_, _prompt_neg, confirmed, _token_counter) {
|
function clear_prompt() {
|
||||||
confirmed = false
|
|
||||||
|
|
||||||
if(confirm("Delete prompt?")) {
|
if(confirm("Delete prompt?")) {
|
||||||
confirmed = true
|
|
||||||
} else {
|
|
||||||
return [_, _prompt_neg, confirmed, _token_counter]
|
|
||||||
}
|
|
||||||
|
|
||||||
if(selected_tab_id() == "tab_txt2img") {
|
let pos_prompt = gradioApp().querySelector("#txt2img_prompt > label > textarea");
|
||||||
update_token_counter("img2img_token_button")
|
let neg_prompt = gradioApp().querySelector("#txt2img_neg_prompt > label > textarea");
|
||||||
|
|
||||||
|
if (selected_tab_id() == "tab_txt2img") {
|
||||||
} else {
|
} else {
|
||||||
update_token_counter("txt2img_token_button")
|
pos_prompt = gradioApp().querySelector("#img2img_prompt > label > textarea");
|
||||||
|
neg_prompt = gradioApp().querySelector("#img2img_neg_prompt > label > textarea");
|
||||||
}
|
}
|
||||||
|
|
||||||
return [_, _prompt_neg, confirmed, _token_counter]
|
pos_prompt.value = ""
|
||||||
|
neg_prompt.value = ""
|
||||||
|
|
||||||
|
//update prompt values on server-side
|
||||||
|
pos_prompt.dispatchEvent(
|
||||||
|
new Event("input", {bubbles: true})
|
||||||
|
)
|
||||||
|
neg_prompt.dispatchEvent(
|
||||||
|
new Event("input", {bubbles: true})
|
||||||
|
)
|
||||||
|
|
||||||
|
return true
|
||||||
|
} else return false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -400,19 +400,12 @@ def create_seed_inputs():
|
||||||
return seed, reuse_seed, subseed, reuse_subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w, seed_checkbox
|
return seed, reuse_seed, subseed, reuse_subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w, seed_checkbox
|
||||||
|
|
||||||
|
|
||||||
def clear_prompt(prompt, _prompt_neg, confirmed, _token_counter):
|
|
||||||
"""Given confirmation from a user on the client-side, go ahead with clearing prompt"""
|
|
||||||
if confirmed:
|
|
||||||
return ["", "", confirmed, update_token_counter("", 1)]
|
|
||||||
else:
|
|
||||||
return [prompt, _prompt_neg, confirmed, _token_counter]
|
|
||||||
|
|
||||||
|
|
||||||
def connect_clear_prompt(button, prompt, prompt_neg, _dummy_confirmed, token_counter):
|
def connect_clear_prompt(button, prompt, prompt_neg, _dummy_confirmed, token_counter):
|
||||||
"""Given clear button, prompt, and token_counter objects, setup clear prompt button click event"""
|
"""Given clear button, prompt, and token_counter objects, setup clear prompt button click event"""
|
||||||
button.click(
|
button.click(
|
||||||
_js="clear_prompt",
|
_js="clear_prompt",
|
||||||
fn=clear_prompt,
|
fn=None,
|
||||||
inputs=[prompt, prompt_neg, _dummy_confirmed, token_counter],
|
inputs=[prompt, prompt_neg, _dummy_confirmed, token_counter],
|
||||||
outputs=[prompt, prompt_neg, _dummy_confirmed, token_counter],
|
outputs=[prompt, prompt_neg, _dummy_confirmed, token_counter],
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user