Skip to content

Commit

Permalink
Row selection
Browse files Browse the repository at this point in the history
  • Loading branch information
mskvortsov committed Apr 17, 2024
1 parent a8b5aca commit 66633c8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<input id="mqtt-topic" type="text" size="10"/>
<button id="mqtt-connect">Connect</button>
<button id="clear">Clear</button>
<button id="unselect">Unselect</button>
<span id="mqtt-status"></span>
</td>
<td class="right">
Expand Down
22 changes: 21 additions & 1 deletion meshmon.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
--filter-error-bg-color: #d5899c;
--logo-light-mode: block;
--logo-dark-mode: none;

--selected-header: #c2c260;
--selected-header-outbound: #5fcc44;
--selected-decoded: #f9f978;
}

[data-theme="dark"] {
Expand All @@ -25,6 +29,10 @@
--filter-error-bg-color: #4b2f36;
--logo-light-mode: none;
--logo-dark-mode: block;

--selected-header: #5b6053;
--selected-header-outbound: #1c8100;
--selected-decoded: #56563c;
}

body {
Expand Down Expand Up @@ -78,7 +86,7 @@ body {
.packet-header-row-outbound {
background: var(--packet-header-outbound-bg-color);
}
.packet-decoded {
.packet-decoded td {
text-align: left;
}
#filter-expr-input {
Expand Down Expand Up @@ -115,6 +123,18 @@ body {
border: 0;
}

/* Row selection */

.selected.packet-header-row {
background-color: var(--selected-header);
}
.selected.packet-header-row-outbound {
background-color: var(--selected-header-outbound);
}
.selected.packet-decoded {
background-color: var(--selected-decoded);
}

/* Source code link logo */

.logo {
Expand Down
23 changes: 18 additions & 5 deletions meshmon.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,22 @@ function render(se) {
console.error('parsing error');
}

var row = tbody.insertRow();
var cell = row.insertCell();
cell.className = 'packet-decoded verbatim';
var decodedRow = tbody.insertRow();
decodedRow.className = 'packet-decoded verbatim';
var cell = decodedRow.insertCell();
cell.colSpan = fields.length;
var decoded = document.createElement('pre');
decoded.textContent = text;
cell.appendChild(decoded);

headerRow.onclick = () => {
headerRow.classList.toggle('selected');
headerRow.nextElementSibling.classList.toggle('selected');
};
decodedRow.onclick = () => {
decodedRow.previousElementSibling.classList.toggle('selected');
decodedRow.classList.toggle('selected');
};
}

function mqttOnMessage(topic, message) {
Expand Down Expand Up @@ -476,8 +485,12 @@ window.onload = function() {
connectButton = document.getElementById('mqtt-connect');
connectButton.addEventListener('click', onClickConnect);

var clearButton = document.getElementById('clear');
clearButton.addEventListener('click', onClickClear);
document.getElementById('clear').addEventListener('click', onClickClear);
document.getElementById('unselect').addEventListener('click', function() {
Array.from(tbody.rows).forEach((row) => {
row.classList.remove('selected');
});
});

filterInput = document.getElementById('filter-expr-input');
filterInput.placeholder = 'Filter: a JavaScript expression over header fields, ' +
Expand Down

0 comments on commit 66633c8

Please sign in to comment.