|
|
|
@ -49,8 +49,11 @@ const filteredCommunities = {
|
|
|
|
|
*/
|
|
|
|
|
const preloadedImages = [];
|
|
|
|
|
|
|
|
|
|
// This can be achieved with `text-overflow: ellipsis` instead
|
|
|
|
|
// and generated entirely server-side.
|
|
|
|
|
/**
|
|
|
|
|
* Create an interactive version of the Community join link.
|
|
|
|
|
* @param {string} join_link
|
|
|
|
|
* @returns {HTMLElement}
|
|
|
|
|
*/
|
|
|
|
|
const transformJoinURL = (join_link) => {
|
|
|
|
|
return element.button({
|
|
|
|
|
textContent: "Copy",
|
|
|
|
@ -60,6 +63,10 @@ const transformJoinURL = (join_link) => {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fetches the last modification timestamp from the DOM.
|
|
|
|
|
* @returns {?number}
|
|
|
|
|
*/
|
|
|
|
|
function getTimestamp() {
|
|
|
|
|
const timestampRaw = dom.meta_timestamp()
|
|
|
|
|
?.getAttribute('content');
|
|
|
|
@ -69,6 +76,9 @@ function getTimestamp() {
|
|
|
|
|
return timestamp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Triggers all actions dependent on page load.
|
|
|
|
|
*/
|
|
|
|
|
function onLoad() {
|
|
|
|
|
const timestamp = getTimestamp();
|
|
|
|
|
if (timestamp !== null) {
|
|
|
|
@ -84,6 +94,14 @@ function onLoad() {
|
|
|
|
|
preloadImages();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Construct room tag DOM from its description.
|
|
|
|
|
* @param {Object} param0
|
|
|
|
|
* @param {string} param0.text Tag name
|
|
|
|
|
* @param {"user"|"reserved"} param0.type Tag classification
|
|
|
|
|
* @param {string} param0.description Tag details
|
|
|
|
|
* @returns HTMLElement
|
|
|
|
|
*/
|
|
|
|
|
const tagBody = ({text, type, description}) => element.span({
|
|
|
|
|
// todo: truncate
|
|
|
|
|
textContent: text,
|
|
|
|
@ -91,6 +109,11 @@ const tagBody = ({text, type, description}) => element.span({
|
|
|
|
|
title: description
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Shows the details modal hydrated with the given community's details.
|
|
|
|
|
* @param {string} communityID
|
|
|
|
|
* @param {number} pane Pane number to display in modal
|
|
|
|
|
*/
|
|
|
|
|
function displayQRModal(communityID, pane = 0) {
|
|
|
|
|
const modal = dom.details_modal();
|
|
|
|
|
|
|
|
|
@ -140,10 +163,16 @@ function displayQRModal(communityID, pane = 0) {
|
|
|
|
|
modal.showModal();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hideQRModal(communityID) {
|
|
|
|
|
/**
|
|
|
|
|
* Hides the Community details modal.
|
|
|
|
|
*/
|
|
|
|
|
function hideQRModal() {
|
|
|
|
|
dom.details_modal().close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds handlers for details modal-related actions.
|
|
|
|
|
*/
|
|
|
|
|
function addQRModalHandlers() {
|
|
|
|
|
const rows = dom.tbl_communities_content_rows();
|
|
|
|
|
if (!rows) throw new Error("Rows not found");
|
|
|
|
@ -234,6 +263,9 @@ function addQRModalHandlers() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prefetches images used in the page to prevent tracking.
|
|
|
|
|
*/
|
|
|
|
|
function preloadImages() {
|
|
|
|
|
const rows = dom.tbl_communities_content_rows();
|
|
|
|
|
const identifiers = rows.map(
|
|
|
|
@ -257,6 +289,9 @@ function preloadImages() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Places join link buttons in the Community rows.
|
|
|
|
|
*/
|
|
|
|
|
function createJoinLinkButtons() {
|
|
|
|
|
const join_URLs = dom.join_urls();
|
|
|
|
|
Array.from(join_URLs).forEach((td_url) => {
|
|
|
|
@ -266,6 +301,9 @@ function createJoinLinkButtons() {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Hides rows of communities deemed to be superflous or unsuitable.
|
|
|
|
|
*/
|
|
|
|
|
function hideBadCommunities() {
|
|
|
|
|
let numberOfHiddenCommunities = 0;
|
|
|
|
|
|
|
|
|
|