Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
skrashevich committed Mar 22, 2024
1 parent a50c99b commit de70b0a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions www/log.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<div>
<button id="clean">Clean</button>
<button id="update">Auto Update: ON</button>
<button id="reverse">Reverse Log Order: ON</button>
<button id="reverse">Reverse Log Order: OFF</button>
</div>
<br>
<table>
Expand Down Expand Up @@ -86,11 +86,18 @@
.replace(/\n/g, '<br>');
}

let reverseBtn = document.getElementById('reverse');
let update = document.getElementById('update');

let reverseOrder = false;
let autoUpdateEnabled = true;

reverseBtn.textContent = `Reverse Log Order: ${reverseOrder ? 'ON' : 'OFF'}`;
update.textContent = `Auto Update: ${autoUpdateEnabled ? 'ON' : 'OFF'}`;

function applyLogStyling(jsonlines) {
const KEYS = ['time', 'level', 'message'];
const lines = JSON.parse('[' + jsonlines.trimEnd().replaceAll('\n', ',') + ']');
let lines = JSON.parse('[' + jsonlines.trimEnd().replaceAll('\n', ',') + ']');
if (reverseOrder) {
lines = lines.reverse();
}
Expand Down Expand Up @@ -118,17 +125,14 @@

reload();

// Handle auto-update switch
let autoUpdateEnabled = true;

const update = document.getElementById('update');
update.textContent = `Auto Update: ${autoUpdateEnabled ? 'ON' : 'OFF'}`;
update.addEventListener('click', () => {
autoUpdateEnabled = !autoUpdateEnabled;
update.textContent = `Auto Update: ${autoUpdateEnabled ? 'ON' : 'OFF'}`;
});

// Toggle log order
const reverseBtn = document.getElementById('reverse');
reverseBtn.textContent = `Reverse Log Order: ${reverseOrder ? 'ON' : 'OFF'}`;
reverseBtn.addEventListener('click', () => {
reverseOrder = !reverseOrder;
reverseBtn.textContent = `Reverse Log Order: ${reverseOrder ? 'ON' : 'OFF'}`;
Expand Down

0 comments on commit de70b0a

Please sign in to comment.