aboutsummaryrefslogtreecommitdiff
path: root/communities/174bg/handbook
diff options
context:
space:
mode:
authorAlex Pooley (@zuedev) <zuedev@gmail.com>2026-05-26 05:03:29 +0100
committerAlex Pooley (@zuedev) <zuedev@gmail.com>2026-05-26 05:03:29 +0100
commitbde0b9f99d70b3718b60d84b18b20761446320f4 (patch)
tree115bb6aea0b998e7b88741713d13066b7c82e3a7 /communities/174bg/handbook
parent68e07291f4b63e31eaac1fffbbdc8f7ba9d4fa70 (diff)
downloadunnamed-group-bde0b9f99d70b3718b60d84b18b20761446320f4.tar
unnamed-group-bde0b9f99d70b3718b60d84b18b20761446320f4.tar.gz
unnamed-group-bde0b9f99d70b3718b60d84b18b20761446320f4.tar.bz2
unnamed-group-bde0b9f99d70b3718b60d84b18b20761446320f4.tar.xz
unnamed-group-bde0b9f99d70b3718b60d84b18b20761446320f4.zip
add replaceWordsWithLinks
Diffstat (limited to 'communities/174bg/handbook')
-rw-r--r--communities/174bg/handbook/public/index.html53
1 files changed, 50 insertions, 3 deletions
diff --git a/communities/174bg/handbook/public/index.html b/communities/174bg/handbook/public/index.html
index 04e42b0..1bb815d 100644
--- a/communities/174bg/handbook/public/index.html
+++ b/communities/174bg/handbook/public/index.html
@@ -882,9 +882,7 @@
<ul>
<li>
<strong>Primary Ship:</strong>
- <a href="https://starcitizen.tools/Hull_C">Hull C</a>
- (<a href="https://starcitizen.tools/Hull_E">Hull E</a> once
- available)
+ Hull C (Hull E once available)
</li>
</ul>
</section>
@@ -1195,6 +1193,8 @@
console.log("DOMContentLoaded");
generateTableOfContents();
+
+ replaceWordsWithLinks();
});
function generateTableOfContents() {
@@ -1266,5 +1266,52 @@
}
});
}
+
+ function replaceWordsWithLinks() {
+ const linkMap = {
+ "Hull C": "https://starcitizen.tools/Hull_C",
+ "Hull E": "https://starcitizen.tools/Hull_E",
+ };
+
+ const walker = document.createTreeWalker(
+ document.body,
+ NodeFilter.SHOW_TEXT,
+ null,
+ false,
+ );
+
+ let node;
+ while ((node = walker.nextNode())) {
+ const parent = node.parentNode;
+ if (parent && parent.tagName !== "A") {
+ let text = node.textContent;
+ let replaced = false;
+
+ for (const [word, url] of Object.entries(linkMap)) {
+ const regex = new RegExp(`\\b${word}\\b`, "g");
+ if (regex.test(text)) {
+ const link = document.createElement("a");
+ link.href = url;
+ link.textContent = word;
+ text = text.replace(regex, link.outerHTML);
+ replaced = true;
+
+ console.log(
+ `Replaced "${word}" with link to ${url} in text: "${node.textContent.trim()}"`,
+ );
+ }
+ }
+
+ if (replaced) {
+ const tempDiv = document.createElement("div");
+ tempDiv.innerHTML = text;
+ while (tempDiv.firstChild) {
+ parent.insertBefore(tempDiv.firstChild, node);
+ }
+ parent.removeChild(node);
+ }
+ }
+ }
+ }
</script>
</html>