33 lines
847 B
JavaScript
33 lines
847 B
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.replace(/\s/g, '').length) {
|
|
ntfyButton.innerHTML = "<span>ಠ﹏ಠ</span>";
|
|
setTimeout(() => {
|
|
ntfyButton.innerHTML = "<span>Send</span>";
|
|
return;
|
|
}, 1000);
|
|
}
|
|
else {
|
|
ntfyButton.innerHTML = "<span>Sent! ( ꈍᴗꈍ)</span>";
|
|
sendNotification();
|
|
setTimeout(() => {
|
|
ntfyButton.innerHTML = "<span>Send</span>";
|
|
}, 1000);
|
|
}
|
|
}
|