diff options
| author | Hannah Isopod <me@bathynomus.xyz> | 2025-05-10 03:03:58 -0600 |
|---|---|---|
| committer | Hannah Isopod <me@bathynomus.xyz> | 2025-05-10 03:03:58 -0600 |
| commit | eb61c1bae2ffad114e17393d91d86fb00d7ac8cd (patch) | |
| tree | 4f997d73e0843dab760e5d988679a1a86b76f5da /old/2/script.js | |
| parent | 4b9500ddeedbea21f80f41dfe4149cf3bf9be4c3 (diff) | |
Initialer commit
Just remade the repo because I don't *need* need a comprehensive source history for my personal website and this is easier than getting filter-repo to work good
Diffstat (limited to 'old/2/script.js')
| -rw-r--r-- | old/2/script.js | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/old/2/script.js b/old/2/script.js new file mode 100644 index 0000000..125b87c --- /dev/null +++ b/old/2/script.js @@ -0,0 +1,102 @@ +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(); + } +}
\ No newline at end of file |
