}
function startValidation (event) {
+ console.log('validating')
const threshold = document.getElementById('threshold')
const work = document.getElementById('work')
const hash = document.getElementById('hash')
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')
<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>