From 848eb43c80166ffb9d440ddf8c5d00cff2b22f91 Mon Sep 17 00:00:00 2001 From: Ayo Ayco Date: Sun, 19 Jan 2025 09:57:45 +0100 Subject: [PATCH] feat: remove enhance-content wc --- static/enhance-content.js | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 static/enhance-content.js diff --git a/static/enhance-content.js b/static/enhance-content.js deleted file mode 100644 index d26c681..0000000 --- a/static/enhance-content.js +++ /dev/null @@ -1,37 +0,0 @@ -class EnhanceContent extends HTMLElement { - connectedCallback() { - const el = this.getElementsByClassName("hashtag"); - const server = this.dataset.server; - const tagUrl = this.dataset.tagUrl; - - for (let i = 0; i < el.length; i++) { - const tagEl = el.item(i); - const currentHref = tagEl.getAttribute("href"); - const tagName = currentHref.replace(`${server}/tags/`, ""); - tagEl.setAttribute("href", tagUrl + tagName); - - const parentEl = tagEl.parentElement; - const siblings = parentEl.childNodes; - let validSiblingsCount = 0; - - for (const sibling of siblings) { - if (!(sibling.nodeType === 3 && sibling.textContent === " ")) { - validSiblingsCount++; - } - } - - const childrenTags = parentEl.getElementsByClassName("hashtag"); - - console.log({ childrenTags, siblings, validSiblingsCount }); - - const isTagBar = validSiblingsCount === childrenTags.length; - - if (isTagBar) { - tagEl.textContent = tagName; - tagEl.classList.add("pill"); - } - } - } -} - -customElements.define("enhance-content", EnhanceContent);