meow button
This commit is contained in:
parent
1d5b10b22c
commit
a147f28723
2 changed files with 143 additions and 102 deletions
|
@ -1,11 +1,12 @@
|
|||
// i deeply apologize for the horrors within...
|
||||
const ntfyEndpoint = "https://ntfy.ouroboros.group/beep"
|
||||
const ntfyEndpoint = "https://ntfy.ouroboros.group/beep";
|
||||
|
||||
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 meowButton = document.getElementById("meow-button");
|
||||
|
||||
const optionsCheck = document.getElementById("optionsCheckbox");
|
||||
const titleCheck = document.getElementById("titleCheckbox");
|
||||
|
@ -15,6 +16,7 @@ const clickCheck = document.getElementById("clickCheckbox");
|
|||
const titleBoxLabel = document.getElementById("titleBoxLabel");
|
||||
const attachmentBoxLabel = document.getElementById("attachBoxLabel");
|
||||
const clickBoxLabel = document.getElementById("clickBoxLabel");
|
||||
const justMeowed = document.getElementById("justMeowed");
|
||||
|
||||
const optionsEnabled = sessionStorage.getItem("optionsEnabled");
|
||||
const titleEnabled = sessionStorage.getItem("optionsEnabled");
|
||||
|
@ -26,25 +28,6 @@ const msgPFX = "message: ";
|
|||
const attachPFX = "attachment: ";
|
||||
const clickPFX = "click-action: ";
|
||||
|
||||
function checkBoxes() {
|
||||
if (optionsEnabled) {
|
||||
optionsCheck.checked = true;
|
||||
toggleOptions();
|
||||
}
|
||||
if (titleEnabled) {
|
||||
titleCheck.checked = true;
|
||||
toggleTitle();
|
||||
}
|
||||
if (attachmentEnabled) {
|
||||
attachmentCheck.checked = true;
|
||||
toggleAttach();
|
||||
}
|
||||
if (clickEnabled) {
|
||||
clickCheck.checked = true;
|
||||
toggleClick();
|
||||
}
|
||||
}
|
||||
|
||||
// Random placeholder
|
||||
function getPlaceholder() {
|
||||
placeholderSelector = Math.floor(Math.random() * 8) + 1;
|
||||
|
@ -89,11 +72,135 @@ function getPlaceholder() {
|
|||
ntfyTitle.placeholder = `${titlePFX}title the message for some reason?`;
|
||||
ntfyMessage.placeholder = `${msgPFX}type some words and hit send.`;
|
||||
ntfyAttach.placeholder = `${attachPFX}https://http.cat/images/100.jpg`;
|
||||
ntfyClickAction.placeholder = `${clickPFX}https://www.youtube.com/watch?v=dQw4w9WgXcQ`
|
||||
ntfyClickAction.placeholder = `${clickPFX}https://www.youtube.com/watch?v=dQw4w9WgXcQ`;
|
||||
}
|
||||
}
|
||||
|
||||
// send functions
|
||||
function checkBoxes() {
|
||||
if (optionsEnabled) {
|
||||
optionsCheck.checked = true;
|
||||
toggleOptions();
|
||||
}
|
||||
if (titleEnabled) {
|
||||
titleCheck.checked = true;
|
||||
toggleTitle();
|
||||
}
|
||||
if (attachmentEnabled) {
|
||||
attachmentCheck.checked = true;
|
||||
toggleAttach();
|
||||
}
|
||||
if (clickEnabled) {
|
||||
clickCheck.checked = true;
|
||||
toggleClick();
|
||||
}
|
||||
}
|
||||
function toggleOptions() {
|
||||
if (optionsCheck.checked) {
|
||||
sessionStorage.setItem("optionsEnabled", 1);
|
||||
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) {
|
||||
sessionStorage.removeItem("optionsEnabled");
|
||||
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) {
|
||||
sessionStorage.setItem("titleEnabled", 1);
|
||||
ntfyTitle.style.display = "initial";
|
||||
}
|
||||
if (!titleCheck.checked) {
|
||||
sessionStorage.removeItem("titleEnabled");
|
||||
ntfyTitle.style.display = "none";
|
||||
}
|
||||
}
|
||||
function toggleAttach() {
|
||||
if (attachmentCheck.checked) {
|
||||
sessionStorage.setItem("attachmentEnabled", 1);
|
||||
ntfyAttach.style.display = "initial";
|
||||
}
|
||||
if (!attachmentCheck.checked) {
|
||||
sessionStorage.removeItem("attachmentEnabled");
|
||||
ntfyAttach.style.display = "none";
|
||||
}
|
||||
}
|
||||
function toggleClick() {
|
||||
if (clickCheck.checked) {
|
||||
sessionStorage.setItem("clickEnabled", 1);
|
||||
ntfyClickAction.style.display = "initial";
|
||||
}
|
||||
if (!clickCheck.checked) {
|
||||
sessionStorage.removeItem("clickEnabled");
|
||||
ntfyClickAction.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
// on send button click
|
||||
async function meowClick() { meowButton.disabled=true;
|
||||
setTimeout('meowButton.disabled=false;',11000);
|
||||
meowButton.innerHTML = "<span>Sent! :3</span>";
|
||||
sendNone("meow");
|
||||
setTimeout(() => {
|
||||
meowButton.innerHTML = "<span>cooldown 10s</span>";
|
||||
setTimeout(() => {
|
||||
meowButton.innerHTML = "<span>cooldown 9s</span>";
|
||||
setTimeout(() => {
|
||||
meowButton.innerHTML = "<span>cooldown 8s</span>";
|
||||
setTimeout(() => {
|
||||
meowButton.innerHTML = "<span>cooldown 7s</span>";
|
||||
setTimeout(() => {
|
||||
meowButton.innerHTML = "<span>cooldown 6s</span>";
|
||||
setTimeout(() => {
|
||||
meowButton.innerHTML = "<span>cooldown 5s</span>";
|
||||
setTimeout(() => {
|
||||
meowButton.innerHTML = "<span>cooldown 4s</span>";
|
||||
setTimeout(() => {
|
||||
meowButton.innerHTML = "<span>cooldown 3s</span>";
|
||||
setTimeout(() => {
|
||||
meowButton.innerHTML = "<span>cooldown 2s</span>";
|
||||
setTimeout(() => {
|
||||
meowButton.innerHTML = "<span>cooldown 1s</span>";
|
||||
setTimeout(() => {
|
||||
meowButton.innerHTML = "<span>meow</span>";
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
// on send button click
|
||||
async function ntfyClick() {
|
||||
if (!ntfyMessage.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);
|
||||
}
|
||||
}
|
||||
|
||||
// only message
|
||||
function sendNone(message) {
|
||||
|
@ -102,7 +209,6 @@ function sendNone(message) {
|
|||
r.setRequestHeader("Content-Type", "text/plain");
|
||||
r.send(message);
|
||||
}
|
||||
|
||||
// send all
|
||||
function sendAll(title, message, attachment, click) {
|
||||
const r = new XMLHttpRequest();
|
||||
|
@ -113,7 +219,6 @@ function sendAll(title, message, attachment, click) {
|
|||
r.setRequestHeader("Click", click);
|
||||
r.send(message);
|
||||
}
|
||||
|
||||
// send title only
|
||||
function sendTitle(title, message) {
|
||||
const r = new XMLHttpRequest();
|
||||
|
@ -122,7 +227,6 @@ function sendTitle(title, message) {
|
|||
r.setRequestHeader("Title", title);
|
||||
r.send(message);
|
||||
}
|
||||
|
||||
// send attachment only
|
||||
function sendAttach(message, attachment) {
|
||||
const r = new XMLHttpRequest();
|
||||
|
@ -131,7 +235,6 @@ function sendAttach(message, attachment) {
|
|||
r.setRequestHeader("Attach", attachment);
|
||||
r.send(message);
|
||||
}
|
||||
|
||||
// send click only
|
||||
function sendClick(message, click) {
|
||||
const r = new XMLHttpRequest();
|
||||
|
@ -140,7 +243,6 @@ function sendClick(message, click) {
|
|||
r.setRequestHeader("Click", click);
|
||||
r.send(message);
|
||||
}
|
||||
|
||||
// send Title & Attachment
|
||||
function sendTitleAttach(title, message, attachment) {
|
||||
const r = new XMLHttpRequest();
|
||||
|
@ -150,7 +252,6 @@ function sendTitleAttach(title, message, attachment) {
|
|||
r.setRequestHeader("Attach", attachment);
|
||||
r.send(message);
|
||||
}
|
||||
|
||||
// send Title & Click
|
||||
function sendTitleClick(title, message, click) {
|
||||
const r = new XMLHttpRequest();
|
||||
|
@ -160,7 +261,6 @@ function sendTitleClick(title, message, click) {
|
|||
r.setRequestHeader("Click", click);
|
||||
r.send(message);
|
||||
}
|
||||
|
||||
// send Attach & Click
|
||||
function sendAttachClick(message, attachment, click) {
|
||||
const r = new XMLHttpRequest();
|
||||
|
@ -214,7 +314,12 @@ function sendNotification() {
|
|||
}
|
||||
// all three
|
||||
if (titleEnabled && attachmentEnabled && clickEnabled) {
|
||||
sendAll(ntfyTitle.value, ntfyMessage.value, ntfyAttach.value, ntfyClickAction.value);
|
||||
sendAll(
|
||||
ntfyTitle.value,
|
||||
ntfyMessage.value,
|
||||
ntfyAttach.value,
|
||||
ntfyClickAction.value
|
||||
);
|
||||
ntfyTitle.value = "";
|
||||
ntfyMessage.value = "";
|
||||
ntfyAttach.value = "";
|
||||
|
@ -226,75 +331,3 @@ function sendNotification() {
|
|||
ntfyMessage.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
// on send button click
|
||||
async function ntfyClick() {
|
||||
if (!ntfyMessage.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);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleOptions() {
|
||||
if (optionsCheck.checked) {
|
||||
sessionStorage.setItem("optionsEnabled", 1);
|
||||
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) {
|
||||
sessionStorage.removeItem("optionsEnabled");
|
||||
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) {
|
||||
sessionStorage.setItem("titleEnabled", 1);
|
||||
ntfyTitle.style.display = "initial";
|
||||
}
|
||||
if (!titleCheck.checked) {
|
||||
sessionStorage.removeItem("titleEnabled");
|
||||
ntfyTitle.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
function toggleAttach() {
|
||||
if (attachmentCheck.checked) {
|
||||
sessionStorage.setItem("attachmentEnabled", 1);
|
||||
ntfyAttach.style.display = "initial";
|
||||
}
|
||||
if (!attachmentCheck.checked) {
|
||||
sessionStorage.removeItem("attachmentEnabled");
|
||||
ntfyAttach.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
function toggleClick() {
|
||||
if (clickCheck.checked) {
|
||||
sessionStorage.setItem("clickEnabled", 1);
|
||||
ntfyClickAction.style.display = "initial";
|
||||
}
|
||||
if (!clickCheck.checked) {
|
||||
sessionStorage.removeItem("clickEnabled");
|
||||
ntfyClickAction.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
id="ntfy-button">
|
||||
<span>Send</span>
|
||||
</button>
|
||||
<br>
|
||||
<!-- OPTIONS BOXES -->
|
||||
<fieldset style="margin-left: 35%; margin-right: 35%; margin-bottom: -4%; margin-top: 2%;">
|
||||
<div>
|
||||
|
@ -40,6 +41,13 @@
|
|||
<input type="checkbox" id="clickCheckbox" name="clickCheckbox" onchange="toggleClick()" style="display: none;"/>
|
||||
<label id="clickBoxLabel" style="display: none;" for="clickCheckbox">Add Click Action?</label>
|
||||
</div>
|
||||
<button
|
||||
class="custom-btn btn-1"
|
||||
style="width: 75%; margin-top: 4%"
|
||||
onclick="meowClick()"
|
||||
id="meow-button">
|
||||
<span>meow</span>
|
||||
</button>
|
||||
</fieldset>
|
||||
<br>
|
||||
<br>
|
||||
|
|
Loading…
Reference in a new issue