Sfoglia il codice sorgente

Web: link neighbour IDs to meshcoretel.ru profile pages

renderNeighbourId in the /stats neighbours table now checks for the
"full_id" field emitted by appendJsonNeighbours().  If the value is a
valid 64-character hex string (the node's full 32-byte public key),
the short ID is wrapped in an anchor tag pointing to
https://meshcoretel.ru/<FULL_ID_UPPERCASE> (target="_blank",
rel="noopener noreferrer").  Falls back to plain short ID when
"full_id" is absent or does not match the expected pattern.
Valentin V. Bartenev 2 mesi fa
parent
commit
7378666416
1 ha cambiato i file con 6 aggiunte e 1 eliminazioni
  1. 6 1
      src/helpers/web/WebPanelServer.cpp

+ 6 - 1
src/helpers/web/WebPanelServer.cpp

@@ -1661,7 +1661,12 @@ const char kWebPanelAppHtml[] PROGMEM = R"HTML(
       }
       const renderNeighbourId = (neighbour) => {
         const shortId = escapeHtml(neighbour.id || "--");
-        return shortId;
+        const fullId = typeof neighbour.full_id === "string" ? neighbour.full_id.trim() : "";
+        if (!/^[0-9A-Fa-f]{64}$/.test(fullId)) {
+          return shortId;
+        }
+        const href = "https://meshcoretel.ru/" + encodeURIComponent(fullId.toUpperCase());
+        return `<a href="${href}" target="_blank" rel="noopener noreferrer">${shortId}</a>`;
       };
       const rows = neighbours.map((neighbour) => `<tr>
         <td>${renderNeighbourId(neighbour)}</td>