From 9269a089723bfe26f1919fd7b385e327556637f6 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Sun, 25 Aug 2024 15:41:31 -0500 Subject: [PATCH] compiled TS --- .dist/channel.js | 2 +- .dist/direct.js | 2 +- .dist/localuser.js | 52 ++++++++++++++++++++++++++++++++++++++++++++-- .dist/markdown.js | 37 +++++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 4 deletions(-) diff --git a/.dist/channel.js b/.dist/channel.js index 27f8cc4..6bfc692 100644 --- a/.dist/channel.js +++ b/.dist/channel.js @@ -655,7 +655,7 @@ class Channel { this.localuser.channelfocus = this; const prom = this.infinite.delete(); history.pushState(null, "", "/channels/" + this.guild_id + "/" + this.snowflake); - document.getElementById("channelname").textContent = "#" + this.name; + this.localuser.pageTitle("#" + this.name); const channelTopic = document.getElementById("channelTopic"); if (this.topic) { channelTopic.innerHTML = new MarkDown(this.topic, this).makeHTML().innerHTML; diff --git a/.dist/direct.js b/.dist/direct.js index 2303890..46ae8ca 100644 --- a/.dist/direct.js +++ b/.dist/direct.js @@ -132,7 +132,7 @@ class Group extends Channel { } this.buildmessages(); history.pushState(null, "", "/channels/" + this.guild_id + "/" + this.id); - document.getElementById("channelname").textContent = "@" + this.name; + this.localuser.pageTitle("@" + this.name); document.getElementById("channelTopic").setAttribute("hidden", ""); document.getElementById("typebox").contentEditable = "" + true; } diff --git a/.dist/localuser.js b/.dist/localuser.js index b849f9f..3ee0214 100644 --- a/.dist/localuser.js +++ b/.dist/localuser.js @@ -33,6 +33,9 @@ class Localuser { typing = new Map(); connectionSucceed = 0; errorBackoff = 0; + instancePing = { + name: "Unknown", + }; mfa_enabled; constructor(userinfo) { if (userinfo === -1) { @@ -94,6 +97,7 @@ class Localuser { user.nickname = thing.nickname; user.relationshipType = thing.type; } + this.pingEndpoint(); } outoffocus() { const servers = document.getElementById("servers"); @@ -369,14 +373,26 @@ class Localuser { else { thing = { id: temp.d.user_id }; } - message.makeReaction(temp.d.emoji, thing); + message.reactionAdd(temp.d.emoji, thing); } break; case "MESSAGE_REACTION_REMOVE": if (SnowFlake.hasSnowFlakeFromID(temp.d.message_id, Message)) { const message = SnowFlake.getSnowFlakeFromID(temp.d.message_id, Message).getObject(); console.log("test"); - message.removeReaction(temp.d.emoji, temp.d.user_id); + message.reactionRemove(temp.d.emoji, temp.d.user_id); + } + break; + case "MESSAGE_REACTION_REMOVE_ALL": + if (SnowFlake.hasSnowFlakeFromID(temp.d.message_id, Message)) { + const messageReactionRemoveAll = SnowFlake.getSnowFlakeFromID(temp.d.message_id, Message).getObject(); + messageReactionRemoveAll.reactionRemoveAll(); + } + break; + case "MESSAGE_REACTION_REMOVE_EMOJI": + if (SnowFlake.hasSnowFlakeFromID(temp.d.message_id, Message)) { + const messageReactionRemoveEmoji = SnowFlake.getSnowFlakeFromID(temp.d.message_id, Message).getObject(); + messageReactionRemoveEmoji.reactionRemoveEmoji(temp.d.emoji); } break; case "GUILD_MEMBERS_CHUNK": @@ -1341,6 +1357,38 @@ class Localuser { }); } } + async pingEndpoint() { + const userInfo = getBulkInfo(); + if (!userInfo.instances) + userInfo.instances = {}; + const wellknown = this.info.wellknown; + if (!userInfo.instances[wellknown]) { + const pingRes = await fetch(this.info.api + "/ping"); + const pingJSON = await pingRes.json(); + userInfo.instances[wellknown] = pingJSON; + localStorage.setItem("userinfos", JSON.stringify(userInfo)); + } + this.instancePing = userInfo.instances[wellknown].instance; + this.pageTitle("Loading..."); + } + pageTitle(channelName = "", guildName = "") { + document.getElementById("channelname").textContent = channelName; + document.getElementsByTagName("title")[0].textContent = channelName + (guildName ? " | " + guildName : "") + " | " + this.instancePing.name + " | Jank Client (Tomato fork)"; + } + async instanceStats() { + const res = await fetch(this.info.api + "/policies/stats", { + headers: this.headers + }); + const json = await res.json(); + const dialog = new Dialog(["vdiv", + ["title", "Instance stats: " + this.instancePing.name], + ["text", "Registered users: " + json.counts.user], + ["text", "Servers: " + json.counts.guild], + ["text", "Messages: " + json.counts.message], + ["text", "Members: " + json.counts.members] + ]); + dialog.show(); + } } export { Localuser }; let fixsvgtheme; diff --git a/.dist/markdown.js b/.dist/markdown.js index 52a65e2..cf2eccc 100644 --- a/.dist/markdown.js +++ b/.dist/markdown.js @@ -465,6 +465,43 @@ class MarkDown { } } } + if (txt[i] == "[" && !keep) { + let partsFound = 0; + let j = i + 1; + const build = ["["]; + for (; txt[j] !== void 0; j++) { + build.push(txt[j]); + if (partsFound === 0 && txt[j] === "]") { + if (txt[j + 1] === "(" && + txt[j + 2] === "h" && txt[j + 3] === "t" && txt[j + 4] === "t" && txt[j + 5] === "p" && (txt[j + 6] === "s" || txt[j + 6] === ":")) { + partsFound++; + } + else { + break; + } + ; + } + else if (partsFound === 1 && txt[j] === ")") { + partsFound++; + break; + } + } + if (partsFound === 2) { + appendcurrent(); + i = j; + const parts = build.join("").match(/^\[(.+)\]\((https?:.+?)( ('|").+('|"))?\)$/); + if (parts) { + const linkElem = document.createElement("a"); + linkElem.href = parts[2]; + linkElem.textContent = parts[1]; + linkElem.target = "_blank"; + linkElem.rel = "noopener noreferrer"; + linkElem.title = (parts[3] ? parts[3].substring(2, parts[3].length - 1) + "\n\n" : "") + parts[2]; + span.appendChild(linkElem); + continue; + } + } + } current.textContent += txt[i]; } appendcurrent();