Fix docstring accuracy, extract _firstElementFromHtml helper, address all code review feedback
This commit is contained in:
committed by
GitHub
parent
69b84153b4
commit
06988d0ff0
@@ -2415,15 +2415,15 @@ def _get_bip110_status() -> dict:
|
|||||||
Resolution order (authoritative → fallback → honest unknown):
|
Resolution order (authoritative → fallback → honest unknown):
|
||||||
|
|
||||||
1. ``getdeploymentinfo`` (authoritative) — scan the ``deployments`` dict for an
|
1. ``getdeploymentinfo`` (authoritative) — scan the ``deployments`` dict for an
|
||||||
entry whose key (case-insensitive) contains "bip110" or "110". The exact
|
entry whose key (case-insensitive) contains "bip110". The exact
|
||||||
deployment key name is **not** hard-coded because it may vary across Knots
|
deployment key name is **not** hard-coded because it may vary across Knots
|
||||||
releases; detection is intentionally generic so that a name change degrades
|
releases; detection is intentionally generic so that a name change degrades
|
||||||
to "unknown" rather than producing a false result.
|
to "unknown" rather than producing a false result.
|
||||||
|
|
||||||
2. Subversion fallback — if getdeploymentinfo is unavailable or yields no
|
2. Subversion fallback — if getdeploymentinfo is unavailable or yields no
|
||||||
recognisable BIP-110 entry, inspect the ``subversion`` field from
|
recognisable BIP-110 entry, inspect the ``subversion`` field from
|
||||||
``getnetworkinfo``. A case-insensitive match for "bip110" or "uasf" in the
|
``getnetworkinfo``. A case-insensitive match for "bip110" or "uasf-bip110"
|
||||||
subversion string is treated as "signaling".
|
in the subversion string is treated as "signaling".
|
||||||
|
|
||||||
3. Unknown — if the node is entirely unreachable or neither source is
|
3. Unknown — if the node is entirely unreachable or neither source is
|
||||||
conclusive, return state="unknown", signaling=False, source="none".
|
conclusive, return state="unknown", signaling=False, source="none".
|
||||||
|
|||||||
@@ -13,6 +13,12 @@ function _renderBip110Badge(bip110) {
|
|||||||
return '<div class="tile-bip110-badge ' + cfg.cls + '" title="' + escHtml(cfg.title) + '">' + escHtml(cfg.label) + '</div>';
|
return '<div class="tile-bip110-badge ' + cfg.cls + '" title="' + escHtml(cfg.title) + '">' + escHtml(cfg.label) + '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _firstElementFromHtml(html) {
|
||||||
|
var tmp = document.createElement("div");
|
||||||
|
tmp.innerHTML = html;
|
||||||
|
return tmp.firstElementChild || null;
|
||||||
|
}
|
||||||
|
|
||||||
// ── Render: initial build ─────────────────────────────────────────
|
// ── Render: initial build ─────────────────────────────────────────
|
||||||
|
|
||||||
function buildTiles(services, categoryLabels) {
|
function buildTiles(services, categoryLabels) {
|
||||||
@@ -281,21 +287,13 @@ function updateTiles(services) {
|
|||||||
var badgeEl = tile.querySelector(".tile-bip110-badge");
|
var badgeEl = tile.querySelector(".tile-bip110-badge");
|
||||||
if (badgeEl) {
|
if (badgeEl) {
|
||||||
// Replace existing badge in-place
|
// Replace existing badge in-place
|
||||||
var tmp = document.createElement("div");
|
var newBadge = _firstElementFromHtml(badgeHtml);
|
||||||
tmp.innerHTML = badgeHtml;
|
if (newBadge) { badgeEl.replaceWith(newBadge); } else { badgeEl.remove(); }
|
||||||
var newBadge = tmp.firstElementChild;
|
|
||||||
if (newBadge) {
|
|
||||||
badgeEl.replaceWith(newBadge);
|
|
||||||
} else {
|
|
||||||
badgeEl.remove();
|
|
||||||
}
|
|
||||||
} else if (badgeHtml) {
|
} else if (badgeHtml) {
|
||||||
// Insert badge after version label (or after tile-name if no version)
|
// Insert badge after version label (or after tile-name if no version)
|
||||||
var anchorEl = tile.querySelector(".tile-version") || tile.querySelector(".tile-name");
|
var anchorEl = tile.querySelector(".tile-version") || tile.querySelector(".tile-name");
|
||||||
if (anchorEl) {
|
if (anchorEl) {
|
||||||
var tmpDiv = document.createElement("div");
|
var newBadgeEl = _firstElementFromHtml(badgeHtml);
|
||||||
tmpDiv.innerHTML = badgeHtml;
|
|
||||||
var newBadgeEl = tmpDiv.firstElementChild;
|
|
||||||
if (newBadgeEl) anchorEl.insertAdjacentElement("afterend", newBadgeEl);
|
if (newBadgeEl) anchorEl.insertAdjacentElement("afterend", newBadgeEl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user