bye bye posting buttons

This commit is contained in:
nelle 2024-12-30 14:19:31 -07:00
parent b4c92cd739
commit 6a856e7367
4 changed files with 2 additions and 126 deletions

View file

@ -1,55 +0,0 @@
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 === 423) {
meowButton.disabled = true;
meowButton.innerHTML = "<span>sleeping...</span>";
console.warn("MEOW TIMED OUT");
}
if (response.status === 100) {
meowButton.disabled = false;
meowButton.innerHTML = "<span>meow</span>";
console.warn("MEOW NOT TIMED OUT");
}
}
async function getBeepTimeout(endpoint) {
const response = await fetch(endpoint);
if (response.status === 423) {
beepButton.disabled = true;
beepButton.innerHTML = "<span>sleeping...</span>";
console.warn("BEEP TIMED OUT");
}
if (response.status === 100) {
beepButton.disabled = false;
beepButton.innerHTML = "<span>meow</span>";
console.warn("BEEP NOT TIMED OUT");
}
}
async function getKaomojiTimeout(endpoint) {
const response = await fetch(endpoint);
if (response.status === 423) {
kaomojiButton.disabled = true;
kaomojiButton.innerHTML = "<span>sleeping...</span>";
console.warn("KAOMOJI TIMED OUT");
}
if (response.status === 100) {
kaomojiButton.disabled = false;
kaomojiButton.innerHTML = "<span>meow</span>";
console.warn("KAOMOJI NOT TIMED OUT");
}
}

View file

@ -1,13 +1,9 @@
const meowEndpoint = "https://nelle.observer/api/meow";
const beepEndpoint = "https://nelle.observer/api/beep";
const kaomojiEndpoint = "https://nelle.observer/api/kaomoji";
const badgeGray = document.getElementById("badgeGray"); const badgeGray = document.getElementById("badgeGray");
const badgeGreen = document.getElementById("badgeGreen"); const badgeGreen = document.getElementById("badgeGreen");
const badgeOrange = document.getElementById("badgeOrange"); const badgeOrange = document.getElementById("badgeOrange");
var colorBool = Math.random() < 0.5; const colorBool = Math.random() < 0.5;
var is_root = location.pathname === "/"; const is_root = location.pathname === "/";
// loads all the functions to be loaded on load, pretty simple, it loads shit on load. // loads all the functions to be loaded on load, pretty simple, it loads shit on load.
function onLoad() { function onLoad() {
@ -17,9 +13,6 @@ function onLoad() {
redirect(); redirect();
checkBoxes(); checkBoxes();
getPlaceholder(); getPlaceholder();
getMeowTimeout(meowEndpoint);
getBeepTimeout(beepEndpoint);
getKaomojiTimeout(beepEndpoint);
} }
// if javascript is enabled, this script will load, enabling all site elements that use javascript, by default these are all hidden. // if javascript is enabled, this script will load, enabling all site elements that use javascript, by default these are all hidden.
@ -75,32 +68,6 @@ function redirect() {
} }
} }
// meow
const meowButton = document.getElementById("meow-button");
const beepButton = document.getElementById("beep-button");
const kaomojiButton = document.getElementById("kaomoji-button");
// on send meow button click
async function meowClick() {
meowButton.disabled = true;
meowButton.innerHTML = "<span>sleeping...</span>";
sendMeow(meowEndpoint);
}
// on send beep button click
async function beepClick() {
beepButton.disabled = true;
beepButton.innerHTML = "<span>sleeping...</span>";
sendMeow(beepEndpoint);
}
// on send kaomoji button click
async function kaomojiClick() {
kaomojiButton.disabled = true;
kaomojiButton.innerHTML = "<span>sleeping...</span>";
sendMeow(kaomojiEndpoint);
}
// Show/Hide Info Boxes // Show/Hide Info Boxes
const posterInfoButton = document.getElementById("poster-info-button"); const posterInfoButton = document.getElementById("poster-info-button");
const posterInfo = document.getElementById("poster-info"); const posterInfo = document.getElementById("poster-info");

View file

@ -8,5 +8,4 @@ import MEOW from "./widgets/meow.astro";
<h2>silly widgets <a href="#silly-widgets"><i class="nf nf-oct-link"></i></a></h2> <h2>silly widgets <a href="#silly-widgets"><i class="nf nf-oct-link"></i></a></h2>
<LastFM /> <LastFM />
<NTFY /> <NTFY />
<!--<MEOW />-->
</section> </section>

View file

@ -1,35 +0,0 @@
<div class="funny-meow">
<br>
<hr>
<h3>meow/beep/etc. </h3>
<p>press the buttons bellow to make me meow/beep or post other random things on the fediverse,
there is a global timeout of anywhere between 10 and 180 minutes, and a separate timer for each button. if it says its sleeping, come back and try again later!</p>
<button
class="custom-btn btn-1 beep-buttons"
onclick="meowClick()"
id="meow-button">
<span>meow</span>
</button>
<button
class="custom-btn btn-1 beep-buttons"
onclick="beepClick()"
id="beep-button">
<span>beep</span>
</button>
<button
class="custom-btn btn-1 beep-buttons"
onclick="kaomojiClick()"
id="kaomoji-button">
<span>( ꈍᴗꈍ)</span>
</button>
<div id="poster-info" style="display: none;">
<br>you can POST to <span class="glitch">https://nelle.observer/api/meow</span> or <span class="glitch">https://nelle.observer/api/beep</span> or <span class="glitch">https://nelle.observer/api/kaomoji</span>
respectively, and GET at the same endpoints to check the status of the timer.
</div>
<br>
<a onclick="showPosterInfo()"><span id="poster-info-button" class="glitch" style="cursor: pointer;">[show more info]</span></a>
</div>