diff --git a/public/index.html b/public/index.html
index ea1a5655..e741d93f 100644
--- a/public/index.html
+++ b/public/index.html
@@ -84,7 +84,7 @@
-
+
diff --git a/public/packets.js b/public/packets.js
index 315e600c..78ce2485 100644
--- a/public/packets.js
+++ b/public/packets.js
@@ -413,6 +413,11 @@
+
@@ -460,6 +465,19 @@
loadPackets();
});
+ // Observation sort dropdown
+ const obsSortSel = document.getElementById('fObsSort');
+ obsSortSel.value = obsSortMode;
+ obsSortSel.addEventListener('change', function () {
+ obsSortMode = this.value;
+ localStorage.setItem('meshcore-obs-sort', obsSortMode);
+ // Re-sort all expanded groups
+ for (const p of packets) {
+ if (expandedHashes.has(p.hash) && p._children) sortGroupChildren(p);
+ }
+ renderTableRows();
+ });
+
// Column visibility toggle (#71)
const COL_DEFS = [
{ key: 'region', label: 'Region' },
@@ -600,13 +618,6 @@
if (hash) selectPacket(null, hash);
else selectPacket(Number(value));
}
- else if (action === 'sort-group') {
- e.preventDefault();
- const sortType = btn.dataset.sort;
- groupSortModes[value] = sortType;
- const group = packets.find(p => p.hash === value);
- if (group) { sortGroupChildren(group); renderTableRows(); }
- }
else if (action === 'select-observation') {
const parentHash = row.dataset.parentHash;
const group = packets.find(p => p.hash === parentHash);
@@ -699,11 +710,6 @@
`;
// Child rows (loaded async when expanded)
if (isExpanded && p._children) {
- const sortMode = groupSortModes[p.hash] || SORT_OBSERVER;
- const obsLabel = sortMode === SORT_OBSERVER ? '
Observer' : 'Observer';
- const pathLabel = sortMode === SORT_PATH_LENGTH ? '
Path length' : 'Path length';
- const chronoLabel = sortMode === SORT_CHRONO ? '
Chronological' : 'Chronological';
- html += `
| Sort: ${obsLabel} · ${pathLabel} · ${chronoLabel} |
`;
for (const c of p._children) {
const typeName = payloadTypeName(c.payload_type);
const typeClass = payloadTypeColor(c.payload_type);
@@ -1253,7 +1259,7 @@
const SORT_OBSERVER = 'observer';
const SORT_PATH_LENGTH = 'path';
const SORT_CHRONO = 'chrono';
- const groupSortModes = {}; // hash → sort mode
+ let obsSortMode = localStorage.getItem('meshcore-obs-sort') || SORT_OBSERVER;
function getPathHopCount(c) {
try { return JSON.parse(c.path_json || '[]').length; } catch { return 0; }
@@ -1261,7 +1267,7 @@
function sortGroupChildren(group) {
if (!group || !group._children) return;
- const mode = groupSortModes[group.hash] || SORT_OBSERVER;
+ const mode = obsSortMode;
if (mode === SORT_CHRONO) {
group._children.sort((a, b) => {