aboutsummaryrefslogtreecommitdiff
path: root/web/script/log_live.ts
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-12-11 01:20:17 +0100
committermetamuffin <metamuffin@disroot.org>2025-12-11 01:20:17 +0100
commit6e5f6d9b9c6fedb4ab80190c156595d321d33bbf (patch)
treeb6c2140e744fc3018ad08975afefad40386ebbc6 /web/script/log_live.ts
parente4f865e9da9d6660399e22a6fbeb5b84a749b07a (diff)
downloadjellything-6e5f6d9b9c6fedb4ab80190c156595d321d33bbf.tar
jellything-6e5f6d9b9c6fedb4ab80190c156595d321d33bbf.tar.bz2
jellything-6e5f6d9b9c6fedb4ab80190c156595d321d33bbf.tar.zst
refactor import plugins part 3
Diffstat (limited to 'web/script/log_live.ts')
-rw-r--r--web/script/log_live.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/web/script/log_live.ts b/web/script/log_live.ts
new file mode 100644
index 0000000..053c110
--- /dev/null
+++ b/web/script/log_live.ts
@@ -0,0 +1,22 @@
+/*
+ This file is part of jellything (https://codeberg.org/metamuffin/jellything)
+ which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
+ Copyright (C) 2025 metamuffin <metamuffin.org>
+*/
+/// <reference lib="dom" />
+globalThis.addEventListener("DOMContentLoaded", () => {
+ if (!document.body.classList.contains("admin_log")) return
+ const log = document.getElementById("log")!
+
+ const warnonly = new URL(globalThis.location.href).searchParams.get("warnonly") == "true"
+ const ws = new WebSocket(`/admin/log?stream&warnonly=${warnonly}&html=true`)
+ ws.onopen = () => console.log("live log connected");
+ ws.onclose = () => console.log("live log disconnected");
+ ws.onerror = e => console.log(`live log ws error: ${e}`);
+
+ ws.onmessage = msg => {
+ log.children[0].children[0].innerHTML += msg.data
+ while (log.children[0].children[0].children.length > 1024)
+ log.children[0].children[0].children[0].remove()
+ }
+})