From 718f402fa621b22363d5d3780b4484763bf2006c Mon Sep 17 00:00:00 2001 From: Anthony Doud Date: Sun, 15 Dec 2024 20:13:54 -0600 Subject: [PATCH] added a save button to the debug log --- data/status.html | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/data/status.html b/data/status.html index 1871db11..03e615e4 100644 --- a/data/status.html +++ b/data/status.html @@ -1,11 +1,17 @@ + SmartSpin2k Status - + +
@@ -105,6 +111,9 @@

Debug Console

Loading
+
+ +
@@ -148,7 +157,7 @@

Debug Console

function requestConfigValues() { if (updatePending) return; - + updatePending = true; fetch('/configJSON') .then(response => response.json()) @@ -166,7 +175,7 @@

Debug Console

function requestRuntimeValues() { if (updatePending) return; - + updatePending = true; fetch('/runtimeConfigJSON') .then(response => response.json()) @@ -202,16 +211,16 @@

Debug Console

websocket.onmessage = (evt) => { if (!evt?.data) return; - + lastLogMessageTime = Date.now(); logEntries.push(evt.data); - + if (logEntries.length > maxLogentries) { logEntries = logEntries.slice(1, logEntries.length - 10); } debugElement.innerHTML = logEntries.join("
"); - + if (followElement.checked) { debugElement.scrollTop = debugElement.scrollHeight - debugElement.clientHeight; } @@ -239,6 +248,22 @@

Debug Console

setTimeout(requestRuntimeValues, 200); startUpdate(); }); + + document.getElementById('saveLogButton').addEventListener('click', () => { + const debugElement = document.getElementById('debug'); + const logContent = debugElement.textContent; + const blob = new Blob([logContent], { type: 'text/plain' }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = 'debug_log.txt'; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + }); + - + + \ No newline at end of file