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

@ -61,7 +61,7 @@
<input type="file" id="initimg" name="initimg" accept=".jpg, .jpeg, .png">
<label title="Set to -1 for random seed" for="seed">Seed:</label>
<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>
<button type="button" id="reset-all">Reset to Defaults</button>
<br>

View File

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