diff --git a/homepage/static/assets/js/captcha_refresh.js b/homepage/static/assets/js/captcha_refresh.js index f3bee68..bc5f1d9 100644 --- a/homepage/static/assets/js/captcha_refresh.js +++ b/homepage/static/assets/js/captcha_refresh.js @@ -17,8 +17,8 @@ const captcha_span = document.getElementsByClassName("captcha")[0]; const captcha_img = captcha_span.children[1]; captcha_span.classList.toggle("refresh"); -captcha_span.children[3].innerHTML - = `ed in 600 seconds.`; +captcha_span.children[3].innerHTML = + `ed in 600 seconds.`; const captcha_refresh = document.getElementById("refresh"); const captcha_remain = document.getElementById("remain"); @@ -27,13 +27,15 @@ captcha_refresh.classList.toggle("refresh"); captcha_refresh.addEventListener("click", async e => { e.preventDefault(); captcha_refresh.disabled = true; - // Checking if CAPTCHA is solved deletes it. setTimeout(async () => { captcha_refresh.disabled = false; await fetch(`/captcha/${g_current_captcha_id}`); }, 3000); await getNewCaptcha(); }); +// Remove unused CAPTCHA on a server. +window.addEventListener("unload", () => fetch(`/captcha/${g_current_captcha_id}`)); + setInterval(async () => { captcha_remain.innerText = --g_captcha_timeout_remain; if (g_captcha_timeout_remain == 0)