40 lines
1 KiB
JavaScript
40 lines
1 KiB
JavaScript
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 = "<span>ಠ﹏ಠ</span>";
|
|
setTimeout(()=> {
|
|
ntfyButton.innerHTML = "<span>Send</span>";
|
|
return;
|
|
}, 1000);
|
|
}
|
|
if (ntfyInput.value === ' ') {
|
|
ntfyButton.innerHTML = "<span>ಠ﹏ಠ</span>";
|
|
setTimeout(()=> {
|
|
ntfyButton.innerHTML = "<span>Send</span>";
|
|
return;
|
|
}, 1000);
|
|
}
|
|
if (ntfyInput.value.length >= 1 && ntfyInput.value !== " ") {
|
|
ntfyButton.innerHTML = "<span>Sent! ( ꈍᴗꈍ)</span>";
|
|
sendNotification();
|
|
setTimeout(()=> {
|
|
ntfyButton.innerHTML = "<span>Send</span>";
|
|
}, 1000);
|
|
}
|
|
}
|