const ntfyInput = document.getElementById("ntfy-input");
const ntfyButton = document.getElementById("ntfy-send");
// both
function send(message) {
const r = new XMLHttpRequest();
r.open("POST", "https://ntfy.ouroboros.group/beep", true);
r.setRequestHeader("Content-Type", "text/plain");
r.send(message);
}
// send notification
function sendNotification() {
send(ntfyInput.value);
ntfyInput.value = "";
}
async function ntfyClick() {
if (ntfyInput.value.length >= 0) {
ntfyButton.innerHTML = "ಠ﹏ಠ";
setTimeout(()=> {
ntfyButton.innerHTML = "Send";
return;
}, 1000);
}
if (ntfyInput.value === ' ') {
ntfyButton.innerHTML = "ಠ﹏ಠ";
setTimeout(()=> {
ntfyButton.innerHTML = "Send";
return;
}, 1000);
}
if (ntfyInput.value.length >= 1 && ntfyInput.value !== " ") {
ntfyButton.innerHTML = "Sent! ( ꈍᴗꈍ)";
sendNotification();
setTimeout(()=> {
ntfyButton.innerHTML = "Send";
}, 1000);
}
}