diff --git a/output/main.js b/output/main.js index 0bc0bdb..567097e 100644 --- a/output/main.js +++ b/output/main.js @@ -51,11 +51,11 @@ const filteredCommunities = { // This can be achieved with `text-overflow: ellipsis` instead // and generated entirely server-side. const transformJoinURL = (join_link) => { - return element.button({ - textContent: "Copy", - className: "copy_button", - onclick: () => copyToClipboard(join_link) - }); + return element.button({ + textContent: "Copy", + className: "copy_button", + onclick: () => copyToClipboard(join_link) + }); } function onLoad(timestamp) { @@ -77,8 +77,8 @@ function hideQRModal(communityID) { function createJoinLinkButtons() { const join_URLs = dom.join_urls(); Array.from(join_URLs).forEach((td_url) => { - const a_href = td_url.querySelector('a'); // get first (only) element - const join_link = a_href.getAttribute("href"); // get link + // Data attributes are more idiomatic and harder to change by accident in the DOM. + const join_link = td_url.getAttribute('data-url'); td_url.append(transformJoinURL(join_link)); // add interactive content }); } @@ -101,7 +101,7 @@ function hideBadCommunities() { * Removes an element by its ID and returns the number of elements removed. */ function hideElementByID(id) { - const element = document.getElementById(id); + const element = document.getElementById(id); element?.remove(); return element ? 1 : 0; } @@ -289,3 +289,4 @@ Object.assign(window, { onLoad, sortTable, displayQRModal, hideQRModal, copyToClipboard }); + diff --git a/sites/+components/tbl_communities.php b/sites/+components/tbl_communities.php index 9292b15..dbb5325 100644 --- a/sites/+components/tbl_communities.php +++ b/sites/+components/tbl_communities.php @@ -61,7 +61,7 @@ >