mirror of
https://github.com/anapnoe/stable-diffusion-webui-ux.git
synced 2026-09-19 09:15:20 +02:00
Merge branch 'dev'
This commit is contained in:
+85
-14
@@ -48,7 +48,7 @@ function extract_image_from_gallery(gallery){
|
||||
return [gallery[0]];
|
||||
}
|
||||
|
||||
index = selected_gallery_index()
|
||||
var index = selected_gallery_index()
|
||||
|
||||
if (index < 0 || index >= gallery.length){
|
||||
// Use the first image in the gallery as the default
|
||||
@@ -59,7 +59,7 @@ function extract_image_from_gallery(gallery){
|
||||
}
|
||||
|
||||
function args_to_array(args){
|
||||
res = []
|
||||
var res = []
|
||||
for(var i=0;i<args.length;i++){
|
||||
res.push(args[i])
|
||||
}
|
||||
@@ -138,7 +138,7 @@ function get_img2img_tab_index() {
|
||||
}
|
||||
|
||||
function create_submit_args(args){
|
||||
res = []
|
||||
var res = []
|
||||
for(var i=0;i<args.length;i++){
|
||||
res.push(args[i])
|
||||
}
|
||||
@@ -159,13 +159,24 @@ function showSubmitButtons(tabname, show){
|
||||
gradioApp().getElementById(tabname+'_skip').style.display = show ? "none" : "block"
|
||||
}
|
||||
|
||||
function showRestoreProgressButton(tabname, show){
|
||||
var button = gradioApp().getElementById(tabname + "_restore_progress")
|
||||
if(! button) return
|
||||
|
||||
button.style.display = show ? "flex" : "none"
|
||||
}
|
||||
|
||||
function submit(){
|
||||
rememberGallerySelection('txt2img_gallery')
|
||||
showSubmitButtons('txt2img', false)
|
||||
|
||||
var id = randomId()
|
||||
localStorage.setItem("txt2img_task_id", id);
|
||||
|
||||
requestProgress(id, gradioApp().getElementById('txt2img_gallery_container'), gradioApp().getElementById('txt2img_gallery'), function(){
|
||||
showSubmitButtons('txt2img', true)
|
||||
localStorage.removeItem("txt2img_task_id")
|
||||
showRestoreProgressButton('txt2img', false)
|
||||
})
|
||||
|
||||
var res = create_submit_args(arguments)
|
||||
@@ -180,8 +191,12 @@ function submit_img2img(){
|
||||
showSubmitButtons('img2img', false)
|
||||
|
||||
var id = randomId()
|
||||
localStorage.setItem("img2img_task_id", id);
|
||||
|
||||
requestProgress(id, gradioApp().getElementById('img2img_gallery_container'), gradioApp().getElementById('img2img_gallery'), function(){
|
||||
showSubmitButtons('img2img', true)
|
||||
localStorage.removeItem("img2img_task_id")
|
||||
showRestoreProgressButton('img2img', false)
|
||||
})
|
||||
|
||||
var res = create_submit_args(arguments)
|
||||
@@ -192,6 +207,42 @@ function submit_img2img(){
|
||||
return res
|
||||
}
|
||||
|
||||
function restoreProgressTxt2img(){
|
||||
showRestoreProgressButton("txt2img", false)
|
||||
var id = localStorage.getItem("txt2img_task_id")
|
||||
|
||||
id = localStorage.getItem("txt2img_task_id")
|
||||
|
||||
if(id) {
|
||||
requestProgress(id, gradioApp().getElementById('txt2img_gallery_container'), gradioApp().getElementById('txt2img_gallery'), function(){
|
||||
showSubmitButtons('txt2img', true)
|
||||
}, null, 0)
|
||||
}
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
function restoreProgressImg2img(){
|
||||
showRestoreProgressButton("img2img", false)
|
||||
|
||||
var id = localStorage.getItem("img2img_task_id")
|
||||
|
||||
if(id) {
|
||||
requestProgress(id, gradioApp().getElementById('img2img_gallery_container'), gradioApp().getElementById('img2img_gallery'), function(){
|
||||
showSubmitButtons('img2img', true)
|
||||
}, null, 0)
|
||||
}
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
|
||||
onUiLoaded(function () {
|
||||
showRestoreProgressButton('txt2img', localStorage.getItem("txt2img_task_id"))
|
||||
showRestoreProgressButton('img2img', localStorage.getItem("img2img_task_id"))
|
||||
});
|
||||
|
||||
|
||||
function modelmerger(){
|
||||
var id = randomId()
|
||||
requestProgress(id, gradioApp().getElementById('modelmerger_results_panel'), null, function(){})
|
||||
@@ -202,7 +253,7 @@ function modelmerger(){
|
||||
}
|
||||
|
||||
function ask_for_style_name(_, prompt_text, negative_prompt_text) {
|
||||
name_ = prompt('Style name:')
|
||||
var name_ = prompt('Style name:')
|
||||
return [name_, prompt_text, negative_prompt_text]
|
||||
}
|
||||
|
||||
@@ -242,12 +293,13 @@ function recalculate_prompts_inpaint(){
|
||||
return args_to_array(arguments);
|
||||
}
|
||||
|
||||
let selectedTabItemId = "tab_txt2img";
|
||||
opts = {}
|
||||
let selectedTabItemId = "tab_txt2img";
|
||||
let opts = {}
|
||||
|
||||
onUiUpdate(function(){
|
||||
if(Object.keys(opts).length != 0) return;
|
||||
|
||||
json_elem = gradioApp().getElementById('settings_json')
|
||||
var json_elem = gradioApp().getElementById('settings_json')
|
||||
if(json_elem == null) return;
|
||||
|
||||
var textarea = json_elem.querySelector('textarea')
|
||||
@@ -297,8 +349,8 @@ onUiUpdate(function(){
|
||||
registerTextarea('img2img_prompt', 'img2img_token_counter', 'img2img_token_button')
|
||||
registerTextarea('img2img_neg_prompt', 'img2img_negative_token_counter', 'img2img_negative_token_button')
|
||||
|
||||
show_all_pages = gradioApp().getElementById('settings_show_all_pages')
|
||||
settings_tabs = gradioApp().querySelector('#settings div')
|
||||
var show_all_pages = gradioApp().getElementById('settings_show_all_pages')
|
||||
var settings_tabs = gradioApp().querySelector('#settings div')
|
||||
if(show_all_pages && settings_tabs){
|
||||
settings_tabs.appendChild(show_all_pages)
|
||||
show_all_pages.onclick = function(){
|
||||
@@ -1037,6 +1089,7 @@ onUiUpdate(function(){
|
||||
let comp_parent = parent.parentElement.parentElement;
|
||||
if( comp_parent.id == "img2img_width" ||
|
||||
comp_parent.id == "img2img_height" ||
|
||||
comp_parent.id == "img2img_scale" ||
|
||||
comp_parent.id.indexOf("--ae-") != -1 ||
|
||||
comp_parent.id.indexOf("theme") != -1 ||
|
||||
comp_parent.className.indexOf("posex") != -1) return;
|
||||
@@ -1477,9 +1530,9 @@ onUiUpdate(function(){
|
||||
})
|
||||
|
||||
onOptionsChanged(function(){
|
||||
elem = gradioApp().getElementById('sd_checkpoint_hash')
|
||||
sd_checkpoint_hash = opts.sd_checkpoint_hash || ""
|
||||
shorthash = sd_checkpoint_hash.substr(0,10)
|
||||
var elem = gradioApp().getElementById('sd_checkpoint_hash')
|
||||
var sd_checkpoint_hash = opts.sd_checkpoint_hash || ""
|
||||
var shorthash = sd_checkpoint_hash.substring(0,10)
|
||||
|
||||
if(elem && elem.textContent != shorthash){
|
||||
elem.textContent = shorthash
|
||||
@@ -1550,12 +1603,28 @@ function updateInput(target){
|
||||
target.dispatchEvent(e);
|
||||
}
|
||||
|
||||
|
||||
var desiredCheckpointName = null;
|
||||
function selectCheckpoint(name){
|
||||
desiredCheckpointName = name;
|
||||
gradioApp().getElementById('change_checkpoint').click()
|
||||
}
|
||||
|
||||
function currentImg2imgSourceResolution(_, _, scaleBy){
|
||||
var img = gradioApp().querySelector('#mode_img2img > div[style="display: block;"] img')
|
||||
return img ? [img.naturalWidth, img.naturalHeight, scaleBy] : [0, 0, scaleBy]
|
||||
}
|
||||
|
||||
function updateImg2imgResizeToTextAfterChangingImage(){
|
||||
// At the time this is called from gradio, the image has no yet been replaced.
|
||||
// There may be a better solution, but this is simple and straightforward so I'm going with it.
|
||||
|
||||
setTimeout(function() {
|
||||
gradioApp().getElementById('img2img_update_resize_to').click()
|
||||
}, 500);
|
||||
|
||||
return []
|
||||
}
|
||||
|
||||
document.addEventListener('readystatechange', function (e) {
|
||||
document.body.style.display = "none";
|
||||
if(localStorage.hasOwnProperty('bg_color')){
|
||||
@@ -1571,4 +1640,6 @@ window.onload = function() {
|
||||
document.body.classList.add("dark");
|
||||
setTimeout(function(){document.body.style.display = "block";},1000)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user