Merge pull request #186 from lstein/reset-properly

Fix form reset logic
This commit is contained in:
Lincoln Stein 2022-08-29 13:03:30 -04:00 committed by GitHub
commit 132d23e55d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 292 additions and 290 deletions

View File

@ -26,14 +26,14 @@
<label for="sampler">Sampler:</label> <label for="sampler">Sampler:</label>
<select id="sampler" name="sampler" value="k_lms"> <select id="sampler" name="sampler" value="k_lms">
<option value="ddim">DDIM</option> <option value="ddim">DDIM</option>
<option value="plms">PLMS</option> <option value="plms">PLMS</option>
<option value="k_lms" selected>KLMS</option> <option value="k_lms" selected>KLMS</option>
<option value="k_dpm_2">KDPM_2</option> <option value="k_dpm_2">KDPM_2</option>
<option value="k_dpm_2_a">KDPM_2A</option> <option value="k_dpm_2_a">KDPM_2A</option>
<option value="k_euler">KEULER</option> <option value="k_euler">KEULER</option>
<option value="k_heun">KHEUN</option> <option value="k_heun">KHEUN</option>
</select> </select>
<br> <br>
<label title="Set to multiple of 64" for="width">Width:</label> <label title="Set to multiple of 64" for="width">Width:</label>
<select id="width" name="width" value="512"> <select id="width" name="width" value="512">
<option value="64">64</option> <option value="128">128</option> <option value="64">64</option> <option value="128">128</option>
@ -61,19 +61,19 @@
<input type="file" id="initimg" name="initimg" accept=".jpg, .jpeg, .png"> <input type="file" id="initimg" name="initimg" accept=".jpg, .jpeg, .png">
<label title="Set to -1 for random seed" for="seed">Seed:</label> <label title="Set to -1 for random seed" for="seed">Seed:</label>
<input value="-1" type="number" id="seed" name="seed"> <input value="-1" type="number" id="seed" name="seed">
<button type="button" id="reset">&olarr;</button> <button type="button" id="reset-seed">&olarr;</button>
<span>&bull;</span> <span>&bull;</span>
<button type="button" id="reset-all">Reset to Defaults</button> <button type="button" id="reset-all">Reset to Defaults</button>
<br> <br>
<p><em>The options below require the GFPGAN and ESRGAN packages to be installed</em></p> <p><em>The options below require the GFPGAN and ESRGAN packages to be installed</em></p>
<label title="Strength of the gfpgan (face fixing) algorithm." for="gfpgan_strength">GPFGAN Strength:</label> <label title="Strength of the gfpgan (face fixing) algorithm." for="gfpgan_strength">GPFGAN Strength:</label>
<input value="0.8" min="0" max="1" type="number" id="gfpgan_strength" name="gfpgan_strength" step="0.05"> <input value="0.8" min="0" max="1" type="number" id="gfpgan_strength" name="gfpgan_strength" step="0.05">
<label title="Upscaling to perform using ESRGAN." for="upscale_level">Upscaling Level</label> <label title="Upscaling to perform using ESRGAN." for="upscale_level">Upscaling Level</label>
<select id="upscale_level" name="upscale_level" value=""> <select id="upscale_level" name="upscale_level" value="">
<option value="" selected></option> <option value="" selected></option>
<option value="2">2x</option> <option value="2">2x</option>
<option value="4">4x</option> <option value="4">4x</option>
</select> </select>
<label title="Strength of the esrgan (upscaling) algorithm." for="upscale_strength">Upscale Strength:</label> <label title="Strength of the esrgan (upscaling) algorithm." for="upscale_strength">Upscale Strength:</label>
<input value="0.75" min="0" max="1" type="number" id="upscale_strength" name="upscale_strength" step="0.05"> <input value="0.75" min="0" max="1" type="number" id="upscale_strength" name="upscale_strength" step="0.05">
</fieldset> </fieldset>

View File

@ -47,8 +47,10 @@ function loadFields(form) {
} }
function clearFields(form) { function clearFields(form) {
localStorage.clear() localStorage.clear();
location.reload() let prompt = form.prompt.value;
form.reset();
form.prompt.value = prompt;
} }
async function generateSubmit(form) { async function generateSubmit(form) {
@ -116,7 +118,7 @@ window.onload = () => {
document.querySelector("#generate-form").addEventListener('change', (e) => { document.querySelector("#generate-form").addEventListener('change', (e) => {
saveFields(e.target.form); saveFields(e.target.form);
}); });
document.querySelector("#reset").addEventListener('click', (e) => { document.querySelector("#reset-seed").addEventListener('click', (e) => {
document.querySelector("#seed").value = -1; document.querySelector("#seed").value = -1;
saveFields(e.target.form); saveFields(e.target.form);
}); });