diff --git a/output/js/constants.js b/output/js/constants.js
index 23bc0d1b..49c040a0 100644
--- a/output/js/constants.js
+++ b/output/js/constants.js
@@ -3,6 +3,7 @@
// change in the foreseeable future.
export const dom = {
+ /** @return {HTMLTableElement | null} */
tbl_communities: () => document.getElementById("tbl_communities"),
last_checked: () => document.getElementById("last_checked_value"),
qr_modal: (communityID) => document.getElementById(`modal_${communityID}`),
diff --git a/output/main.js b/output/main.js
index a8525983..3f27bf3c 100644
--- a/output/main.js
+++ b/output/main.js
@@ -46,12 +46,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) {
@@ -62,6 +76,25 @@ 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) {
+ if (row.querySelector('th')) continue;
+ 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) => {
@@ -238,9 +271,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)
+ )
+ };
}
/**
@@ -264,13 +301,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());
diff --git a/sites/+components/page-head.php b/sites/+components/page-head.php
index 730c42fe..08537b40 100644
--- a/sites/+components/page-head.php
+++ b/sites/+components/page-head.php
@@ -1,3 +1,11 @@
-
\ No newline at end of file
+
+
+
diff --git a/sites/+components/qr_modals.php b/sites/+components/qr_modals.php
index adf6e2d8..1a4f31cb 100644
--- a/sites/+components/qr_modals.php
+++ b/sites/+components/qr_modals.php
@@ -34,7 +34,7 @@
$room): ?>
-
+
×
"identifier", 'name' => "Identifier"],
['id' => "language", 'name' => "L"],
@@ -51,17 +52,29 @@
$hostname = explode("//", $room->join_link)[1];
$hostname = explode("/", $hostname)[0];
+
+ // Escape external input.
+ // Ternaries prevent passing null-equal strings, which produce warnings.
+ $id = htmlspecialchars($id);
+ $language = $room->language ? htmlspecialchars($room->language) : "";
+ $name = htmlspecialchars($room->name);
+ $desc = $room->description ? htmlspecialchars($room->description) : "";
+ $users = htmlspecialchars($room->active_users);
+ $preview_link = htmlspecialchars($room->preview_link);
+ $join_link = htmlspecialchars($room->join_link);
+ // TODO: Do not forget to rename this escape when merging!
+ $token = htmlspecialchars($token);
+ $hostname = htmlspecialchars($hostname);
?>
-
- =$id?>
- =$room->language?>
- =$room->name?>
- =$room->description?>
- =$room->active_users?>
-
-
+ ">
+ =$id?>
+ =$language?>
+ =$name?>
+ =$desc?>
+ =$users?>
+
+
preview_link, 'http://')): ?>
HTTP
@@ -71,26 +84,26 @@
-
-
=strtoupper($token[0] . $token[1])?>
-
diff --git a/sites/+instructions/Finnish.txt b/sites/+instructions/Finnish.txt
new file mode 100644
index 00000000..9bd75153
--- /dev/null
+++ b/sites/+instructions/Finnish.txt
@@ -0,0 +1,12 @@
+Mobiililaitteella:
+
+- Napsauta Kopioi-nappia kopioidaksesi ryhmän URL-osoitteen.
+- Avaa Session, paina plussan painiketta ja valitse "Liity ryhmään" ("Join Community").
+- Liitä kopioitu URL-osoite "Syötä yhteisön URL-osoite"-kenttään, ja paina"Liity".
+
+
+Mobiililaitteella, kun tämä sivusto on auki tietokoneellasi:
+
+- Paina valitsemasi yhteisön QR-koodipainiketta tietokoneellasi.
+- Avaa Session, paina plussan painiketta ja valitse "Liity ryhmään" ("Join Community").
+- Valitse ylhäältä "Skannaa QR-koodi" ja skannaa puhelimen kameralla ryhmän QR-koodiin.
diff --git a/sites/+instructions/Russian.txt b/sites/+instructions/Russian.txt
new file mode 100644
index 00000000..0e3230d0
--- /dev/null
+++ b/sites/+instructions/Russian.txt
@@ -0,0 +1,12 @@
+На мобильном девайсе:
+
+- Нажмите кнопку «Копировать», чтобы скопировать URL-адрес нужной группы.
+- Откройте Session, нажмите на кнопку с плюсом и выберите «Присоединиться к сообществу».
+- Вставьте скопированный URL-адрес в поле «Введите URL-адрес сообщества», и нажмите «Присоединиться».
+
+
+На мобильном девайсе, когда этот сайт открыт на вашем компьютере:
+
+- Нажмите кнопку QR-кода для выбранного сообщества на вашем компьютере.
+- Откройте Session, нажмите на кнопку с плюсом и выберите «Присоединиться к сообществу».
+- Выберите «Сканировать QR-код» наверху и наведите камеру телефона на QR-код.
diff --git a/sites/index.php b/sites/index.php
index 8d51d44b..ecc21bb1 100644
--- a/sites/index.php
+++ b/sites/index.php
@@ -13,17 +13,35 @@
+
-
+
Self-updating list of active Session communities
+
+ ">
+
+
+
+
+
+
-
+
@@ -50,10 +68,16 @@
This site is not affiliated with
- Oxen Privacy Tech Foundation .
+ Oxen Privacy Tech Foundation .
Communities shown are fetched automatically from
- various sources.
+ various sources .
We make an attempt to hide communities containing
objectionable or illegal content, but
@@ -65,8 +89,13 @@
only available with JS enabled.
-
- Toggle room identifier display
+
+ Toggle room identifier display
@@ -83,17 +112,30 @@
Host Your Own Community
Session Terms Of Service
+
+
Source Code & Contact
+ >Source Code
+ Source Code (Mirror)
+ Contact
diff --git a/sites/instructions.php b/sites/instructions.php
index a89723e4..fb4275dd 100644
--- a/sites/instructions.php
+++ b/sites/instructions.php
@@ -1,46 +1,66 @@
+
+
. In short: Use the Copy button or scan the QR code!
+ ">
+
+
+
+
Instructions for joining Session Communities
+
+
+ Go back to Community list
+
+
Choose your language:
$file): ?>
-
>
=
// Name of the language
// Can be later parsed from i.e. first line of file
- pathinfo($file)['filename']
+ file_language($file);
?>
-
-
+
+
$file): ?>