diff --git a/pageUpdater.js b/pageUpdater.js index bb7f521..83e8a9d 100644 --- a/pageUpdater.js +++ b/pageUpdater.js @@ -344,6 +344,15 @@ function converter(html, dynamic = true) { addedHTML += "

No blog posts found...
wait
huh ???
what???????
how ???????????????
WHY ?!
Violet must've fucked up like. REALLY bad.
We're so cooked

" } return addedHTML + }, + "SUBPAGE_JS": () => { + return ` + + + + + + ` } } diff --git a/static/ambience/ambient.js b/static/ambience/ambient.js deleted file mode 100644 index 3f8e12c..0000000 --- a/static/ambience/ambient.js +++ /dev/null @@ -1,32 +0,0 @@ -function loop() { - var date = new Date() - - var hour = date.getHours(); - hour = (hour < 10 ? "0" : "") + hour; - - var min = date.getMinutes(); - min = (min < 10 ? "0" : "") + min; - - var sec = date.getSeconds(); - sec = (sec < 10 ? "0" : "") + sec; - - $("#time").text(hour + ":" + min) - - setTimeout(() => { - loop() - }, 1000) -} - -document.addEventListener("DOMContentLoaded", function() { - loop() -}) - -$(document).on('keypress',function(e) { - if(e.which == 102) { - if ($.fullscreen.isFullScreen()) { - $.fullscreen.exit() - } else { - $("body").fullscreen() - } - } -}); \ No newline at end of file diff --git a/static/ambience/fullscreen.js b/static/ambience/fullscreen.js deleted file mode 100644 index de65877..0000000 --- a/static/ambience/fullscreen.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * jquery.fullscreen v0.6.0 - * https://github.com/private-face/jquery.fullscreen - * - * Copyright (c) 2012–2016 Vladimir Zhuravlev - * Released under the MIT license - * https://github.com/private-face/jquery.fullscreen/blob/master/LICENSE - * - * Date: 2016-08-25 - **/ -(function(global, factory) { - if (typeof define === 'function' && define.amd) { - // AMD - define(['jquery'], function (jQuery) { - return factory(jQuery); - }); - } else if (typeof exports === 'object') { - // CommonJS/Browserify - factory(require('jquery')); - } else { - // Global - factory(global.jQuery); - } -}(this, function($) { - -function defined(a){return"undefined"!=typeof a}function extend(a,b,c){var d=function(){};d.prototype=b.prototype,a.prototype=new d,a.prototype.constructor=a,b.prototype.constructor=b,a._super=b.prototype,c&&$.extend(a.prototype,c)}function native(a,b){var c;"string"==typeof a&&(b=a,a=document);for(var d=0;d37)&&defined(native("fullscreenElement"))&&(!defined(fsEnabled)||fsEnabled===!0),version=$.fn.jquery.split("."),JQ_LT_17=parseInt(version[0])<2&&parseInt(version[1])<7,FullScreenAbstract=function(){this.__options=null,this._fullScreenElement=null,this.__savedStyles={}};FullScreenAbstract.prototype={native:native,_DEFAULT_OPTIONS:{styles:{boxSizing:"border-box",MozBoxSizing:"border-box",WebkitBoxSizing:"border-box"},toggleClass:null},__documentOverflow:"",__htmlOverflow:"",_preventDocumentScroll:function(){this.__documentOverflow=document.body.style.overflow,this.__htmlOverflow=document.documentElement.style.overflow,$(this._fullScreenElement).is("body, html")||$("body, html").css("overflow","hidden")},_allowDocumentScroll:function(){document.body.style.overflow=this.__documentOverflow,document.documentElement.style.overflow=this.__htmlOverflow},_fullScreenChange:function(){this.__options&&(this.isFullScreen()?(this._preventDocumentScroll(),this._triggerEvents()):(this._allowDocumentScroll(),this._revertStyles(),this._triggerEvents(),this._fullScreenElement=null))},_fullScreenError:function(a){this.__options&&(this._revertStyles(),this._fullScreenElement=null,a&&$(document).trigger("fscreenerror",[a]))},_triggerEvents:function(){$(this._fullScreenElement).trigger(this.isFullScreen()?"fscreenopen":"fscreenclose"),$(document).trigger("fscreenchange",[this.isFullScreen(),this._fullScreenElement])},_saveAndApplyStyles:function(){var a=$(this._fullScreenElement);this.__savedStyles={};for(var b in this.__options.styles)this.__savedStyles[b]=this._fullScreenElement.style[b],this._fullScreenElement.style[b]=this.__options.styles[b];a.is("body")&&(document.documentElement.style.overflow=this.__options.styles.overflow),this.__options.toggleClass&&a.addClass(this.__options.toggleClass)},_revertStyles:function(){var a=$(this._fullScreenElement);for(var b in this.__options.styles)this._fullScreenElement.style[b]=this.__savedStyles[b];a.is("body")&&(document.documentElement.style.overflow=this.__savedStyles.overflow),this.__options.toggleClass&&a.removeClass(this.__options.toggleClass)},open:function(a,b){a!==this._fullScreenElement&&(this.isFullScreen()&&this.exit(),this._fullScreenElement=a,this.__options=$.extend(!0,{},this._DEFAULT_OPTIONS,b),this._saveAndApplyStyles())},exit:null,isFullScreen:null,isNativelySupported:function(){return IS_NATIVELY_SUPPORTED}};var FullScreenNative=function(){FullScreenNative._super.constructor.apply(this,arguments),this.exit=$.proxy(native("exitFullscreen"),document),this._DEFAULT_OPTIONS=$.extend(!0,{},this._DEFAULT_OPTIONS,{styles:{width:"100%",height:"100%"}}),$(document).bind(this._prefixedString("fullscreenchange")+" MSFullscreenChange",$.proxy(this._fullScreenChange,this)).bind(this._prefixedString("fullscreenerror")+" MSFullscreenError",$.proxy(this._fullScreenError,this))};extend(FullScreenNative,FullScreenAbstract,{VENDOR_PREFIXES:["","o","moz","webkit"],_prefixedString:function(a){return $.map(this.VENDOR_PREFIXES,function(b){return b+a}).join(" ")},open:function(a,b){FullScreenNative._super.open.apply(this,arguments);var c=native(a,"requestFullscreen");c.call(a)},exit:$.noop,isFullScreen:function(){return null!==native("fullscreenElement")},element:function(){return native("fullscreenElement")}});var FullScreenFallback=function(){FullScreenFallback._super.constructor.apply(this,arguments),this._DEFAULT_OPTIONS=$.extend({},this._DEFAULT_OPTIONS,{styles:{position:"fixed",zIndex:"2147483647",left:0,top:0,bottom:0,right:0}}),this.__delegateKeydownHandler()};extend(FullScreenFallback,FullScreenAbstract,{__isFullScreen:!1,__delegateKeydownHandler:function(){var a=$(document);a.delegate("*","keydown.fullscreen",$.proxy(this.__keydownHandler,this));var b=JQ_LT_17?a.data("events"):$._data(document).events,c=b.keydown;JQ_LT_17?b.live.unshift(b.live.pop()):c.splice(0,0,c.splice(c.delegateCount-1,1)[0])},__keydownHandler:function(a){return!this.isFullScreen()||27!==a.which||(this.exit(),!1)},_revertStyles:function(){FullScreenFallback._super._revertStyles.apply(this,arguments),this._fullScreenElement.offsetHeight},open:function(a){FullScreenFallback._super.open.apply(this,arguments),this.__isFullScreen=!0,this._fullScreenChange()},exit:function(){this.__isFullScreen&&(this.__isFullScreen=!1,this._fullScreenChange())},isFullScreen:function(){return this.__isFullScreen},element:function(){return this.__isFullScreen?this._fullScreenElement:null}}),$.fullscreen=IS_NATIVELY_SUPPORTED?new FullScreenNative:new FullScreenFallback,$.fn.fullscreen=function(a){var b=this[0];return a=$.extend({toggleClass:null,overflow:"hidden"},a),a.styles={overflow:a.overflow},delete a.overflow,b&&$.fullscreen.open(b,a),this}; -//# sourceMappingURL=jquery.fullscreen.min.js.mapreturn $.fullscreen; -})); \ No newline at end of file diff --git a/static/ambience/index.html b/static/ambience/index.html deleted file mode 100644 index 2b58283..0000000 --- a/static/ambience/index.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - Violet's Purgatory Ambient Page - - - - - - - - - - - {WEATHER_MODIFIER} -
-

00:00

-
- {ACTIVITIES} -
-
- - - \ No newline at end of file diff --git a/static/ambience/style.css b/static/ambience/style.css deleted file mode 100644 index cd4159a..0000000 --- a/static/ambience/style.css +++ /dev/null @@ -1,19 +0,0 @@ -body { - background-image: none; - background-color: black; - display: flex; - align-items: center; - margin: auto; - -} - -@media screen and (min-height: 500px) { - html, - body { - height: 100%; - } -} - -#time { - font-size: 5rem; -} \ No newline at end of file diff --git a/static/blog/index.html b/static/blog/index.html index 1a1ef18..3adb6cd 100644 --- a/static/blog/index.html +++ b/static/blog/index.html @@ -4,9 +4,6 @@ - - - diff --git a/static/faq/index.html b/static/faq/index.html index dd72bb5..95d5642 100644 --- a/static/faq/index.html +++ b/static/faq/index.html @@ -5,8 +5,7 @@ - - + {SUBPAGE_JS} diff --git a/static/index.html b/static/index.html index 4a29bf4..409b42d 100644 --- a/static/index.html +++ b/static/index.html @@ -8,8 +8,11 @@ - - + + + + + diff --git a/static/cash.js b/static/js/cash.js similarity index 100% rename from static/cash.js rename to static/js/cash.js diff --git a/static/js/constants.js b/static/js/constants.js new file mode 100644 index 0000000..4fbf4a5 --- /dev/null +++ b/static/js/constants.js @@ -0,0 +1,26 @@ +const discStatuses = { + "online": { + "text": "Online", + "color": "rgb(100, 255, 100)" + }, + "dnd": { + "text": "DND", + "color": "rgb(255, 100, 100)" + }, + "idle": { + "text": "Idle", + "color": "rgb(255, 255, 75)" + }, + "offline": { + "text": "", + "color": "rgb(175, 175, 200)" + } +} + +var teto = false + +var date = new Date() + +if (date.getDay() == 2) { + teto = true +} \ No newline at end of file diff --git a/static/js/lanyardSocket.js b/static/js/lanyardSocket.js new file mode 100644 index 0000000..4237be9 --- /dev/null +++ b/static/js/lanyardSocket.js @@ -0,0 +1,79 @@ +var sock + +var firsttimeDebounce = true + +var lastPong = Date.now() + +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); +} + +function socketeer() { + sock = new WebSocket('wss://api.violets-purgatory.dev') + + sock.addEventListener("open", () => { + ping(30000) + }) + + sock.addEventListener("error", (error) => { + console.log(error) + }) + + sock.addEventListener("close", () => { + console.log("Connection Closed. Attempting Reconnect in 30 seconds.") + $("#apiConnected").text("false") + setTimeout(() => { + socketeer() + }, 30000); + }) + + sock.addEventListener("message", async (data) => { + data = data.data + data = JSON.parse(data) + if (data.op == 4) { + $("#apiConnected").text("true") + globalSpins = data.spins + if (firsttimeDebounce == true) { + firsttimeDebounce = false + $(".globalSpins").innerHTML = globalSpins + 1; + } else { + $(".globalSpins").innerHTML = globalSpins; + } + } else if (data.op == 0) { + var lanyard = data.d + var statusInfo = discStatuses[lanyard.discord_status] + var lastStatus = $(".statusColor") + + if (lastStatus.text() != statusInfo.text) { + lastStatus.text(statusInfo.text) + lastStatus.css("color", statusInfo.color) + + $(".pfp").css("borderColor", statusInfo.color) + } + + // if (lanyard.activities[0] && lanyard.activities[0].type == 4) { + // document.querySelector(".customStatus").innerHTML = `

${lanyard.activities[0].state}

` + // } else { + // document.querySelector(".customStatus").innerHTML = "" + // } + + var discFetch = await (await fetch("/discHTML")).text() + $("#activityHtml").html(discFetch) + } else if (data.op == 3) { + lastPong = Date.now() + } else { + console.log(data) + } + }) +} + +socketeer() \ No newline at end of file diff --git a/static/js/main.js b/static/js/main.js new file mode 100644 index 0000000..ec70b44 --- /dev/null +++ b/static/js/main.js @@ -0,0 +1,7 @@ +window.onbeforeunload = function () { + window.scrollTo(0, 0); +} + +document.addEventListener("DOMContentLoaded", function() { + $("#jsEnabled").text("true") +}) \ No newline at end of file diff --git a/static/js/spin.js b/static/js/spin.js new file mode 100644 index 0000000..7f10511 --- /dev/null +++ b/static/js/spin.js @@ -0,0 +1,102 @@ +const spinSpeed = 30 +var spinFactor = 3 + +var pfp + +var music + +if (teto) { + music = new Audio("/snds/Triple Baka.ogg") +} else { + music = new Audio("/snds/Lotus Waters.ogg") +} + +music.loop = true +music.preservesPitch = false + +var spins = 0 +var lastSent = 0 +var globalSpins = 0 + +var spinning = false + +var spinWaiting = false + +function resetPFP() { + $(".pfp") +} + +function lerp(a, b, t) { + return a * (1 - t) + b * t +} + +function spinLoop() { + spinWaiting = true + setTimeout(() => { + spinWaiting = false + if (spinning) { + // music.volume = 0.5 + if (music.currentTime > 6.5 && teto) { + spinFactor = 0.25 + } else { + spinFactor = 3 + } + if (!teto) { + music.playbackRate = lerp(music.playbackRate, 1, 1/spinSpeed) + music.volume = lerp(music.volume, 0.5, 1/spinSpeed) + } + spins += 1/spinSpeed / spinFactor + if (Math.floor(spins) != lastSent && sock && sock.OPEN) { + $(".globalSpins").text(globalSpins + 1) + lastSent = Math.floor(spins) + // resetPFP() + sock.send(`{"op": 4}`) + if (spins > 1) { + $(".spinnyCount").css("display", "block") + $(".localSpins").html(lastSent); + } + } + } else { + if (!teto) { + music.playbackRate = lerp(music.playbackRate, 0.5, 1/spinSpeed) + music.volume = lerp(music.volume, -0, 3/spinSpeed) + } else { + music.pause() + music.currentTime = 1.5 + } + + spins = lerp(spins, Math.round(spins), 1 / spinSpeed * 3) + } + $(".pfp").css("rotate", (spins * 360) + "deg") + spinLoop() + }, 1/spinSpeed * 1000); +} + +document.addEventListener("DOMContentLoaded", function() { + $("#jsEnabled").text("true") + + pfp = $(".pfp") + + spinLoop() + + pfp.on("mousedown", () => { + // if (!spinWaiting) { + // spinLoop(); + // } + music.play() + + spinning = true + }) + + document.body.onmouseup = () => { + if (music.currentTime != 0) { + // music.currentTime = 0 + // music.pause() + + // whipLash.currentTime = 0 + // whipLash.play() + + spinning = false + } + } +}) \ No newline at end of file diff --git a/static/js/timeFormatter.js b/static/js/timeFormatter.js new file mode 100644 index 0000000..024d509 --- /dev/null +++ b/static/js/timeFormatter.js @@ -0,0 +1,50 @@ +function gameTimeFormatter(seconds) { + seconds = Math.ceil(seconds / 1000) + var minutes = Math.ceil(seconds / 60) + var hours = Math.floor(minutes / 60) + if (seconds <= 60) { + return 'about ' + seconds + ' seconds' + } else if (minutes < 60) { + return `${minutes} Minutes` + } + + return `${hours} hours and ${minutes % 60} minutes` + +} + +function timeFormatter(seconds) { + seconds = Math.ceil(seconds / 1000) + var minutes = Math.floor(seconds / 60) + + if (seconds % 60 < 10) { + return `${minutes}:0${seconds % 60}` + } else { + return `${minutes}:${seconds % 60}` + } +} + + +function secondLoop() { + $(".durationBarFormatter").each((_, item) => { + item = $(item) + item.text(`${timeFormatter((Math.min(Date.now(), item.attr("data-end")) - item.attr("data-start")))}/${timeFormatter((item.attr("data-end") - item.attr("data-start")))}`) + }) + + $(".timeEstimate").each((_, item) => { + item = $(item) + item.text(gameTimeFormatter(Date.now() - item.attr("data-start"))) + }) + + $(".endEstimate").each((_, item) => { + item = $(item) + item.text(timeFormatter((item.attr("data-end") - Date.now()))) + }) + + setTimeout(() => { + secondLoop() + }, 1000); +} + +document.addEventListener("DOMContentLoaded", function() { + secondLoop() +}) \ No newline at end of file diff --git a/static/main.js b/static/main.js deleted file mode 100644 index f5400a5..0000000 --- a/static/main.js +++ /dev/null @@ -1,261 +0,0 @@ -const discStatuses = { - "online": { - "text": "Online", - "color": "rgb(100, 255, 100)" - }, - "dnd": { - "text": "DND", - "color": "rgb(255, 100, 100)" - }, - "idle": { - "text": "Idle", - "color": "rgb(255, 255, 75)" - }, - "offline": { - "text": "", - "color": "rgb(175, 175, 200)" - } -} - -const spinSpeed = 30 -var spinFactor = 3 - -var date = new Date() - -var teto = false - -if (date.getDay() == 2) { - teto = true -} - -var pfp - -var music - -if (teto) { - music = new Audio("/snds/Triple Baka.ogg") -} else { - music = new Audio("/snds/Lotus Waters.ogg") -} - -music.loop = true -music.preservesPitch = false - -var sock - -var spins = 0 -var lastSent = 0 -var globalSpins = 0 - -var spinning = false - -var firsttimeDebounce = true - -var spinWaiting = false - -function resetPFP() { - $(".pfp") -} - -function lerp(a, b, t) { - return a * (1 - t) + b * t -} - -function gameTimeFormatter(seconds) { - seconds = Math.ceil(seconds / 1000) - var minutes = Math.ceil(seconds / 60) - var hours = Math.floor(minutes / 60) - if (seconds <= 60) { - return 'about ' + seconds + ' seconds' - } else if (minutes < 60) { - return `${minutes} Minutes` - } - - return `${hours} hours and ${minutes % 60} minutes` - -} - -function timeFormatter(seconds) { - seconds = Math.ceil(seconds / 1000) - var minutes = Math.floor(seconds / 60) - - if (seconds % 60 < 10) { - return `${minutes}:0${seconds % 60}` - } else { - return `${minutes}:${seconds % 60}` - } -} - -function spinLoop() { - spinWaiting = true - setTimeout(() => { - spinWaiting = false - if (spinning) { - // music.volume = 0.5 - if (music.currentTime > 6.5 && teto) { - spinFactor = 0.25 - } else { - spinFactor = 3 - } - if (!teto) { - music.playbackRate = lerp(music.playbackRate, 1, 1/spinSpeed) - music.volume = lerp(music.volume, 0.5, 1/spinSpeed) - } - spins += 1/spinSpeed / spinFactor - if (Math.floor(spins) != lastSent && sock && sock.OPEN) { - $(".globalSpins").text(globalSpins + 1) - lastSent = Math.floor(spins) - // resetPFP() - sock.send(`{"op": 4}`) - if (spins > 1) { - $(".spinnyCount").css("display", "block") - $(".localSpins").html(lastSent); - } - } - } else { - if (!teto) { - music.playbackRate = lerp(music.playbackRate, 0.5, 1/spinSpeed) - music.volume = lerp(music.volume, -0, 3/spinSpeed) - } else { - music.pause() - music.currentTime = 1.5 - } - - spins = lerp(spins, Math.round(spins), 1 / spinSpeed * 3) - } - $(".pfp").css("rotate", (spins * 360) + "deg") - spinLoop() - }, 1/spinSpeed * 1000); -} - -function secondLoop() { - $(".durationBarFormatter").each((_, item) => { - item = $(item) - item.text(`${timeFormatter((Math.min(Date.now(), item.attr("data-end")) - item.attr("data-start")))}/${timeFormatter((item.attr("data-end") - item.attr("data-start")))}`) - }) - - $(".timeEstimate").each((_, item) => { - item = $(item) - item.text(gameTimeFormatter(Date.now() - item.attr("data-start"))) - }) - - $(".endEstimate").each((_, item) => { - item = $(item) - item.text(timeFormatter((item.attr("data-end") - Date.now()))) - }) - - setTimeout(() => { - secondLoop() - }, 1000); -} - -window.onbeforeunload = function () { - window.scrollTo(0, 0); -} - -document.addEventListener("DOMContentLoaded", function() { - $("#jsEnabled").text("true") - - pfp = $(".pfp") - - spinLoop() - secondLoop() - - pfp.on("mousedown", () => { - // if (!spinWaiting) { - // spinLoop(); - // } - music.play() - - spinning = true - }) - - document.body.onmouseup = () => { - if (music.currentTime != 0) { - // music.currentTime = 0 - // music.pause() - - // whipLash.currentTime = 0 - // whipLash.play() - - spinning = false - } - } - socketeer() -}) - -var lastPong = Date.now() - -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); -} - -function socketeer() { - sock = new WebSocket('wss://api.violets-purgatory.dev') - - sock.addEventListener("open", () => { - ping(30000) - }) - - sock.addEventListener("error", (error) => { - console.log(error) - }) - - sock.addEventListener("close", () => { - console.log("Connection Closed. Attempting Reconnect in 30 seconds.") - $("#apiConnected").text("false") - setTimeout(() => { - socketeer() - }, 30000); - }) - - sock.addEventListener("message", async (data) => { - data = data.data - data = JSON.parse(data) - if (data.op == 4) { - $("#apiConnected").text("true") - globalSpins = data.spins - if (firsttimeDebounce == true) { - firsttimeDebounce = false - $(".globalSpins").innerHTML = globalSpins + 1; - } else { - $(".globalSpins").innerHTML = globalSpins; - } - } else if (data.op == 0) { - var lanyard = data.d - var statusInfo = discStatuses[lanyard.discord_status] - var lastStatus = $(".statusColor") - - if (lastStatus.text() != statusInfo.text) { - lastStatus.text(statusInfo.text) - lastStatus.css("color", statusInfo.color) - - pfp.css("borderColor", statusInfo.color) - - resetPFP() - } - - // if (lanyard.activities[0] && lanyard.activities[0].type == 4) { - // document.querySelector(".customStatus").innerHTML = `

${lanyard.activities[0].state}

` - // } else { - // document.querySelector(".customStatus").innerHTML = "" - // } - - var discFetch = await (await fetch("/discHTML")).text() - $("#activityHtml").html(discFetch) - } else if (data.op == 3) { - lastPong = Date.now() - } else { - console.log(data) - } - }) -} \ No newline at end of file diff --git a/static/socials/index.html b/static/socials/index.html index 5aac04d..69722c3 100644 --- a/static/socials/index.html +++ b/static/socials/index.html @@ -5,8 +5,7 @@ - - + {SUBPAGE_JS} diff --git a/static/stats/index.html b/static/stats/index.html index 84340f5..a311660 100644 --- a/static/stats/index.html +++ b/static/stats/index.html @@ -5,8 +5,7 @@ - - + {SUBPAGE_JS}