×
Create a new article
Write your page title here:
We currently have 6,031 articles on Polcompball Anarchy Wiki. Type your article name above or create one of the articles listed here!



    Polcompball Anarchy Wiki

    User:TheGhostOfInky/common.js

    Note: After publishing, you may have to bypass your browser's cache to see the changes.

    • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
    • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
    • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
    • Opera: Press Ctrl-F5.
    function divMod(a, b) {
        return [Math.floor(a / b), a % b];
    }
    
    function parseDelta(delta) {
        var deltaMinutes = divMod(delta, 60);
        var deltaHours = divMod(deltaMinutes[0], 60);
        var deltaDays = divMod(deltaHours[0], 24);
        var deltaWeeks = divMod(deltaDays[0], 7);
    
        var weeks = deltaWeeks[0].toFixed() + "w";
        var days = deltaWeeks[1].toFixed() + "d";
        var hours = deltaDays[1].toFixed() + "h";
        var minutes = deltaHours[1].toFixed() + "m";
        var seconds = deltaMinutes[1].toFixed() + "s";
    
        return [weeks, days, hours, minutes, seconds].join(", ");
    }
    
    function createTimer(timerElm) {
        var timestamp = timerElm.querySelector(".timestamp").textContent;
        var endTime = new Date(timestamp.trim());
        if(isNaN(endTime.valueOf())){
            return;
        }
        var timerBody = timerElm.querySelector(".timer-body");
    
        var timerfunction = function () {
            var now = new Date();
            if (now > endTime) {
                timerBody.textContent = "Expired Timer";
                clearInterval(interval);
                return;
            }
            var deltaSeconds = (endTime - now) / 1000;
            timerBody.textContent = parseDelta(deltaSeconds);
        }
        var interval = setInterval(timerfunction, 1000);
    }
    
    var timers = document.getElementsByClassName("timer-wrapper");
    for (var i = 0; i < timers.length; i++) {
        createTimer(timers[i]);
    }
    
    /*function createItem(id, href, shortRef, title) {
        var titleTag = title ? '" title="' + title : '';
        var elm = '<li id="t-' + id + '" class="mw-list-item"><a href="/wiki/';
        elm += href + titleTag + '">' + shortRef + '</a></li>';
        return elm;
    }
    
    function addTools() {
        var pagesToAdd = [
            {
                "id": "userpage",
                "href": "User:",
                "shortRef": "User page"
            },
            {
                "id": "contributions",
                "href": "Special:Contributions/",
                "title": "A list of contributions by this user",
                "shortRef": "User contributions"
            },
            {
                "id": "log",
                "href": "Special:Log/",
                "shortRef": "Logs"
            },
            {
                "id": "blockip",
                "href": "Special:Block/",
                "shortRef": "Block user"
            },
            {
                "id": "userrights",
                "href": "Special:UserRights/",
                "shortRef": "Change user groups"
            }
        ];
        var currentPage = new window.mw.Title(mw.config.values.wgPageName);
    
        if (currentPage.namespace === 200) {
            var toolsList = $(".cosmos-tools-list > ul:nth-child(1)");
    
            var userName = currentPage.title.split("/")[0];
    
            var elms = "";
    
            for (var i = 0; i < pagesToAdd.length; i++) {
                var page = pagesToAdd[i];
                var href = page.href + userName;
                elms += createItem(page.id, href, page.shortRef, page.title);
            }
            $(toolsList).children("li:nth-child(2)").after(elms);
        }
    }
    
    function viewHistory() {
        $(".cosmos-recentChanges-page").each(function () {
            var link = $(this).children("a:nth-child(1)").attr("href");
            var page = link.split("/wiki/")[1];
            var href = "/w/index.php?title=" + page + "&action=history";
            $(this).append(
                '<a style="margin-left: 6px; color: #C12576" href="' + href + '">Revisions</a>'
            );
        });
    }
    
    window.addEventListener("load", function () {
        addTools();
        viewHistory();
    });
    
    $("textarea").on("keydown", function (e) {
        if (e.which === 9) {
            e.preventDefault();
            var start = this.selectionStart,
                end = this.selectionEnd, spaces = "    ";
    
            this.value = this.value.substring(0, start) +
                spaces + this.value.substring(end);
    
            this.selectionStart = this.selectionEnd = start + 4;
        }
    });
    */
    
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.

    Recent changes

  • Yelvia • 9 minutes ago
  • Zzankara • 11 minutes ago
  • Zzankara • 16 minutes ago
  • 2005Remember • 37 minutes ago
  • Cookies help us deliver our services. By using our services, you agree to our use of cookies.