const ntfyMessage = document.getElementById("ntfy-message");
const ntfyTitle = document.getElementById("ntfy-title");
const ntfyAttach = document.getElementById("ntfy-attach");
const ntfyClickAction = document.getElementById("ntfy-click");
const ntfyButton = document.getElementById("ntfy-button");
const optionsCheck = document.getElementById("optionsCheckbox");
const titleCheck = document.getElementById("titleCheckbox");
const attachmentCheck = document.getElementById("attachmentCheckbox");
const clickCheck = document.getElementById("clickCheckbox");
const titleBoxLabel = document.getElementById("titleBoxLabel");
const attachmentBoxLabel = document.getElementById("attachBoxLabel");
const clickBoxLabel = document.getElementById("clickBoxLabel");
const msgPFX = "message: "
// Random placeholder
function getPlaceholder() {
placeholderSelector = Math.floor(Math.random() * 8) + 1;
switch (placeholderSelector) {
case 1:
ntfyMessage.placeholder = `${msgPFX}hi nelle! (。>﹏<。)`;
break;
case 2:
ntfyMessage.placeholder = `${msgPFX}(╹◡╹)凸`;
break;
case 3:
ntfyMessage.placeholder = `${msgPFX}Confession of sin: I dont like SciAdv`;
break;
case 4:
ntfyMessage.placeholder = `${msgPFX}Knock Knock...`;
break;
case 5:
ntfyMessage.placeholder = `${msgPFX}El. Psy. Kongroo.`;
break;
case 6:
ntfyMessage.placeholder = `${msgPFX}the organization is after you.`;
break;
case 7:
ntfyMessage.placeholder =
`${msgPFX}you wouldnt happen to know where an IBN5100 is, would you?`;
break;
case 8:
ntfyMessage.placeholder =
`${msgPFX}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:
ntfyMessage.placeholder = `${msgPFX}time travel?`;
break;
default:
ntfyMessage.placeholder = `${msgPFX}type some words and hit send`;
}
}
// send function
function send(message, title, attachment, click) {
const r = new XMLHttpRequest();
r.open("POST", "https://ntfy.ouroboros.group/beep", true);
r.setRequestHeader("Content-Type", "text/plain");
r.setRequestHeader("Title", title);
r.setRequestHeader("Attach", attachment);
r.setRequestHeader("Click", click);
r.send(message);
}
// send notification
function sendNotification() {
send(ntfyTitle.value, ntfyMessage.value, ntfyAttach.value, ntfyClickAction.value);
ntfyTitle.value = "";
ntfyAttach.value = "";
ntfyClickAction.value = "";
}
// on send button click
async function ntfyClick() {
if (!ntfyMessage.value.replace(/\s/g, "").length) {
ntfyButton.innerHTML = "ಠ﹏ಠ";
setTimeout(() => {
ntfyButton.innerHTML = "Send";
return;
}, 1000);
} else {
ntfyButton.innerHTML = "Sent! ( ꈍᴗꈍ)";
sendNotification();
setTimeout(() => {
ntfyButton.innerHTML = "Send";
}, 1000);
}
}
function toggleOptions() {
if (optionsCheck.checked) {
titleBoxLabel.style.display = "initial";
attachmentBoxLabel.style.display = "initial";
clickBoxLabel.style.display = "initial";
titleCheck.style.display = "initial";
attachmentCheck.style.display = "initial";
clickCheck.style.display = "initial";
}
if (!optionsCheck.checked) {
titleBoxLabel.style.display = "none";
attachmentBoxLabel.style.display = "none";
clickBoxLabel.style.display = "none";
titleCheck.style.display = "none";
attachmentCheck.style.display = "none";
clickCheck.style.display = "none";
}
}
function toggleTitle() {
if (titleCheck.checked) {
ntfyTitle.style.display = "initial"
}
if (!titleCheck.checked) {
ntfyTitle.style.display = "none"
}
}
function toggleAttach() {
if (attachmentCheck.checked) {
ntfyAttach.style.display = "initial"
}
if (!attachmentCheck.checked) {
ntfyAttach.style.display = "none"
}
}
function toggleClick() {
if (clickCheck.checked) {
ntfyClickAction.style.display = "initial"
}
if (!clickCheck.checked) {
ntfyClickAction.style.display = "none"
}
}