]> zoso.dev Git - nano-pow.git/commitdiff
Validate work on test page with pizzazz.
authorChris Duncan <chris@zoso.dev>
Sat, 25 Jan 2025 07:12:43 +0000 (23:12 -0800)
committerChris Duncan <chris@zoso.dev>
Sat, 25 Jan 2025 07:12:43 +0000 (23:12 -0800)
test.html

index cec3854d018110d55ca601ddde9df945ae504204..e016fd21a81b6057a28c361be191dbaae981022c 100644 (file)
--- a/test.html
+++ b/test.html
@@ -107,6 +107,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
                }
 
                function startValidation (event) {
+                       console.log('validating')
                        const threshold = document.getElementById('threshold')
                        const work = document.getElementById('work')
                        const hash = document.getElementById('hash')
@@ -115,15 +116,16 @@ SPDX-License-Identifier: GPL-3.0-or-later
                        NanoPow.validate(work.value, hash.value, { threshold: `0x${+threshold.value}` })
                                .then(result => {
                                        validation.innerText = result
-                                               ? 'Valid'
-                                               : 'INVALID'
+                                               ? '✔️'
+                                               : ''
                                })
                                .catch(err => {
-                                       console.error(err)
-                                       validation.innerText = err.message
+                                       validation.innerText = '⏳'
                                })
                }
-               document.getElementById('btnStartValidation').addEventListener('click', startValidation)
+               document.getElementById('threshold').addEventListener('input', startValidation)
+               document.getElementById('work').addEventListener('input', startValidation)
+               document.getElementById('hash').addEventListener('input', startValidation)
 
                function startTest (event) {
                        const threshold = document.getElementById('threshold')
@@ -151,11 +153,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
        <label for="threshold">Threshold 0x</label>
        <input id="threshold" type="text" value="FFFFFFF8" />
        <hr />
-       <label for="work">Work</label>
+       <label for="work">Validate Work</label>
        <input id="work" type="text" />
        <label for="hash">Hash</label>
        <input id="hash" type="text" />
-       <button id="btnStartValidation">Validate</button>
        <span id="validation"></span>
        <hr />
        <label for="size">Test Size</label>