From 697dfdab1821ddb7983df28520536c194a734af0 Mon Sep 17 00:00:00 2001 From: pancakes Date: Tue, 3 Dec 2024 20:08:32 +1000 Subject: [PATCH] Add character count to ntfy message --- src/routes/+page.svelte | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index b205181..8a61a44 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -4,6 +4,17 @@ import links from "../data/links.json"; const pages = getPages(); + + function updateCharCount(_) { + const message = document.getElementById("ntfy-message").value; + const el = document.getElementById("ntfy-char-count"); + + if (message.length >= 15 && message.length <= 128) + el.setAttribute("style", "color: var(--success);"); + else el.setAttribute("style", "color: var(--error);"); + + el.innerText = 128 - message.length; + }
@@ -343,18 +354,24 @@

+ +