MCPcopy Create free account
hub / github.com/Cosmian/kms / linkifyFileCells

Function linkifyFileCells

documentation/docs/javascripts/log_filter.js:215–247  ·  view source on GitHub ↗
(content)

Source from the content-addressed store, hash-verified

213}
214
215function linkifyFileCells(content) {
216 const version = (window.KMS_VERSION || "develop").trim();
217
218 content.querySelectorAll("table").forEach((tableEl) => {
219 // Only act on 5-column tables (our log tables)
220 if (tableEl.querySelectorAll("thead th").length < 5) return;
221 if (tableEl.dataset.linksInjected === "true") return;
222 tableEl.dataset.linksInjected = "true";
223
224 const cratePath = getCratePath(tableEl);
225 if (!cratePath) return;
226
227 tableEl.querySelectorAll("tbody tr").forEach((row) => {
228 const cells = row.querySelectorAll("td");
229 if (cells.length < 3) return;
230 const fileCell = cells[2]; // File is the 3rd column (0-indexed)
231 const code = fileCell.querySelector("code");
232 if (!code) return;
233 if (fileCell.querySelector("a")) return; // already linked
234
235 const fileRel = code.textContent.trim();
236 const href = `${GITHUB_BASE}/${version}/${cratePath}/${fileRel}`;
237
238 const link = document.createElement("a");
239 link.href = href;
240 link.target = "_blank";
241 link.rel = "noopener noreferrer";
242 link.appendChild(code.cloneNode(true));
243
244 fileCell.replaceChildren(link);
245 });
246 });
247}
248
249// ── Inline badge coloring ─────────────────────────────────────────────────
250// Colors <code>error</code>, <code>trace</code>, etc. throughout the page.

Callers 1

initPageFunction · 0.85

Calls 2

getCratePathFunction · 0.85
forEachMethod · 0.45

Tested by

no test coverage detected