api.violets-purgatory.dev/static/main.js

76 lines
1.7 KiB
JavaScript
Raw Normal View History

2024-04-18 23:50:10 -05:00
var catsOnMars = new Audio("/snds/cats on mars.mp3")
var whipLash = new Audio("/snds/johnny-test-whip-crack.mp3")
catsOnMars.loop = true
2024-04-19 09:31:26 -05:00
var spins = 1
2024-04-20 12:56:37 -05:00
var globalSpins = 0
2024-04-19 09:31:26 -05:00
2024-04-20 12:24:46 -05:00
var spinWaiting = false
2024-04-19 09:31:26 -05:00
2024-04-20 12:24:46 -05:00
function spinLoop() {
spinWaiting = true
2024-04-19 09:31:26 -05:00
setTimeout(() => {
2024-04-20 12:24:46 -05:00
spinWaiting = false
var pfp = document.querySelector(".pfp")
if (!catsOnMars.paused) {
2024-04-20 12:56:37 -05:00
if (spins > 1) {
document.querySelector(".spinnyCount").style.display = "block"
document.querySelector(".localSpins").innerHTML = Math.ceil(spins - 1);
document.querySelector(".globalSpins").innerHTML = Math.ceil(spins - 1) + globalSpins;
}
2024-04-20 12:24:46 -05:00
spins += 0.5
spinLoop()
}
2024-04-19 09:31:26 -05:00
}, 1000);
}
2024-04-13 00:08:16 -05:00
window.onbeforeunload = function () {
window.scrollTo(0, 0);
2024-04-12 23:37:21 -05:00
}
2024-04-13 00:08:16 -05:00
window.onload = function () {
window.scrollTo(0, 0);
2024-04-18 23:50:10 -05:00
var pfp = document.querySelector(".pfp")
pfp.addEventListener("mousedown", () => {
2024-04-20 12:24:46 -05:00
if (!spinWaiting) {
spinLoop();
}
2024-04-18 23:50:10 -05:00
catsOnMars.play()
pfp.style.animationName = "spinny"
2024-04-20 12:56:37 -05:00
pfp.style.scale = "1.1"
2024-04-18 23:50:10 -05:00
})
document.body.onmouseup = () => {
if (catsOnMars.currentTime != 0) {
catsOnMars.currentTime = 0
catsOnMars.pause()
whipLash.currentTime = 0
whipLash.play()
pfp.style.animationName = "unset"
pfp.style.scale = "1"
}
}
2024-04-20 15:39:25 -05:00
socketeer()
2024-04-13 00:08:16 -05:00
}
2024-04-20 13:03:54 -05:00
var lastPong = Date.now()
2024-04-13 00:08:16 -05:00
function socketeer() {
2024-04-20 15:39:25 -05:00
var sock = new WebSocket('wss://api.violets-purgatory.dev')
2024-04-13 00:08:16 -05:00
2024-04-20 13:18:01 -05:00
sock.onmessage = (event) => {
console.log(event.data)
2024-04-13 00:08:16 -05:00
}
2024-04-20 15:39:25 -05:00
sock.addEventListener("open", () => {
console.log("AAAA")
})
}