]> zoso.dev Git - nano-pow.git/commitdiff
Adjust test form element names and extract function so other event listeners can...
authorChris Duncan <chris@zoso.dev>
Fri, 17 Jan 2025 21:03:25 +0000 (13:03 -0800)
committerChris Duncan <chris@zoso.dev>
Fri, 17 Jan 2025 21:03:25 +0000 (13:03 -0800)
test.html

index d95e69ef727febdd34d23c3fc798ce330e3624e0..3d266523c9e000b9fea908c197f1f733140943e1 100644 (file)
--- a/test.html
+++ b/test.html
@@ -117,32 +117,33 @@ SPDX-License-Identifier: GPL-3.0-or-later
                        console.log('%cTESTING COMPLETE', 'color:orange;font-weight:bold')
                }
 
-               document.getElementById('validate').addEventListener('click', e => {
-                       console.log(e)
+               function startValidation (event) {
                        const work = document.getElementById('work')
                        const hash = document.getElementById('hash')
-                       const validated = document.getElementById('validated')
-                       validated.innerText = ''
+                       const validation = document.getElementById('validation')
+                       validation.innerText = ''
                        NanoPow.validate(work.value, hash.value)
                                .then(result => {
-                                       validated.innerText = result
+                                       validation.innerText = result
                                                ? 'Valid'
                                                : 'INVALID'
                                })
                                .catch(err => {
                                        console.error(err)
-                                       validated.innerText = err.message
+                                       validation.innerText = err.message
                                })
-               })
+               }
+               document.getElementById('btnStartValidation').addEventListener('click', startValidation)
 
-               document.getElementById('go').addEventListener('click', e => {
+               function startTest (event) {
                        const size = document.getElementById('size')
                        const effort = document.getElementById('effort')
                        const isOutputShown = document.getElementById('isOutputShown')
                        const isGlForced = document.getElementById('isGlForced')
                        const isDebug = document.getElementById('isDebug')
                        run(+size.value, +effort.value, isOutputShown.checked, isGlForced.checked, isDebug.checked)
-               })
+               }
+               document.getElementById('btnStartTest').addEventListener('click', startTest)
        </script>
        <style>body{background:black;color:white;}a{color:darkcyan;}input[type=number]{width:5em;}span{margin:0.5em;}</style>
 </head>
@@ -160,11 +161,11 @@ SPDX-License-Identifier: GPL-3.0-or-later
        <input id="work" type="text" />
        <label for="hash">Hash</label>
        <input id="hash" type="text" />
-       <button id="validate">Validate</button>
-       <span id="validated"></span>
+       <button id="btnStartValidation">Validate</button>
+       <span id="validation"></span>
        <hr />
        <label for="size">Test Size</label>
-       <input id="size" type="number" value="64" />
+       <input id="size" type="number" value="64" autofocus />
        <label for="effort">Effort (1-16)</label>
        <input id="effort" type="number" value="8" min="1" max="16" />
        <span>
@@ -179,7 +180,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
                <label for="isDebug">Debug?</label>
                <input id="isDebug" type="checkbox" />
        </span>
-       <button id="go">Go</button>
+       <button id="btnStartTest">Go</button>
        <h3 id="status">WAITING</h3>
        <hr />
        <pre id="summary"></pre>