Global Spinner
This commit is contained in:
parent
fb85cdf770
commit
17327706f5
3 changed files with 51 additions and 13 deletions
|
@ -117,7 +117,7 @@ function converter(html, query) {
|
|||
|
||||
module.exports = {
|
||||
getActivities: function () {
|
||||
return activityToHTML.activitiesToHTML(lanyardData, cachedImages)
|
||||
return minify.minify(activityToHTML.activitiesToHTML(lanyardData, cachedImages))
|
||||
},
|
||||
|
||||
middleWare: function (req, res, next) {
|
||||
|
@ -218,7 +218,7 @@ function socketeer() {
|
|||
console.log("Connection Closed. Attempting Reconnect in 30 seconds.")
|
||||
setTimeout(() => {
|
||||
socketeer()
|
||||
}, 3000);
|
||||
}, 30000);
|
||||
})
|
||||
|
||||
function ping(dur) {
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<p class="spinnyCount" style="display: none;">You have spun Violet <span class="localSpins">4</span> times!<br>
|
||||
Everyone has spun Violet <span class="globalSpins">3603250</span> times!</p>
|
||||
Everyone has spun Violet <span class="globalSpins">2</span> times!</p>
|
||||
<hr>
|
||||
<div>
|
||||
<p style="padding: 10px;">Hi! I'm Violet, a 15 year old web and game developer. I make server-sided dynamic websites, with no Javascript required! I'm currently making games in the Godot Engine, and my dynamic sites in NodeJS.</p>
|
||||
|
|
|
@ -2,6 +2,8 @@ var catsOnMars = new Audio("/snds/cats on mars.mp3")
|
|||
var whipLash = new Audio("/snds/johnny-test-whip-crack.mp3")
|
||||
catsOnMars.loop = true
|
||||
|
||||
var sock
|
||||
|
||||
var spins = 1
|
||||
var globalSpins = 0
|
||||
|
||||
|
@ -16,9 +18,12 @@ function spinLoop() {
|
|||
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;
|
||||
}
|
||||
spins += 0.5
|
||||
if (Math.round(spins) == spins && sock && sock.OPEN) {
|
||||
sock.send(`{"op": 4}`)
|
||||
console.log("Spin Sent!")
|
||||
}
|
||||
spinLoop()
|
||||
}
|
||||
}, 1000);
|
||||
|
@ -62,15 +67,48 @@ window.onload = function () {
|
|||
var lastPong = Date.now()
|
||||
|
||||
function socketeer() {
|
||||
var sock = new WebSocket('wss://api.violets-purgatory.dev')
|
||||
|
||||
sock.onmessage = (event) => {
|
||||
console.log(event.data)
|
||||
}
|
||||
sock = new WebSocket('wss://api.violets-purgatory.dev')
|
||||
|
||||
sock.addEventListener("open", () => {
|
||||
console.log("AAAA")
|
||||
ping(30000)
|
||||
})
|
||||
|
||||
sock.addEventListener("error", (error) => {
|
||||
console.log(error)
|
||||
})
|
||||
|
||||
sock.addEventListener("close", () => {
|
||||
console.log("Connection Closed. Attempting Reconnect in 30 seconds.")
|
||||
setTimeout(() => {
|
||||
socketeer()
|
||||
}, 30000);
|
||||
})
|
||||
|
||||
function ping(dur) {
|
||||
sock.send(JSON.stringify({
|
||||
op: 3
|
||||
}))
|
||||
setTimeout(() => {
|
||||
ping(dur)
|
||||
if (Date.now() - lastPong > 120000) {
|
||||
sock.close()
|
||||
console.log("Max duration since last pong exceeded- Closing socket.")
|
||||
}
|
||||
}, dur);
|
||||
}
|
||||
|
||||
|
||||
sock.addEventListener("message", async(data) => {
|
||||
data = data.data
|
||||
data = JSON.parse(data)
|
||||
if (data.op == 4) {
|
||||
globalSpins = data.spins
|
||||
document.querySelector(".globalSpins").innerHTML = globalSpins;
|
||||
} else if (data.op == 0) {
|
||||
var discFetch = await (await fetch("/discHTML")).text()
|
||||
document.querySelector("#activityHTML").innerHTML = discFetch
|
||||
} else {
|
||||
console.log(data)
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue