72 lines
1.9 KiB
JavaScript
72 lines
1.9 KiB
JavaScript
const ntfyInput = document.getElementById("ntfy-input");
|
||
const ntfyButton = document.getElementById("ntfy-send");
|
||
|
||
// Random placeholder
|
||
|
||
function getPlaceholder() {
|
||
placeholderSelector = Math.floor(Math.random() * 8) + 1;
|
||
switch (placeholderSelector) {
|
||
case 1:
|
||
ntfyInput.placeholder = "hi nelle! (。>﹏<。)";
|
||
break;
|
||
case 2:
|
||
ntfyInput.placeholder = "(╹◡╹)凸";
|
||
break;
|
||
case 3:
|
||
ntfyInput.placeholder = "Confession of sin: I dont like SciAdv";
|
||
break;
|
||
case 4:
|
||
ntfyInput.placeholder = "Knock Knock...";
|
||
break;
|
||
case 5:
|
||
ntfyInput.placeholder = "El. Psy. Kongroo.";
|
||
break;
|
||
case 6:
|
||
ntfyInput.placeholder = "the organization is after you.";
|
||
break;
|
||
case 7:
|
||
ntfyInput.placeholder =
|
||
"you wouldnt happen to know where an IBN5100 is, would you?";
|
||
break;
|
||
case 8:
|
||
ntfyInput.placeholder =
|
||
"if you had to choose, between: bacon, unlimited bacon, but no games. or. games. unlimited games, but no games. which would you pick?";
|
||
break;
|
||
case 9:
|
||
ntfyInput.placeholder = "time travel?";
|
||
break;
|
||
default:
|
||
ntfyInput.placeholder = "type some words and hit send";
|
||
}
|
||
}
|
||
|
||
// send function
|
||
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 = "";
|
||
}
|
||
|
||
// on send button click
|
||
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);
|
||
}
|
||
}
|