From 26b52fd1ecd7397869973d2c0f8563498993e75b Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Sun, 18 Sep 2022 08:48:13 +0300 Subject: [PATCH] script.js split work - hints.js --- javascript/hints.js | 122 ++------------------------------------------ script.js | 92 --------------------------------- 2 files changed, 4 insertions(+), 210 deletions(-) diff --git a/javascript/hints.js b/javascript/hints.js index 65386ccd..3d286654 100644 --- a/javascript/hints.js +++ b/javascript/hints.js @@ -70,19 +70,9 @@ titles = { "Checkpoint name": "Loads weights from checkpoint before making images. You can either use hash or a part of filename (as seen in settings) for checkpoint name. Recommended to use with Y axis for less switching.", } -function gradioApp(){ - return document.getElementsByTagName('gradio-app')[0].shadowRoot; -} -global_progressbar = null - -uiUpdateCallbacks = [] -function onUiUpdate(callback){ - uiUpdateCallbacks.push(callback) -} - -function uiUpdate(root){ - root.querySelectorAll('span, button, select').forEach(function(span){ +onUiUpdate(function(){ + gradioApp().querySelectorAll('span, button, select').forEach(function(span){ tooltip = titles[span.textContent]; if(!tooltip){ @@ -94,115 +84,11 @@ function uiUpdate(root){ } }) - root.querySelectorAll('select').forEach(function(select){ + gradioApp().querySelectorAll('select').forEach(function(select){ if (select.onchange != null) return; select.onchange = function(){ select.title = titles[select.value] || ""; } }) - - progressbar = root.getElementById('progressbar') - if(progressbar!= null && progressbar != global_progressbar){ - global_progressbar = progressbar - - var mutationObserver = new MutationObserver(function(m){ - txt2img_preview = gradioApp().getElementById('txt2img_preview') - txt2img_gallery = gradioApp().getElementById('txt2img_gallery') - - img2img_preview = gradioApp().getElementById('img2img_preview') - img2img_gallery = gradioApp().getElementById('img2img_gallery') - - if(txt2img_preview != null && txt2img_gallery != null){ - txt2img_preview.style.width = txt2img_gallery.clientWidth + "px" - txt2img_preview.style.height = txt2img_gallery.clientHeight + "px" - } - - if(img2img_preview != null && img2img_gallery != null){ - img2img_preview.style.width = img2img_gallery.clientWidth + "px" - img2img_preview.style.height = img2img_gallery.clientHeight + "px" - } - - window.setTimeout(requestProgress, 500) - }); - mutationObserver.observe( progressbar, { childList:true, subtree:true }) - } - - - uiUpdateCallbacks.forEach(function(x){ - x() - }) -} - -document.addEventListener("DOMContentLoaded", function() { - var mutationObserver = new MutationObserver(function(m){ - uiUpdate(gradioApp()); - }); - mutationObserver.observe( gradioApp(), { childList:true, subtree:true }) -}); - -function selected_gallery_index(){ - var gr = gradioApp() - var buttons = gradioApp().querySelectorAll(".gallery-item") - var button = gr.querySelector(".gallery-item.\\!ring-2") - - var result = -1 - buttons.forEach(function(v, i){ if(v==button) { result = i } }) - - return result -} - -function extract_image_from_gallery(gallery){ - if(gallery.length == 1){ - return gallery[0] - } - - index = selected_gallery_index() - - if (index < 0 || index >= gallery.length){ - return [null] - } - - return gallery[index]; -} - -function extract_image_from_gallery_img2img(gallery){ - gradioApp().querySelectorAll('button')[1].click(); - return extract_image_from_gallery(gallery); -} - -function extract_image_from_gallery_extras(gallery){ - gradioApp().querySelectorAll('button')[2].click(); - return extract_image_from_gallery(gallery); -} - -function requestProgress(){ - btn = gradioApp().getElementById("check_progress"); - if(btn==null) return; - - btn.click(); -} - -function submit(){ - window.setTimeout(requestProgress, 500) - - res = [] - for(var i=0;i1 means increasing variety so your sequence will become more and more chaotic.", - - "Interrupt": "Stop processing images and return any results accumulated so far.", - "Save": "Write image to a directory (default - log/images) and generation parameters into csv file.", - - "X values": "Separate values for X axis using commas.", - "Y values": "Separate values for Y axis using commas.", - - "None": "Do not do anything special", - "Prompt matrix": "Separate prompts into parts using vertical pipe character (|) and the script will create a picture for every combination of them (except for the first part, which will be present in all combinations)", - "X/Y plot": "Create a grid where images will have different parameters. Use inputs below to specify which parameters will be shared by columns and rows", - "Custom code": "Run Python code. Advanced user only. Must run program with --allow-code for this to work", - - "Prompt S/R": "Separate a list of words with commas, and the first word will be used as a keyword: script will search for this word in the prompt, and replace it with others", - - "Tiling": "Produce an image that can be tiled.", - "Tile overlap": "For SD upscale, how much overlap in pixels should there be between tiles. Tiles overlap so that when they are merged back into one picture, there is no clearly visible seam.", - - "Roll": "Add a random artist to the prompt.", - - "Variation seed": "Seed of a different picture to be mixed into the generation.", - "Variation strength": "How strong of a variation to produce. At 0, there will be no effect. At 1, you will get the complete picture with variation seed (except for ancestral samplers, where you will just get something).", - "Resize seed from height": "Make an attempt to produce a picture similar to what would have been produced with same seed at specified resolution", - "Resize seed from width": "Make an attempt to produce a picture similar to what would have been produced with same seed at specified resolution", - - "Interrogate": "Reconstruct prompt from existing image and put it into the prompt field.", - - "Images filename pattern": "Use following tags to define how filenames for images are chosen: [steps], [cfg], [prompt], [prompt_spaces], [width], [height], [sampler], [seed], [model_hash], [prompt_words], [date]; leave empty for default.", - "Directory name pattern": "Use following tags to define how subdirectories for images and grids are chosen: [steps], [cfg], [prompt], [prompt_spaces], [width], [height], [sampler], [seed], [model_hash], [prompt_words], [date]; leave empty for default.", - - "Loopback": "Process an image, use it as an input, repeat.", - "Loops": "How many times to repeat processing an image and using it as input for the next iteration", - - - "Style 1": "Style to apply; styles have components for both positive and negative prompts and apply to both", - "Style 2": "Style to apply; styles have components for both positive and negative prompts and apply to both", - "Apply style": "Insert selected styles into prompt fields", - "Create style": "Save current prompts as a style. If you add the token {prompt} to the text, the style use that as placeholder for your prompt when you use the style in the future.", - - "Checkpoint name": "Loads weights from checkpoint before making images. You can either use hash or a part of filename (as seen in settings) for checkpoint name. Recommended to use with Y axis for less switching.", -} - function gradioApp(){ return document.getElementsByTagName('gradio-app')[0].shadowRoot; } @@ -82,26 +10,6 @@ function onUiUpdate(callback){ } function uiUpdate(root){ - root.querySelectorAll('span, button, select').forEach(function(span){ - tooltip = titles[span.textContent]; - - if(!tooltip){ - tooltip = titles[span.value]; - } - - if(tooltip){ - span.title = tooltip; - } - }) - - root.querySelectorAll('select').forEach(function(select){ - if (select.onchange != null) return; - - select.onchange = function(){ - select.title = titles[select.value] || ""; - } - }) - progressbar = root.getElementById('progressbar') if(progressbar!= null && progressbar != global_progressbar){ global_progressbar = progressbar