From 941db4aa36f851cd1000854986ce919ab277e358 Mon Sep 17 00:00:00 2001 From: FullGreaM Date: Thu, 6 Feb 2025 15:42:13 +0300 Subject: [PATCH] update into /connect, start work on /connect-area --- server/frontend/connect-router.js | 19 ++++++++++++++++ server/frontend/index.js | 5 ++++- server/frontend/pages/connect.html | 30 +++++++++++++++++++++++++- server/frontend/public/js/main.js | 18 +++++++++++++--- server/frontend/public/js/translate.js | 27 ++++++++++++++++++++--- 5 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 server/frontend/connect-router.js diff --git a/server/frontend/connect-router.js b/server/frontend/connect-router.js new file mode 100644 index 0000000..7d93c00 --- /dev/null +++ b/server/frontend/connect-router.js @@ -0,0 +1,19 @@ +module.exports = function (req, res) { + const serverAddress = req.query.server; + res.send(` + + + Connection: ${serverAddress} + + + +
+

Error: Javascript off


+

Javascript is required for the site to work, enable it in your browser settings

+
+ + +`); +} \ No newline at end of file diff --git a/server/frontend/index.js b/server/frontend/index.js index a832ba8..5d2563b 100644 --- a/server/frontend/index.js +++ b/server/frontend/index.js @@ -3,6 +3,7 @@ const path = require("path"); const logger = require("../logger"); const flDir = require("./fldir-router"); +const connectArea = require("./connect-router"); const api = require("./web-api/api-router"); module.exports = (address, port) => { @@ -18,7 +19,9 @@ module.exports = (address, port) => { app.use("/fl_dir", flDir); app.use("/api", api); - + + app.get("/connect-area", connectArea); + app.use("/*", (req, res) => { res.send(` diff --git a/server/frontend/pages/connect.html b/server/frontend/pages/connect.html index ce6f2df..68a0533 100644 --- a/server/frontend/pages/connect.html +++ b/server/frontend/pages/connect.html @@ -36,7 +36,7 @@ + + + \ No newline at end of file diff --git a/server/frontend/public/js/main.js b/server/frontend/public/js/main.js index 4627ae8..e404b9d 100644 --- a/server/frontend/public/js/main.js +++ b/server/frontend/public/js/main.js @@ -81,7 +81,10 @@ fl.bindLoad("/connect", () => { xhr.onload = async () => { if (xhr.status === 200) { - const servers = JSON.parse(xhr.response).result; + const localServers = JSON.parse(localStorage.getItem("savedServers") ?? "null") ?? []; + + const servers = localServers.concat(JSON.parse(xhr.response).result); + const serversByItemID = new Object(); const items = []; const itemIDs = []; const mp = servers.map(async serverItem => { @@ -98,6 +101,7 @@ fl.bindLoad("/connect", () => { ...data, itemID: `con-btn-to:${data.tag}:${serverItem.address}:${serverItem.port}` }); + serversByItemID[`con-btn-to:${data.tag}:${serverItem.address}:${serverItem.port}`] = { data, serverItem }; resolve(items.push(` ${data.name} ${serverItem.address}:${serverItem.port} @@ -125,7 +129,7 @@ fl.bindLoad("/connect", () => { }); await Promise.all(mp); - items.push(`
`); + items.push(`
`); document.getElementById("loading-servers").innerHTML = ` @@ -141,9 +145,17 @@ fl.bindLoad("/connect", () => { itemIDs.forEach(btn => { document.getElementById(btn.itemID).onclick = () => { - checkContentWarning(); + checkContentWarning(() => { + const serverInfo = serversByItemID[btn.itemID].serverItem; + window.open(`/connect-area?server=${serverInfo.address}:${serverInfo.port}`); + }); }; }); + + document.getElementById("conn-to-custom").onclick = function () { + const connectModal = new bootstrap.Modal(document.getElementById('connectModal'), {}); + connectModal.show(); + } } }; diff --git a/server/frontend/public/js/translate.js b/server/frontend/public/js/translate.js index 5c078f3..b460d44 100644 --- a/server/frontend/public/js/translate.js +++ b/server/frontend/public/js/translate.js @@ -52,10 +52,16 @@ const translationTree = { "accept-cookie-btn": "Accept", loading: "Loading of servers...", - titleDenial: ' Denial of responsibility', + titleDenial: ' Denial of responsibility', denialText: 'The server data does not belong to a centrally moderated foundation, community or individual, as well as to the developer of the software, program interface (protocol client), or protocol developer. Any content posted on servers is posted by the server administrator and can be absolutely anything. You assume all risks for the content and connect to the server at your own peril and risk!', "accept-denial-btn": "Accept", + titleCustomServerConnect: ' Connect to remote server', + titleCustomConnect: 'Connection Data', + addressCustomConnect: 'Enter address of server (without ws(s):// and port)', + portCustomConnect: 'Enter port of server', + tlsCustomConnect: 'Check this if server use TLS (wss:// connection):', + "server-name-tbl": "Name", "server-address": "Address", "server-encryption": "Encryprtion", @@ -78,10 +84,16 @@ const translationTree = { "accept-cookie-btn": "Принять", loading: "Загрузка серверов...", - titleDenial: ' Отказ от отвественности', + titleDenial: ' Отказ от отвественности', denialText: 'Данные сервера не принадлежат централизованно-модерируемому фонду, сообществу или частному лицу, а также разработчику программного обеспечения, програмного интерфейса (клиента протокола), разработчику протокола. Любой размещённый на серверах контент размещается администратором сервера и может быть абсолютно любым. Все риски за контент вы берёте полностью на себя и подключаетесь к серверу на свой страх и риск!', "accept-denial-btn": "Принять", + titleCustomServerConnect: ' Прямое подключение к серверу', + titleCustomConnect: 'Данные подключения', + addressCustomConnect: 'Адрес сервера (без порта и ws(s)://)', + portCustomConnect: 'Порт сервера', + tlsCustomConnect: 'Использовать защищённое соединение (TLS) (wss://):', + "server-name-tbl": "Имя сервера", "server-address": "Адрес", "server-encryption": "Шифрование", @@ -104,8 +116,17 @@ Object.entries(translationTree).forEach(([page, langs]) => { console.log(translationTree); +const simpleLangTags = { + "ru": "ru-RU", + "en": "en-US", +}; + function tr (page, id) { - const lang = navigator.language || navigator.userLanguage; + let lang = navigator.language || navigator.userLanguage; + lang = lang.split("-").length === 1 ? (simpleLangTags[lang] ?? "en-US") : lang; + // Britains sucks, Sir Keir Starmer (Sir Dicksucker) is faggot, he is sucking a muslim's dicks. + if (lang === "en-UK") + lang = "en-US"; // console.log("lang is", lang); return (translationTree[page]?.[lang]?.[id] ?? translationTree[page]?.["en-US"][id]) ?? null }
${tr("/connect", "server-name-tbl") ?? "Name"}