aboutsummaryrefslogtreecommitdiff
path: root/javascript
diff options
context:
space:
mode:
authorInvincibleDude <81354513+InvincibleDude@users.noreply.github.com>2023-01-29 14:36:10 +0300
committerGitHub <noreply@github.com>2023-01-29 14:36:10 +0300
commitee3d63b6beb88e63542976a1095d4c8aa97388bd (patch)
treecf891130682c343107ae0a0f8cec309aea16807a /javascript
parent44c0e6b993d00bb2f441f0fde409bcb79136f034 (diff)
parent00dab8f10defbbda579a1bc89c8d4e972c58a20d (diff)
Merge branch 'master' into master
Diffstat (limited to 'javascript')
-rw-r--r--javascript/extensions.js20
-rw-r--r--javascript/extraNetworks.js42
-rw-r--r--javascript/hints.js2
-rw-r--r--javascript/ui.js7
4 files changed, 65 insertions, 6 deletions
diff --git a/javascript/extensions.js b/javascript/extensions.js
index ac6e35b9..c593cd2e 100644
--- a/javascript/extensions.js
+++ b/javascript/extensions.js
@@ -1,7 +1,8 @@
function extensions_apply(_, _){
- disable = []
- update = []
+ var disable = []
+ var update = []
+
gradioApp().querySelectorAll('#extensions input[type="checkbox"]').forEach(function(x){
if(x.name.startsWith("enable_") && ! x.checked)
disable.push(x.name.substr(7))
@@ -16,11 +17,24 @@ function extensions_apply(_, _){
}
function extensions_check(){
+ var disable = []
+
+ gradioApp().querySelectorAll('#extensions input[type="checkbox"]').forEach(function(x){
+ if(x.name.startsWith("enable_") && ! x.checked)
+ disable.push(x.name.substr(7))
+ })
+
gradioApp().querySelectorAll('#extensions .extension_status').forEach(function(x){
x.innerHTML = "Loading..."
})
- return []
+
+ var id = randomId()
+ requestProgress(id, gradioApp().getElementById('extensions_installed_top'), null, function(){
+
+ })
+
+ return [id, JSON.stringify(disable)]
}
function install_extension_from_index(button, url){
diff --git a/javascript/extraNetworks.js b/javascript/extraNetworks.js
index c5a9adb3..17bf2000 100644
--- a/javascript/extraNetworks.js
+++ b/javascript/extraNetworks.js
@@ -16,7 +16,7 @@ function setupExtraNetworksForTab(tabname){
searchTerm = search.value.toLowerCase()
gradioApp().querySelectorAll('#'+tabname+'_extra_tabs div.card').forEach(function(elem){
- text = elem.querySelector('.name').textContent.toLowerCase()
+ text = elem.querySelector('.name').textContent.toLowerCase() + " " + elem.querySelector('.search_term').textContent.toLowerCase()
elem.style.display = text.indexOf(searchTerm) == -1 ? "none" : ""
})
});
@@ -48,10 +48,39 @@ function setupExtraNetworks(){
onUiLoaded(setupExtraNetworks)
+var re_extranet = /<([^:]+:[^:]+):[\d\.]+>/;
+var re_extranet_g = /\s+<([^:]+:[^:]+):[\d\.]+>/g;
+
+function tryToRemoveExtraNetworkFromPrompt(textarea, text){
+ var m = text.match(re_extranet)
+ if(! m) return false
+
+ var partToSearch = m[1]
+ var replaced = false
+ var newTextareaText = textarea.value.replaceAll(re_extranet_g, function(found, index){
+ m = found.match(re_extranet);
+ if(m[1] == partToSearch){
+ replaced = true;
+ return ""
+ }
+ return found;
+ })
+
+ if(replaced){
+ textarea.value = newTextareaText
+ return true;
+ }
+
+ return false
+}
+
function cardClicked(tabname, textToAdd, allowNegativePrompt){
var textarea = allowNegativePrompt ? activePromptTextarea[tabname] : gradioApp().querySelector("#" + tabname + "_prompt > label > textarea")
- textarea.value = textarea.value + " " + textToAdd
+ if(! tryToRemoveExtraNetworkFromPrompt(textarea, textToAdd)){
+ textarea.value = textarea.value + " " + textToAdd
+ }
+
updateInput(textarea)
}
@@ -67,3 +96,12 @@ function saveCardPreview(event, tabname, filename){
event.stopPropagation()
event.preventDefault()
}
+
+function extraNetworksSearchButton(tabs_id, event){
+ searchTextarea = gradioApp().querySelector("#" + tabs_id + ' > div > textarea')
+ button = event.target
+ text = button.classList.contains("search-all") ? "" : button.textContent.trim()
+
+ searchTextarea.value = text
+ updateInput(searchTextarea)
+} \ No newline at end of file
diff --git a/javascript/hints.js b/javascript/hints.js
index 3cf10e20..7b60b25e 100644
--- a/javascript/hints.js
+++ b/javascript/hints.js
@@ -50,7 +50,7 @@ titles = {
"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",
+ "X/Y/Z plot": "Create grid(s) 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",
diff --git a/javascript/ui.js b/javascript/ui.js
index ba72623c..dd40e62d 100644
--- a/javascript/ui.js
+++ b/javascript/ui.js
@@ -309,3 +309,10 @@ function updateInput(target){
Object.defineProperty(e, "target", {value: target})
target.dispatchEvent(e);
}
+
+
+var desiredCheckpointName = null;
+function selectCheckpoint(name){
+ desiredCheckpointName = name;
+ gradioApp().getElementById('change_checkpoint').click()
+}