aboutsummaryrefslogtreecommitdiff
path: root/old/2/script.js
blob: 125b87c78f1018e2319436c89fd25d0def1fc85b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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();
    }
}