diff --git a/public/scripts/api.js b/public/scripts/api.js new file mode 100644 index 0000000..060467a --- /dev/null +++ b/public/scripts/api.js @@ -0,0 +1,27 @@ +function handleErrors(response) { + if (!response.ok) { + throw Error(response.statusText); + } + return response; +} + +function sendMeow(endpoint) { + const request = new XMLHttpRequest(); + request.open("POST", endpoint); + request.send("superSecret=null"); + console.warn(request.response.text); +} + +async function getMeowTimeout(endpoint) { +const response = await fetch(endpoint) +if (response.status === 500) { + meowButton.disabled=true; + meowButton.innerHTML = "sleeping..."; + console.warn("TIMED OUT") +} +if (response.status === 200) { + meowButton.disabled=false; + meowButton.innerHTML = "meow"; + console.warn("NOT TIMED OUT") +} + } diff --git a/public/scripts/main.js b/public/scripts/main.js index bc18609..228265b 100644 --- a/public/scripts/main.js +++ b/public/scripts/main.js @@ -1,3 +1,6 @@ +const meowEndpoint = "https://nelle.observer/meow"; +const timeOutEndpoint = "https://nelle.observer/meowTimeout"; + // loads all the functions to be loaded on load, pretty simple, it loads shit on load. function onLoad() { jsEnabled(); @@ -5,6 +8,7 @@ function onLoad() { redirect(); checkBoxes(); getPlaceholder(); + getMeowTimeout(timeOutEndpoint); } // if javascript is enabled, this script will load, enabling all site elements that use javascript, by default these are all hidden. @@ -52,3 +56,16 @@ function redirect() { } } } + +// meow +const meowButton = document.getElementById("meow-button"); +const justMeowed = document.getElementById("justMeowed"); + +let timeout = 1; + +// on send button click +async function meowClick() { + meowButton.disabled=true; + meowButton.innerHTML = "sleeping for 30 minutes..."; + sendMeow(meowEndpoint); +} diff --git a/public/scripts/ntfy.js b/public/scripts/ntfy.js index 78e218b..ef93634 100644 --- a/public/scripts/ntfy.js +++ b/public/scripts/ntfy.js @@ -1,6 +1,5 @@ // i deeply apologize for the horrors within... const ntfyEndpoint = "https://ntfy.ouroboros.group/beep"; -const meowEndpoint = "https://ntfy.ouroboros.group/meow"; // text fields and buttons const ntfyMessage = document.getElementById("ntfy-message"); @@ -8,7 +7,6 @@ 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"); // options checkboxes const optionsCheck = document.getElementById("optionsCheckbox"); @@ -20,7 +18,6 @@ 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"); // Options storage variables const optionsEnabled = sessionStorage.getItem("optionsEnabled"); @@ -159,46 +156,6 @@ function toggleClick() { } } -// on send button click -async function meowClick() { meowButton.disabled=true; - setTimeout('meowButton.disabled=false;',11000); - meowButton.innerHTML = "Sent! :3"; - sendNone(meowEndpoint, "meow"); - setTimeout(() => { - meowButton.innerHTML = "cooldown 10s"; - setTimeout(() => { - meowButton.innerHTML = "cooldown 9s"; - setTimeout(() => { - meowButton.innerHTML = "cooldown 8s"; - setTimeout(() => { - meowButton.innerHTML = "cooldown 7s"; - setTimeout(() => { - meowButton.innerHTML = "cooldown 6s"; - setTimeout(() => { - meowButton.innerHTML = "cooldown 5s"; - setTimeout(() => { - meowButton.innerHTML = "cooldown 4s"; - setTimeout(() => { - meowButton.innerHTML = "cooldown 3s"; - setTimeout(() => { - meowButton.innerHTML = "cooldown 2s"; - setTimeout(() => { - meowButton.innerHTML = "cooldown 1s"; - setTimeout(() => { - meowButton.innerHTML = "meow"; - }, 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) { diff --git a/public/scripts/sound.js b/public/scripts/sound.js index 914563c..d3c8ce5 100644 --- a/public/scripts/sound.js +++ b/public/scripts/sound.js @@ -10,9 +10,6 @@ const phonewaveSound = new Audio( const startLeapSound = new Audio( "/assets/sounds/sciadv/phonewave/begin-leap.ogg" ); -const stopLeapSound = new Audio( - "/assets/sounds/sciadv/phonewave/SE11_03.ogg" -); // Sound effects function PlaySound(soundobj) { diff --git a/src/components/main-page/silly-widgets.astro b/src/components/main-page/silly-widgets.astro index 6cae1b9..e395a67 100644 --- a/src/components/main-page/silly-widgets.astro +++ b/src/components/main-page/silly-widgets.astro @@ -1,10 +1,12 @@ --- import LastFM from "./widgets/lastfm.astro"; import NTFY from "./widgets/ntfy.astro"; +import MEOW from "./widgets/meow.astro"; ---

silly widgets

+
diff --git a/src/components/main-page/widgets/meow.astro b/src/components/main-page/widgets/meow.astro new file mode 100644 index 0000000..1f3a5dd --- /dev/null +++ b/src/components/main-page/widgets/meow.astro @@ -0,0 +1,11 @@ +
+
+ press this button to make me meow on the fediverse,
you can POST to https://nelle.observer/meow. there is a timeout of 33 minutes globally.
+ +
\ No newline at end of file diff --git a/src/components/main-page/widgets/ntfy.astro b/src/components/main-page/widgets/ntfy.astro index b61df55..2081311 100644 --- a/src/components/main-page/widgets/ntfy.astro +++ b/src/components/main-page/widgets/ntfy.astro @@ -42,13 +42,6 @@ -
diff --git a/src/components/scripts/normal-scripts.astro b/src/components/scripts/normal-scripts.astro index a8459f2..079cf1c 100644 --- a/src/components/scripts/normal-scripts.astro +++ b/src/components/scripts/normal-scripts.astro @@ -1,8 +1,9 @@ - - + + + \ No newline at end of file diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 988f816..ddf3eb7 100755 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -26,7 +26,7 @@ const { title } = Astro.props;