Hotfix Copy button generation

dev
gravel 2 years ago
parent 1d48e1e5fb
commit 490d25c895
Signed by: gravel
GPG Key ID: C0538F3C906B308F

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

@ -61,7 +61,7 @@
> >
</td> </td>
<td class="td_join_url"> <td class="td_join_url">
<div class="join_url_container"> <div class="join_url_container" data-url="<?=$room->join_link?>">
<a class="join_url show-from-w5" title="<?=$room->join_link?>" <a class="join_url show-from-w5" title="<?=$room->join_link?>"
><?=truncate($room->join_link, 32)?></a> ><?=truncate($room->join_link, 32)?></a>
<a class="noscript" href="<?=$room->join_link?>" <a class="noscript" href="<?=$room->join_link?>"

Loading…
Cancel
Save