102 lines
3.9 KiB
JavaScript
102 lines
3.9 KiB
JavaScript
|
function header(index) {
|
||
|
var rh = document.getElementById('randomheader');
|
||
|
var Title = document.getElementById('header').innerHTML;
|
||
|
if(rh != undefined) {
|
||
|
const titles = [
|
||
|
'bruh moment',
|
||
|
'Try reloading!',
|
||
|
'Supports VPNs',
|
||
|
'I use arch btw',
|
||
|
'niceopod v2',
|
||
|
'<span class="rainbowtext">RGB Gaming Webpage</span>',
|
||
|
'Stream deep twisty',
|
||
|
'MySite.html',
|
||
|
'Over Construction',
|
||
|
'Real isopod hours',
|
||
|
'Version 2.0: the Verbose Update',
|
||
|
'depytwisty',
|
||
|
'[object Object]',
|
||
|
'Uses cookies',
|
||
|
'* You found the [Moss]!',
|
||
|
'Minceraft',
|
||
|
'Best viewed with Firefox',
|
||
|
'Isopod gaming',
|
||
|
'Website of some guy',
|
||
|
'your mom',
|
||
|
'Badly programmed',
|
||
|
'<span class="flipped">Upside Down!</span>',
|
||
|
'Fuck crypto',
|
||
|
'Oh, you know ;)',
|
||
|
'gamer (terminal)'
|
||
|
];
|
||
|
if(index < 0 || index >= titles.length) {
|
||
|
index = Math.floor(Math.random() * titles.length);
|
||
|
}
|
||
|
var choice = titles[index];
|
||
|
Title = choice;
|
||
|
document.getElementById('randomheader').innerHTML = choice;
|
||
|
}
|
||
|
if(Title === "Stats") {
|
||
|
Title = `Stats: ${document.getElementsByTagName('tr').length}`;
|
||
|
document.getElementById('header').innerHTML = Title;
|
||
|
}
|
||
|
document.title = Title;
|
||
|
document.getElementById('header').style.animationName = 'happear';
|
||
|
}
|
||
|
function loadCafeStatus() {
|
||
|
statuscontainer = document.getElementById("status");
|
||
|
if(statuscontainer !== null) {
|
||
|
statuscontainer.innerHTML = '<div id="statuscafe"><div id="statuscafe-username"></div><div id="statuscafe-content"></div></div>';
|
||
|
fetch("https://status.cafe/users/niceopod/status.json")
|
||
|
.then( r => r.json() )
|
||
|
.then( r => {
|
||
|
if (!r.content.length) {
|
||
|
document.getElementById("statuscafe-content").innerHTML = "No status yet."
|
||
|
return
|
||
|
}
|
||
|
document.getElementById("statuscafe-username").innerHTML = '<a href="https://status.cafe/users/niceopod" target="_blank">' + r.author + '</a> ' + r.face + ' ' + r.timeAgo
|
||
|
document.getElementById("statuscafe-content").innerHTML = r.content
|
||
|
}
|
||
|
)
|
||
|
}
|
||
|
}
|
||
|
function getUrlVars() {
|
||
|
var vars = {};
|
||
|
var url = window.location.href;
|
||
|
if(window.location.hash !== "") {
|
||
|
url = url.substring(0, url.lastIndexOf('#'));
|
||
|
}
|
||
|
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { //I copied this function from somewhere. I have no idea what this expression is doing. I'm scared of it
|
||
|
vars[key] = value;
|
||
|
});
|
||
|
return vars;
|
||
|
}
|
||
|
function page() {
|
||
|
var preferredTheme = window.localStorage.getItem("theme");
|
||
|
if(preferredTheme == undefined) {
|
||
|
preferredTheme = "default";
|
||
|
}
|
||
|
document.getElementById("theme").href = `themes/${preferredTheme}/style.css`;
|
||
|
|
||
|
document.getElementById("pretheme").remove();
|
||
|
|
||
|
var currentPage = getUrlVars()['page'];
|
||
|
if(currentPage == undefined) { currentPage = 'home'; }
|
||
|
|
||
|
if(currentPage.indexOf('#') > -1) {
|
||
|
currentPage = currentPage.substring(0, currentPage.lastIndexOf('#'));
|
||
|
}
|
||
|
|
||
|
fetch(`pages/${currentPage}.html`)
|
||
|
.then(response => response.text())
|
||
|
.then(data => { document.getElementById('centercolumn').innerHTML = data; if(document.getElementById('404') !== null) { window.location.replace('not_found.html'); } header(-69); loadCafeStatus(); scrollToHash();});
|
||
|
}
|
||
|
function switchTheme (theme) {
|
||
|
document.getElementById("theme").href = `themes/${theme}/style.css`;
|
||
|
window.localStorage.setItem("theme", theme);
|
||
|
}
|
||
|
function scrollToHash() {
|
||
|
if(window.location.hash !== "") {
|
||
|
document.getElementById(window.location.hash.substring(1)).scrollIntoView();
|
||
|
}
|
||
|
}
|