|
|
|
@ -17,7 +17,7 @@
|
|
|
|
|
import {
|
|
|
|
|
dom, COLUMN, COLUMN_LITERAL, COMPARISON, ATTRIBUTES,
|
|
|
|
|
columnAscendingByDefault, columnIsSortable, COLUMN_TRANSFORMATION,
|
|
|
|
|
element, JOIN_URL_PASTE, communityQRCodeURL, STAFF_ID_PASTE, IDENTIFIER_PASTE
|
|
|
|
|
element, JOIN_URL_PASTE, communityQRCodeURL, STAFF_ID_PASTE, IDENTIFIER_PASTE, DETAILS_LINK_PASTE
|
|
|
|
|
} from './js/constants.js';
|
|
|
|
|
|
|
|
|
|
// Hidden communities for transparency.
|
|
|
|
@ -76,6 +76,32 @@ function getTimestamp() {
|
|
|
|
|
return timestamp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Processes URL hash and parameter to trigger actions on the page.
|
|
|
|
|
*/
|
|
|
|
|
function reactToURLParameters() {
|
|
|
|
|
const hash = location.hash;
|
|
|
|
|
if (hash == "") return;
|
|
|
|
|
const communityID = hash.slice(1);
|
|
|
|
|
const row = dom.community_row(communityID);
|
|
|
|
|
if (row == null || !(row instanceof HTMLTableRowElement)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// manual scrolling to prevent jumping after every modal open
|
|
|
|
|
|
|
|
|
|
row.scrollIntoView({
|
|
|
|
|
behavior: "smooth"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
displayQRModal(communityID);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error("Could not navigate to community " + communityID);
|
|
|
|
|
console.error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Triggers all actions dependent on page load.
|
|
|
|
|
*/
|
|
|
|
@ -92,6 +118,7 @@ function onLoad() {
|
|
|
|
|
addQRModalHandlers();
|
|
|
|
|
addServerIconInteractions();
|
|
|
|
|
preloadImages();
|
|
|
|
|
reactToURLParameters();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -160,6 +187,8 @@ function displayQRModal(communityID, pane = 0) {
|
|
|
|
|
|
|
|
|
|
document.getElementById('details-modal-panes').setAttribute('data-pane', pane);
|
|
|
|
|
|
|
|
|
|
location.hash=`#${communityID}`;
|
|
|
|
|
|
|
|
|
|
modal.showModal();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -254,6 +283,13 @@ function addQRModalHandlers() {
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
document.querySelector('#details-modal-copy-room-details-link')?.addEventListener(
|
|
|
|
|
'click',
|
|
|
|
|
function() {
|
|
|
|
|
copyToClipboard(location.href, DETAILS_LINK_PASTE);
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
for (const anchor of dom.qr_code_buttons()) {
|
|
|
|
|
// Disable QR code links
|
|
|
|
|
anchor.setAttribute("href", "#");
|
|
|
|
@ -310,7 +346,7 @@ function hideBadCommunities() {
|
|
|
|
|
for (const category of ['tests', 'offensive']) {
|
|
|
|
|
numberOfHiddenCommunities +=
|
|
|
|
|
filteredCommunities[category]
|
|
|
|
|
.map(hideElementByID)
|
|
|
|
|
.map(hideCommunity)
|
|
|
|
|
.reduce((a, b) => a + b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -319,10 +355,10 @@ function hideBadCommunities() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Removes an element by its ID and returns the number of elements removed.
|
|
|
|
|
* Removes a Community by its ID and returns the number of elements removed.
|
|
|
|
|
*/
|
|
|
|
|
function hideElementByID(id) {
|
|
|
|
|
const element = document.getElementById(id);
|
|
|
|
|
function hideCommunity(communityID) {
|
|
|
|
|
const element = dom.community_row(communityID);
|
|
|
|
|
element?.remove();
|
|
|
|
|
return element ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|