mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-04-15 15:08:27 +02:00
formatting
This commit is contained in:
parent
fe6991c703
commit
0139111d49
@ -1346,7 +1346,8 @@ function getPromptsNumber(prompts) {
|
|||||||
|
|
||||||
let promptsToMake = []
|
let promptsToMake = []
|
||||||
let numberOfPrompts = 0
|
let numberOfPrompts = 0
|
||||||
if (prompts.trim() !== "") { // this needs to stay sort of the same, as the prompts have to be passed through to the other functions
|
if (prompts.trim() !== "") {
|
||||||
|
// this needs to stay sort of the same, as the prompts have to be passed through to the other functions
|
||||||
prompts = prompts.split("\n")
|
prompts = prompts.split("\n")
|
||||||
prompts = prompts.map((prompt) => prompt.trim())
|
prompts = prompts.map((prompt) => prompt.trim())
|
||||||
prompts = prompts.filter((prompt) => prompt !== "")
|
prompts = prompts.filter((prompt) => prompt !== "")
|
||||||
@ -1354,7 +1355,11 @@ function getPromptsNumber(prompts) {
|
|||||||
// estimate number of prompts
|
// estimate number of prompts
|
||||||
let estimatedNumberOfPrompts = 0
|
let estimatedNumberOfPrompts = 0
|
||||||
prompts.forEach((prompt) => {
|
prompts.forEach((prompt) => {
|
||||||
estimatedNumberOfPrompts += (prompt.match(/{[^}]*}/g) || []).map((e) => (e.match(/,/g) || []).length + 1).reduce( (p,a) => p*a, 1) * (2**(prompt.match(/\|/g) || []).length)
|
estimatedNumberOfPrompts +=
|
||||||
|
(prompt.match(/{[^}]*}/g) || [])
|
||||||
|
.map((e) => (e.match(/,/g) || []).length + 1)
|
||||||
|
.reduce((p, a) => p * a, 1) *
|
||||||
|
2 ** (prompt.match(/\|/g) || []).length
|
||||||
})
|
})
|
||||||
|
|
||||||
if (estimatedNumberOfPrompts >= 10000) {
|
if (estimatedNumberOfPrompts >= 10000) {
|
||||||
@ -1394,7 +1399,8 @@ function applySetOperator(prompts) {
|
|||||||
return promptsToMake
|
return promptsToMake
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyPermuteOperator(prompts) { // prompts is array of input, trimmed, filtered and split by \n
|
function applyPermuteOperator(prompts) {
|
||||||
|
// prompts is array of input, trimmed, filtered and split by \n
|
||||||
let promptsToMake = []
|
let promptsToMake = []
|
||||||
prompts.forEach((prompt) => {
|
prompts.forEach((prompt) => {
|
||||||
let promptMatrix = prompt.split("|")
|
let promptMatrix = prompt.split("|")
|
||||||
@ -1414,13 +1420,14 @@ function applyPermuteOperator(prompts) { // prompts is array of input, trimmed,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// returns how many prompts would have to be made with the given prompts
|
// returns how many prompts would have to be made with the given prompts
|
||||||
function applyPermuteOperatorNumber(prompts) { // prompts is array of input, trimmed, filtered and split by \n
|
function applyPermuteOperatorNumber(prompts) {
|
||||||
|
// prompts is array of input, trimmed, filtered and split by \n
|
||||||
let numberOfPrompts = 0
|
let numberOfPrompts = 0
|
||||||
prompts.forEach((prompt) => {
|
prompts.forEach((prompt) => {
|
||||||
let promptCounter = 1
|
let promptCounter = 1
|
||||||
let promptMatrix = prompt.split("|")
|
let promptMatrix = prompt.split("|")
|
||||||
promptMatrix.shift()
|
promptMatrix.shift()
|
||||||
|
|
||||||
promptMatrix = promptMatrix.map((p) => p.trim())
|
promptMatrix = promptMatrix.map((p) => p.trim())
|
||||||
promptMatrix = promptMatrix.filter((p) => p !== "")
|
promptMatrix = promptMatrix.filter((p) => p !== "")
|
||||||
|
|
||||||
@ -1510,8 +1517,12 @@ clearAllPreviewsBtn.addEventListener("click", (e) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
/* Download images popup */
|
/* Download images popup */
|
||||||
showDownloadDialogBtn.addEventListener("click", (e) => { saveAllImagesDialog.showModal() })
|
showDownloadDialogBtn.addEventListener("click", (e) => {
|
||||||
saveAllImagesCloseBtn.addEventListener("click", (e) => { saveAllImagesDialog.close() })
|
saveAllImagesDialog.showModal()
|
||||||
|
})
|
||||||
|
saveAllImagesCloseBtn.addEventListener("click", (e) => {
|
||||||
|
saveAllImagesDialog.close()
|
||||||
|
})
|
||||||
modalDialogCloseOnBackdropClick(saveAllImagesDialog)
|
modalDialogCloseOnBackdropClick(saveAllImagesDialog)
|
||||||
makeDialogDraggable(saveAllImagesDialog)
|
makeDialogDraggable(saveAllImagesDialog)
|
||||||
|
|
||||||
@ -1629,15 +1640,11 @@ function renameMakeImageButton() {
|
|||||||
imageLabel = totalImages + " Images"
|
imageLabel = totalImages + " Images"
|
||||||
}
|
}
|
||||||
if (SD.activeTasks.size == 0) {
|
if (SD.activeTasks.size == 0) {
|
||||||
if (totalImages >= 10000)
|
if (totalImages >= 10000) makeImageBtn.innerText = "Make 10000+ images"
|
||||||
makeImageBtn.innerText = "Make 10000+ images"
|
else makeImageBtn.innerText = "Make " + imageLabel
|
||||||
else
|
|
||||||
makeImageBtn.innerText = "Make " + imageLabel
|
|
||||||
} else {
|
} else {
|
||||||
if (totalImages >= 10000)
|
if (totalImages >= 10000) makeImageBtn.innerText = "Enqueue 10000+ images"
|
||||||
makeImageBtn.innerText = "Enqueue 10000+ images"
|
else makeImageBtn.innerText = "Enqueue Next " + imageLabel
|
||||||
else
|
|
||||||
makeImageBtn.innerText = "Enqueue Next " + imageLabel
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
numOutputsTotalField.addEventListener("change", renameMakeImageButton)
|
numOutputsTotalField.addEventListener("change", renameMakeImageButton)
|
||||||
@ -2073,9 +2080,8 @@ function resumeClient() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function splashScreen(force = false) {
|
function splashScreen(force = false) {
|
||||||
const splashVersion = splashScreenPopup.dataset['version']
|
const splashVersion = splashScreenPopup.dataset["version"]
|
||||||
const lastSplash = localStorage.getItem("lastSplashScreenVersion") || 0
|
const lastSplash = localStorage.getItem("lastSplashScreenVersion") || 0
|
||||||
if (testDiffusers.checked) {
|
if (testDiffusers.checked) {
|
||||||
if (force || lastSplash < splashVersion) {
|
if (force || lastSplash < splashVersion) {
|
||||||
@ -2085,8 +2091,9 @@ function splashScreen(force = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.getElementById("logo_img").addEventListener("click", (e) => {
|
||||||
document.getElementById("logo_img").addEventListener("click", (e) => { splashScreen(true) })
|
splashScreen(true)
|
||||||
|
})
|
||||||
|
|
||||||
promptField.addEventListener("input", debounce(renameMakeImageButton, 1000))
|
promptField.addEventListener("input", debounce(renameMakeImageButton, 1000))
|
||||||
|
|
||||||
@ -2139,21 +2146,21 @@ document.getElementById("toggle-cloudflare-tunnel").addEventListener("click", as
|
|||||||
|
|
||||||
/* Embeddings */
|
/* Embeddings */
|
||||||
|
|
||||||
function updateEmbeddingsList(filter="") {
|
function updateEmbeddingsList(filter = "") {
|
||||||
function html(model, prefix="", filter="") {
|
function html(model, prefix = "", filter = "") {
|
||||||
filter = filter.toLowerCase()
|
filter = filter.toLowerCase()
|
||||||
let toplevel=""
|
let toplevel = ""
|
||||||
let folders=""
|
let folders = ""
|
||||||
|
|
||||||
model?.forEach( m => {
|
model?.forEach((m) => {
|
||||||
if (typeof(m) == "string") {
|
if (typeof m == "string") {
|
||||||
if (m.toLowerCase().search(filter)!=-1) {
|
if (m.toLowerCase().search(filter) != -1) {
|
||||||
toplevel += `<button data-embedding="${m}">${m}</button> `
|
toplevel += `<button data-embedding="${m}">${m}</button> `
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let subdir = html(m[1], prefix+m[0]+"/", filter)
|
let subdir = html(m[1], prefix + m[0] + "/", filter)
|
||||||
if (subdir != "") {
|
if (subdir != "") {
|
||||||
folders += `<h4>${prefix}${m[0]}</h4>` + subdir
|
folders += `<h4>${prefix}${m[0]}</h4>` + subdir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -2171,7 +2178,7 @@ function updateEmbeddingsList(filter="") {
|
|||||||
insertAtCursor(promptField, text)
|
insertAtCursor(promptField, text)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let pad=""
|
let pad = ""
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
if (!negativePromptField.value.endsWith(" ")) {
|
if (!negativePromptField.value.endsWith(" ")) {
|
||||||
pad = " "
|
pad = " "
|
||||||
@ -2197,13 +2204,15 @@ function updateEmbeddingsList(filter="") {
|
|||||||
// END of remove block
|
// END of remove block
|
||||||
|
|
||||||
embeddingsList.innerHTML = warning + html(modelsOptions.embeddings, "", filter)
|
embeddingsList.innerHTML = warning + html(modelsOptions.embeddings, "", filter)
|
||||||
embeddingsList.querySelectorAll("button").forEach( (b) => { b.addEventListener("click", onButtonClick)})
|
embeddingsList.querySelectorAll("button").forEach((b) => {
|
||||||
|
b.addEventListener("click", onButtonClick)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
embeddingsButton.addEventListener("click", () => {
|
embeddingsButton.addEventListener("click", () => {
|
||||||
updateEmbeddingsList()
|
updateEmbeddingsList()
|
||||||
embeddingsSearchBox.value=""
|
embeddingsSearchBox.value = ""
|
||||||
embeddingsDialog.showModal()
|
embeddingsDialog.showModal()
|
||||||
})
|
})
|
||||||
embeddingsDialogCloseBtn.addEventListener("click", (e) => {
|
embeddingsDialogCloseBtn.addEventListener("click", (e) => {
|
||||||
embeddingsDialog.close()
|
embeddingsDialog.close()
|
||||||
@ -2215,7 +2224,6 @@ embeddingsSearchBox.addEventListener("input", (e) => {
|
|||||||
modalDialogCloseOnBackdropClick(embeddingsDialog)
|
modalDialogCloseOnBackdropClick(embeddingsDialog)
|
||||||
makeDialogDraggable(embeddingsDialog)
|
makeDialogDraggable(embeddingsDialog)
|
||||||
|
|
||||||
|
|
||||||
if (testDiffusers.checked) {
|
if (testDiffusers.checked) {
|
||||||
document.getElementById("embeddings-container").classList.remove("displayNone")
|
document.getElementById("embeddings-container").classList.remove("displayNone")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user