frontend: Fix progress indicator

This commit is contained in:
Simon Bruder 2022-07-16 18:40:35 +02:00
parent 3212cdeb50
commit 0c824b5af7
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC

12
app.js
View file

@ -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)
})
})()