Add ability to recreate variations via image click

This commit is contained in:
Web Dev 9000 2022-09-04 17:50:13 -07:00 committed by GitHub
parent c012929cda
commit ff2c4b9a1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,10 +19,24 @@ function appendOutput(src, seed, config) {
outputNode.addEventListener('click', () => { outputNode.addEventListener('click', () => {
let form = document.querySelector("#generate-form"); let form = document.querySelector("#generate-form");
for (const [k, v] of new FormData(form)) { for (const [k, v] of new FormData(form)) {
if (k == 'initimg') { continue; } form.querySelector(`*[name=${k}]`).value = config[k];
form.querySelector(`*[name=${k}]`).value = config[k]; }
if (config.variation_amount > 0 || config.with_variations != '') {
document.querySelector("#seed").value = config.seed;
} else {
document.querySelector("#seed").value = seed;
}
if (config.variation_amount > 0) {
let oldVarAmt = document.querySelector("#variation_amount").value
let oldVariations = document.querySelector("#with_variations").value
let varSep = ''
document.querySelector("#variation_amount").value = 0;
if (document.querySelector("#with_variations").value != '') {
varSep = ","
}
document.querySelector("#with_variations").value = oldVariations + varSep + seed + ':' + config.variation_amount
} }
document.querySelector("#seed").value = seed;
saveFields(document.querySelector("#generate-form")); saveFields(document.querySelector("#generate-form"));
}); });
@ -60,7 +74,6 @@ async function generateSubmit(form) {
// Convert file data to base64 // Convert file data to base64
let formData = Object.fromEntries(new FormData(form)); let formData = Object.fromEntries(new FormData(form));
formData.initimg_name = formData.initimg.name
formData.initimg = formData.initimg.name !== '' ? await toBase64(formData.initimg) : null; formData.initimg = formData.initimg.name !== '' ? await toBase64(formData.initimg) : null;
let strength = formData.strength; let strength = formData.strength;