X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=index.html;h=d055878d9cf0339d9bcf62bf55489a59314e4e9a;hb=700362e55b2b60329b4d4cdd138865203093e720;hp=f88dd5bf6d15a320fec0cb3daa78773863a62d85;hpb=a9defcc96216fce985226931b87cbe81c14d7089;p=zombocom-ai diff --git a/index.html b/index.html index f88dd5b..d055878 100644 --- a/index.html +++ b/index.html @@ -115,6 +115,7 @@ mute.addEventListener("click", () => { const safety= document.querySelector("#safety"); const spinner = document.querySelector("#spinner"); + var spinner_timeout; comment_form.addEventListener('submit', function(e) { e.preventDefault(); @@ -142,19 +143,25 @@ mute.addEventListener("click", () => { images.prepend(figure); }); + function hide_spinner() { + zombo_form.style.display = "grid"; + spinner.style.display = "none"; + } + zombo_form.addEventListener('submit', function(e) { e.preventDefault(); /* Hide the form and show spinner while generation is happening. */ zombo_form.style.display = "none"; spinner.style.display = "block"; + spinner_timeout = setTimeout(hide_spinner, 60000); socket.emit('generate', {"prompt": prompt.value, "code": code.value}); prompt.value = ''; }); socket.on('generation-done', () => { /* Re-display the form and hide spinner now that generation is over. */ - zombo_form.style.display = "grid"; - spinner.style.display = "none"; + cancelTimeout(spinner_timeout); + hide_spinner(); }); // TODO: Dynamically generate many different prompts here