From 8ead074b9226801e80a069a54fafc9301ec36766 Mon Sep 17 00:00:00 2001 From: limepotato Date: Sat, 6 Jul 2024 16:45:47 -0600 Subject: [PATCH] notifier --- public/css/classes.css | 33 ++++++++++++++++++ public/scripts/ntfy.js | 50 +++++++++++++++++++++++++++ src/layouts/Layout.astro | 1 + src/pages/index.astro | 71 +++++++++++++++++++++++++++++++++++++++ src/pages/site-info.astro | 1 + 5 files changed, 156 insertions(+) create mode 100644 public/scripts/ntfy.js diff --git a/public/css/classes.css b/public/css/classes.css index 65c3b3d..7da4042 100644 --- a/public/css/classes.css +++ b/public/css/classes.css @@ -42,4 +42,37 @@ .small-quote { font-size: smaller; color: #a6adc8; +} + +.ntfy-send::before { + content: "[["; +} + +.ntfy-send::after { + content: "]]"; +} + +.ntfy-box { + margin: 0 1ch; + padding: 1ch 2ch 2ch 2ch; + background: #ffffff13; + border-radius: 10px; +} + +input, +select { + width: 50%; + appearance: none; + outline: none; + font-family: inherit; + background: transparent; + color: inherit; + border-bottom: 1px solid currentColor; + -webkit-box-shadow: 0 0 20px #f5a97f; + -moz-box-shadow: 0 0 20px #f5a97f; + box-shadow: 0 0 20px #f5a97f; +} + +select { + width: unset } \ No newline at end of file diff --git a/public/scripts/ntfy.js b/public/scripts/ntfy.js new file mode 100644 index 0000000..3d747d4 --- /dev/null +++ b/public/scripts/ntfy.js @@ -0,0 +1,50 @@ +// both +function send(message) { + let r = new XMLHttpRequest() + r.open("POST", "https://ntfy.ouroboros.group/beep", true) + r.setRequestHeader("Content-Type", "text/plain") + r.send(message) + } + // send notification + let ntfyInput = document.getElementById("ntfy-input") + function sendNotification() { + if (ntfyInput.value.length <= 0) return + send(ntfyInput.value) + ntfyInput.value = "" + } + ntfyInput.addEventListener("keyup", e => e.keyCode == 13 && send()) + // send praise + let praiseSentence = document.getElementById("pp-sentence"), + praiseA = document.getElementById("pp-a"), + praiseAdj = document.getElementById("pp-adj"), + praiseNoun = document.getElementById("pp-noun"), + praiseAfter = document.getElementById("pp-after") + resetPraise() + praiseAdj.addEventListener("change", updatePraiseA) + praiseSentence.addEventListener("change", () => { + if (praiseSentence.selectedOptions[0].hasAttribute("data-suffix")) praiseAfter.innerText = praiseSentence.selectedOptions[0].attributes["data-suffix"].value + else praiseAfter.innerText = "" + updatePraiseA() + }) + function sendPraise() { + if (praiseAdj.value == "0" || praiseNoun.value == "0") return + text = praiseSentence.selectedOptions[0].innerText + if (text) text += " " + praiseA.innerText + " " + text += praiseAdj.selectedOptions[0].innerText + " " + praiseNoun.selectedOptions[0].innerText + if (praiseAfter.innerText) text += praiseSentence.selectedOptions[0].attributes["data-suffix"].value + send(text) + resetPraise() + } + // praise helpers + function resetPraise() { + praiseSentence.value = "0" + praiseA.innerText = "" + praiseAdj.value = "0" + praiseNoun.value = "0" + praiseAfter.innerText = "" + } + function updatePraiseA() { + if (praiseSentence.value == "0") praiseA.innerText = "" + else if (praiseAdj.selectedOptions[0].hasAttribute("data-mod")) praiseA.innerText = "an" + else praiseA.innerText = "a" + } \ No newline at end of file diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index e134bcd..d90c42d 100755 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -14,5 +14,6 @@ import Footer from "../components/Footer.astro";