From 0c824b5af7c03d28a05336d35fc40e284c250d99 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Sat, 16 Jul 2022 18:40:35 +0200 Subject: [PATCH] frontend: Fix progress indicator --- app.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 961ce94..f0958c6 100644 --- a/app.js +++ b/app.js @@ -47,6 +47,8 @@ function getHasher(hashType) { const buttonText = e.target.innerText e.target.innerText = "Calculating hash…" + document.getElementById("hash-container").classList.remove("done") + const formData = new FormData(document.getElementById("hash-setup")) const hashSetup = getHashSetup(formData) @@ -54,9 +56,13 @@ function getHasher(hashType) { const hasher = getHasher(hashSetup.hashType) - displayHash(hasher(hashSetup.password, hashSetup.privateOptions)) + // Hack for enforcing that the DOM changes get propagated to the view + // before the hash is calculated (which blocks the thread). + setTimeout(() => { + displayHash(hasher(hashSetup.password, hashSetup.privateOptions)) - e.target.innerText = buttonText - e.target.disabled = false + e.target.innerText = buttonText + e.target.disabled = false + }, 0) }) })()