Update app.js

This commit is contained in:
chris
2026-06-20 23:29:52 -04:00
committed by GitHub
parent 33a62d17a5
commit 88b9c44c2f
+32 -25
View File
@@ -154,8 +154,6 @@ function setSel(a, b) {
editor.selectionEnd = b; editor.selectionEnd = b;
} }
/* ============ MARKDOWN RENDERER ============ */
function escapeHtml(s) { function escapeHtml(s) {
return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"); return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
} }
@@ -420,8 +418,6 @@ function attachSpoilers() {
}); });
} }
/* ============ TABS ============ */
function setupTabs() { function setupTabs() {
const channels = document.querySelectorAll(".channel[data-tab]"); const channels = document.querySelectorAll(".channel[data-tab]");
const panels = document.querySelectorAll(".tab-panel"); const panels = document.querySelectorAll(".tab-panel");
@@ -448,11 +444,40 @@ function setupTabs() {
const showEditorBtns = tab === "editor" ? "" : "none"; const showEditorBtns = tab === "editor" ? "" : "none";
document.getElementById("copyBtn").style.display = showEditorBtns; document.getElementById("copyBtn").style.display = showEditorBtns;
document.getElementById("clearBtn").style.display = showEditorBtns; document.getElementById("clearBtn").style.display = showEditorBtns;
closeNav();
}); });
}); });
} }
/* ============ TIMESTAMPS TAB ============ */ function openNav() {
document.querySelector(".sidebar").classList.add("open");
document.getElementById("navBackdrop").classList.add("show");
}
function closeNav() {
document.querySelector(".sidebar").classList.remove("open");
document.getElementById("navBackdrop").classList.remove("show");
}
function setupNav() {
document.getElementById("navToggle").addEventListener("click", openNav);
document.getElementById("navBackdrop").addEventListener("click", closeNav);
document.addEventListener("keydown", e => { if (e.key === "Escape") closeNav(); });
}
function setupToolbarScroll() {
const bar = document.getElementById("toolbar");
const left = document.getElementById("tbLeft");
const right = document.getElementById("tbRight");
const update = () => {
const max = bar.scrollWidth - bar.clientWidth - 1;
left.classList.toggle("disabled", bar.scrollLeft <= 0);
right.classList.toggle("disabled", bar.scrollLeft >= max);
};
left.addEventListener("click", () => bar.scrollBy({ left: -160, behavior: "smooth" }));
right.addEventListener("click", () => bar.scrollBy({ left: 160, behavior: "smooth" }));
bar.addEventListener("scroll", update);
window.addEventListener("resize", update);
update();
}
const TS_STYLES = [ const TS_STYLES = [
{ code: "t", name: "Short Time" }, { code: "t", name: "Short Time" },
@@ -521,8 +546,6 @@ function setupTimestamps() {
update(); update();
} }
/* ============ CHEATSHEET TAB ============ */
const CHEAT = [ const CHEAT = [
{ title: "Text Styles", rows: [ { title: "Text Styles", rows: [
["**bold**", "<strong>bold</strong>"], ["**bold**", "<strong>bold</strong>"],
@@ -575,8 +598,6 @@ function buildCheatsheet() {
}); });
} }
/* ============ UTILS ============ */
function copyText(text) { function copyText(text) {
navigator.clipboard.writeText(text).then(() => showToast("Copied to clipboard")).catch(() => { navigator.clipboard.writeText(text).then(() => showToast("Copied to clipboard")).catch(() => {
const ta = document.createElement("textarea"); const ta = document.createElement("textarea");
@@ -604,8 +625,6 @@ function loadState() {
} catch (e) {} } catch (e) {}
} }
/* ============ INIT ============ */
editor.addEventListener("input", render); editor.addEventListener("input", render);
editor.addEventListener("keydown", e => { editor.addEventListener("keydown", e => {
if (e.ctrlKey || e.metaKey) { if (e.ctrlKey || e.metaKey) {
@@ -636,8 +655,6 @@ Format Discord messages **without memorizing symbols**.
> "No more guessing which symbol does what." > "No more guessing which symbol does what."
-# Made with Toolscord`; -# Made with Toolscord`;
/* ============ EMBED BUILDER ============ */
function embedGet(sel) { function embedGet(sel) {
const el = document.querySelector(`[data-embed="${sel}"]`); const el = document.querySelector(`[data-embed="${sel}"]`);
return el ? el.value.trim() : ""; return el ? el.value.trim() : "";
@@ -821,8 +838,6 @@ function setupEmbed() {
}); });
} }
/* ============ SNOWFLAKE DECODER ============ */
const DISCORD_EPOCH = 1420070400000n; const DISCORD_EPOCH = 1420070400000n;
function decodeSnowflake() { function decodeSnowflake() {
@@ -850,8 +865,6 @@ function setupSnowflake() {
decodeSnowflake(); decodeSnowflake();
} }
/* ============ PERMISSIONS CALCULATOR ============ */
const PERMISSIONS = [ const PERMISSIONS = [
["Create Invite", 0], ["Kick Members", 1], ["Ban Members", 2], ["Administrator", 3], ["Create Invite", 0], ["Kick Members", 1], ["Ban Members", 2], ["Administrator", 3],
["Manage Channels", 4], ["Manage Server", 5], ["Add Reactions", 6], ["View Audit Log", 7], ["Manage Channels", 4], ["Manage Server", 5], ["Add Reactions", 6], ["View Audit Log", 7],
@@ -896,8 +909,6 @@ function setupPermissions() {
updatePerms(); updatePerms();
} }
/* ============ COLOR CONVERTER ============ */
const COLOR_PRESETS = [ const COLOR_PRESETS = [
["Blurple", "#5865F2"], ["Green", "#57F287"], ["Yellow", "#FEE75C"], ["Fuchsia", "#EB459E"], ["Blurple", "#5865F2"], ["Green", "#57F287"], ["Yellow", "#FEE75C"], ["Fuchsia", "#EB459E"],
["Red", "#ED4245"], ["White", "#FFFFFF"], ["Black", "#000000"], ["Greyple", "#99AAB5"], ["Red", "#ED4245"], ["White", "#FFFFFF"], ["Black", "#000000"], ["Greyple", "#99AAB5"],
@@ -950,8 +961,6 @@ function setupColors() {
applyColor("#5865F2", "hex"); applyColor("#5865F2", "hex");
} }
/* ============ EMOJI PICKER ============ */
const EMOJIS = [ const EMOJIS = [
["😀", "grinning smile happy"], ["😃", "smile happy"], ["😄", "laugh happy"], ["😁", "grin"], ["😀", "grinning smile happy"], ["😃", "smile happy"], ["😄", "laugh happy"], ["😁", "grin"],
["😆", "laughing lol"], ["😅", "sweat nervous laugh"], ["🤣", "rofl rolling laughing"], ["😂", "joy tears laughing"], ["😆", "laughing lol"], ["😅", "sweat nervous laugh"], ["🤣", "rofl rolling laughing"], ["😂", "joy tears laughing"],
@@ -1039,8 +1048,6 @@ function setupEmoji() {
document.addEventListener("keydown", e => { if (e.key === "Escape" && emojiOpen) toggleEmoji(false); }); document.addEventListener("keydown", e => { if (e.key === "Escape" && emojiOpen) toggleEmoji(false); });
} }
/* ============ WEBHOOK SENDER ============ */
function setWebhookStatus(msg, kind) { function setWebhookStatus(msg, kind) {
const el = document.getElementById("whStatus"); const el = document.getElementById("whStatus");
el.textContent = msg; el.textContent = msg;
@@ -1148,11 +1155,11 @@ function setupWebhook() {
})); }));
} }
/* ============ INIT ============ */
buildToolbar(); buildToolbar();
buildQuickList(); buildQuickList();
setupTabs(); setupTabs();
setupNav();
setupToolbarScroll();
setupTimestamps(); setupTimestamps();
buildCheatsheet(); buildCheatsheet();
setupEmbed(); setupEmbed();