|
|
|
@ -60,12 +60,26 @@ const transformJoinURL = (join_link) => {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onLoad(timestamp) {
|
|
|
|
|
setLastChecked(timestamp);
|
|
|
|
|
function getTimestamp() {
|
|
|
|
|
const timestampRaw =
|
|
|
|
|
document.querySelector('meta[name=timestamp]')
|
|
|
|
|
?.getAttribute('content');
|
|
|
|
|
if (!timestampRaw) return null;
|
|
|
|
|
const timestamp = parseInt(timestampRaw);
|
|
|
|
|
if (Number.isNaN(timestamp)) return null;
|
|
|
|
|
return timestamp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onLoad() {
|
|
|
|
|
const timestamp = getTimestamp();
|
|
|
|
|
if (timestamp !== null) {
|
|
|
|
|
setLastChecked(timestamp);
|
|
|
|
|
}
|
|
|
|
|
hideBadCommunities();
|
|
|
|
|
sortTable(COLUMN.NAME);
|
|
|
|
|
createJoinLinkButtons();
|
|
|
|
|
markSortableColumns();
|
|
|
|
|
addQRModalHandlers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function displayQRModal(communityID) {
|
|
|
|
@ -76,6 +90,24 @@ function hideQRModal(communityID) {
|
|
|
|
|
dom.qr_modal(communityID).style.display = "none";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addQRModalHandlers() {
|
|
|
|
|
const rows = dom.tbl_communities()?.rows;
|
|
|
|
|
if (!rows) throw new Error("Rows not found");
|
|
|
|
|
for (const row of rows) {
|
|
|
|
|
const communityID = row.getAttribute('--data-identifier');
|
|
|
|
|
row.querySelector('.td_qr_code')?.addEventListener(
|
|
|
|
|
'click',
|
|
|
|
|
() => displayQRModal(communityID)
|
|
|
|
|
);
|
|
|
|
|
const closeButton =
|
|
|
|
|
dom.qr_modal(communityID)?.querySelector('.qr_code_modal_close');
|
|
|
|
|
closeButton?.addEventListener(
|
|
|
|
|
'click',
|
|
|
|
|
() => hideQRModal(communityID)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createJoinLinkButtons() {
|
|
|
|
|
const join_URLs = dom.join_urls();
|
|
|
|
|
Array.from(join_URLs).forEach((td_url) => {
|
|
|
|
@ -252,9 +284,13 @@ function markSortableColumns() {
|
|
|
|
|
const table = dom.tbl_communities();
|
|
|
|
|
const header_cells = table.querySelectorAll('th');
|
|
|
|
|
for (let colno = 0; colno < header_cells.length; colno++) {
|
|
|
|
|
if (!columnIsSortable(colno)) continue;
|
|
|
|
|
if (!columnIsSortable(colno)) continue;
|
|
|
|
|
header_cells[colno].classList.add('sortable');
|
|
|
|
|
}
|
|
|
|
|
header_cells[colno].addEventListener(
|
|
|
|
|
'click',
|
|
|
|
|
() => sortTable(colno)
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -278,13 +314,7 @@ function sortTable(column) {
|
|
|
|
|
setSortState(table, { ascending, column });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// html.js for styling purposes
|
|
|
|
|
window.document.documentElement.classList.add("js");
|
|
|
|
|
|
|
|
|
|
// Crude way to export from module script due to inline event handlers.
|
|
|
|
|
// Ideally, all handlers would be attached from JS via addEventListener.
|
|
|
|
|
Object.assign(window, {
|
|
|
|
|
onLoad, sortTable, displayQRModal,
|
|
|
|
|
hideQRModal, copyToClipboard
|
|
|
|
|
});
|
|
|
|
|
// `html.js` selector for styling purposes
|
|
|
|
|
document.documentElement.classList.add("js");
|
|
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', () => onLoad());
|
|
|
|
|