From: Ardis Lu Date: Wed, 10 Jun 2026 06:41:31 +0000 (-0700) Subject: Only reset checkboxes if `type` has changed X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=6ff4ebe97dde7c0253d1675c8aaafd8f7ae3de81;p=minimal-srihash Only reset checkboxes if `type` has changed If a user is entering several files of the same type, the user likely wants the same settings (for example, `modulepreload` for all JS files). It is annoying to force the user to keep re-checking the boxes. --- diff --git a/index.html b/index.html index 7753038..175720b 100644 --- a/index.html +++ b/index.html @@ -246,13 +246,15 @@ } } + let previousType = ''; form.addEventListener('submit', async e => { e.preventDefault(); const { url, sriHash, preload, esm } = e.target.elements; const { type, ...sri } = await getSri(url.value); - // Reset checkboxes if form submitted via "Hash!" button - if (e?.submitter?.tagName === 'BUTTON') { + // Reset checkboxes if form submitted via "Hash!" button and type has changed + if (e?.submitter?.tagName === 'BUTTON' && type !== previousType) { + previousType = type; preload.checked = false; esm.checked = false; if (type === 'text/javascript' || type === 'application/javascript') {