MEOW BUTTON POWERUP

This commit is contained in:
nelle 2024-09-15 18:11:38 -06:00
parent 36754b0535
commit e105d40452
9 changed files with 61 additions and 56 deletions

27
public/scripts/api.js Normal file
View file

@ -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 = "<span>sleeping...</span>";
console.warn("TIMED OUT")
}
if (response.status === 200) {
meowButton.disabled=false;
meowButton.innerHTML = "<span>meow</span>";
console.warn("NOT TIMED OUT")
}
}

View file

@ -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. // loads all the functions to be loaded on load, pretty simple, it loads shit on load.
function onLoad() { function onLoad() {
jsEnabled(); jsEnabled();
@ -5,6 +8,7 @@ function onLoad() {
redirect(); redirect();
checkBoxes(); checkBoxes();
getPlaceholder(); getPlaceholder();
getMeowTimeout(timeOutEndpoint);
} }
// 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.
@ -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 = "<span>sleeping for 30 minutes...</span>";
sendMeow(meowEndpoint);
}

View file

@ -1,6 +1,5 @@
// i deeply apologize for the horrors within... // i deeply apologize for the horrors within...
const ntfyEndpoint = "https://ntfy.ouroboros.group/beep"; const ntfyEndpoint = "https://ntfy.ouroboros.group/beep";
const meowEndpoint = "https://ntfy.ouroboros.group/meow";
// text fields and buttons // text fields and buttons
const ntfyMessage = document.getElementById("ntfy-message"); const ntfyMessage = document.getElementById("ntfy-message");
@ -8,7 +7,6 @@ const ntfyTitle = document.getElementById("ntfy-title");
const ntfyAttach = document.getElementById("ntfy-attach"); const ntfyAttach = document.getElementById("ntfy-attach");
const ntfyClickAction = document.getElementById("ntfy-click"); const ntfyClickAction = document.getElementById("ntfy-click");
const ntfyButton = document.getElementById("ntfy-button"); const ntfyButton = document.getElementById("ntfy-button");
const meowButton = document.getElementById("meow-button");
// options checkboxes // options checkboxes
const optionsCheck = document.getElementById("optionsCheckbox"); const optionsCheck = document.getElementById("optionsCheckbox");
@ -20,7 +18,6 @@ const clickCheck = document.getElementById("clickCheckbox");
const titleBoxLabel = document.getElementById("titleBoxLabel"); const titleBoxLabel = document.getElementById("titleBoxLabel");
const attachmentBoxLabel = document.getElementById("attachBoxLabel"); const attachmentBoxLabel = document.getElementById("attachBoxLabel");
const clickBoxLabel = document.getElementById("clickBoxLabel"); const clickBoxLabel = document.getElementById("clickBoxLabel");
const justMeowed = document.getElementById("justMeowed");
// Options storage variables // Options storage variables
const optionsEnabled = sessionStorage.getItem("optionsEnabled"); 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 = "<span>Sent! :3</span>";
sendNone(meowEndpoint, "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 // on send button click
async function ntfyClick() { async function ntfyClick() {
if (!ntfyMessage.value.replace(/\s/g, "").length) { if (!ntfyMessage.value.replace(/\s/g, "").length) {

View file

@ -10,9 +10,6 @@ const phonewaveSound = new Audio(
const startLeapSound = new Audio( const startLeapSound = new Audio(
"/assets/sounds/sciadv/phonewave/begin-leap.ogg" "/assets/sounds/sciadv/phonewave/begin-leap.ogg"
); );
const stopLeapSound = new Audio(
"/assets/sounds/sciadv/phonewave/SE11_03.ogg"
);
// Sound effects // Sound effects
function PlaySound(soundobj) { function PlaySound(soundobj) {

View file

@ -1,10 +1,12 @@
--- ---
import LastFM from "./widgets/lastfm.astro"; import LastFM from "./widgets/lastfm.astro";
import NTFY from "./widgets/ntfy.astro"; import NTFY from "./widgets/ntfy.astro";
import MEOW from "./widgets/meow.astro";
--- ---
<section class="content center" id="silly-widgets" > <section class="content center" id="silly-widgets" >
<h2>silly widgets <a href="#silly-widgets"><i class="nf nf-oct-link"></i></span></a></h2> <h2>silly widgets <a href="#silly-widgets"><i class="nf nf-oct-link"></i></span></a></h2>
<LastFM /> <LastFM />
<NTFY /> <NTFY />
<MEOW />
</section> </section>

View file

@ -0,0 +1,11 @@
<div class="funny-meow">
<br>
<small>press this button to make me meow on the fediverse, <br>you can POST to <span class="glitch">https://nelle.observer/meow</span>. there is a timeout of 33 minutes globally.</small>
<button
class="custom-btn btn-1"
style="width: 45%; margin-top: 4%; margin-bottom: 4%;"
onclick="meowClick()"
id="meow-button">
<span>meow</span>
</button>
</div>

View file

@ -42,13 +42,6 @@
<input type="checkbox" id="clickCheckbox" name="clickCheckbox" onchange="toggleClick()" style="display: none;"/> <input type="checkbox" id="clickCheckbox" name="clickCheckbox" onchange="toggleClick()" style="display: none;"/>
<label id="clickBoxLabel" style="display: none;" for="clickCheckbox">Add Click Action?</label> <label id="clickBoxLabel" style="display: none;" for="clickCheckbox">Add Click Action?</label>
</div> </div>
<button
class="custom-btn btn-1"
style="width: 75%; margin-top: 4%"
onclick="meowClick()"
id="meow-button">
<span>meow</span>
</button>
</fieldset> </fieldset>
</div> </div>
<br> <br>

View file

@ -1,8 +1,9 @@
<!-- optimized -->
<!-- unoptimized --> <!-- unoptimized -->
<script is:inline src="/scripts/sound.js"></script> <script is:inline src="/scripts/sound.js"></script>
<script is:inline src="/scripts/sga.js"></script> <script is:inline src="/scripts/sga.js"></script>
<script is:inline src="/scripts/ntfy.js"></script> <script is:inline src="/scripts/ntfy.js"></script>
<script is:inline src="/scripts/api.js"></script>
<!-- ALWAYS LAST -->
<script is:inline src="/scripts/main.js"></script> <script is:inline src="/scripts/main.js"></script>

View file

@ -26,7 +26,7 @@ const { title } = Astro.props;
<NormalScripts /> <NormalScripts />
<audio <audio
id="clickSound" id="clickSound"
src="/assets/sounds/ui/zapsplat_multimedia_button_click_004_68776.mp3"> src="/assets/sounds/ui/zapsplat_button_click_2.mp3">
</audio> </audio>
</body> </body>
</html> </html>