From f21d1aa77c7ca002ef590d99b60efe12aa013f3f Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sun, 26 Jul 2026 02:12:24 -0700 Subject: [PATCH] Append test output as new nodes instead of extra text. Replace inner HTML modifications with text content updates. --- index.html | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/index.html b/index.html index 19f5076..468c7ac 100644 --- a/index.html +++ b/index.html @@ -28,7 +28,7 @@ SPDX-License-Identifier: GPL-3.0-or-later if (NanoPow && Logger) { document.getElementById('btnStartTest').disabled = false - document.getElementById('status').innerHTML = `READY` + document.getElementById('status').textContent = `READY` } const logger = new Logger() @@ -80,7 +80,6 @@ SPDX-License-Identifier: GPL-3.0-or-later duration = end - start const valid = (result.hash === hash && check.hash === hash && check.valid === '1') - document.getElementById('output').textContent += `${valid ? 'VALID' : 'INVALID'} (${duration} ms)\n${JSON.stringify(result, ' ', 2)}\n` if (!valid) { logger.log(hash, result, check) throw new Error(`invalid result\nblock hash: ${hash}\nwork: ${work}`) @@ -106,7 +105,7 @@ SPDX-License-Identifier: GPL-3.0-or-later * @param {string} api */ async function selfCheck (api) { - document.getElementById('status').innerHTML = `RUNNING SELF-CHECK` + document.getElementById('status').textContent = `RUNNING SELF-CHECK` logger.log(`%cNanoPow`, 'color:green', 'Checking validation against known values') const options = { api, debug: true } // Generate once on load to compile shaders and initialize buffers @@ -186,7 +185,6 @@ SPDX-License-Identifier: GPL-3.0-or-later result = await NanoPow.work_generate(hash, options) logger.log(result) } catch (err) { - document.getElementById('output').innerHTML += `Error: ${err.message}
${err.cause}
${err.stack}` console.error(err) return } @@ -198,8 +196,7 @@ SPDX-License-Identifier: GPL-3.0-or-later } if (!expect.every(result => result)) { - document.getElementById('status').innerHTML = `FAILED TO VALIDATE KNOWN VALUES` - document.getElementById('output').innerHTML += `Error: Failed to validate known values
` + document.getElementById('status').textContent = `FAILED TO VALIDATE KNOWN VALUES, CHECK CONSOLE` throw new Error(`Validation is not working`) } } @@ -218,17 +215,17 @@ SPDX-License-Identifier: GPL-3.0-or-later await selfCheck(api) Cache.clear() logger.log(`%cNanoPow ${type}`, 'color:green', `Calculate truncated harmonic mean of the truncated arithmetic rate of generating proof-of-work for ${size} samples over ${runs} test runs.`) + const output = document.getElementById('output').appendChild(document.createElement('pre')) const rates = [] for (let i = 0; i < runs; i++) { - await new Promise(r => setTimeout(r)) const times = [] for (let j = 0; j < size; j++) { - document.getElementById('status').innerHTML = `TESTING IN PROGRESS. THIS MAY TAKE A LONG TIME. ${j}/${size} ${i}/${runs}
` + document.getElementById('status').textContent = `TESTING IN PROGRESS. THIS MAY TAKE A LONG TIME. ${j}/${size} ${i}/${runs}` try { const duration = await sequenceGenerateValidate(api, difficulty, effort) times.push(duration) } catch (err) { - document.getElementById('output').innerHTML += `Error: ${err.message}
` + output.textContent += `Error: ${err.message}\n` console.error(err) return } @@ -237,16 +234,16 @@ SPDX-License-Identifier: GPL-3.0-or-later const result = Object.values(avg)[0] const { truncatedRate } = result rates.push(truncatedRate) - document.getElementById('summary').innerHTML += `Test run ${i + 1} score: ${truncatedRate} wps
` - document.getElementById('output').innerHTML += `${JSON.stringify(avg, null, '\t')}
` + document.getElementById('summary').textContent += `Test run ${i + 1} score: ${truncatedRate} wps\n` + output.textContent += `${JSON.stringify(avg, null, '\t')}\n` } const results = stats(rates) const { truncatedHarmonic } = results logger.log(rates) logger.log(results) - document.getElementById('output').innerHTML += `
` - document.getElementById('summary').innerHTML += `Final work-per-second: ${truncatedHarmonic}
` - document.getElementById('status').innerHTML = `TESTING COMPLETE
` + output.after(document.createElement('hr')) + document.getElementById('summary').textContent += `Final work-per-second: ${truncatedHarmonic}\n` + document.getElementById('status').textContent = `TESTING COMPLETE` logger.log('%TESTING COMPLETE', 'color:orange;font-weight:bold') } @@ -392,7 +389,7 @@ SPDX-License-Identifier: GPL-3.0-or-later

 	

Output

-

+	
-- 2.52.0