MediaWiki:Common.js

From Digimon Masters Online Wiki - DMO Wiki
Revision as of 00:17, 7 February 2021 by Mave (talk | contribs)
Jump to navigation Jump to search

Note: After saving, 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.
/* Any JavaScript here will be loaded for all users on every page load. */


function getCookieValue(a) {
    var b = document.cookie.match('(^|;)\\s*' + a + '\\s*=\\s*([^;]+)');

    return b ? b.pop() : '';
}

$(function () {

    $("#p-navigation .body ul")
        .append('<li><a href="https://twitter.com/DMOWiki" target="_blank"><img src="https://dmowiki.com/images/9/92/Twitter_Icon.png" title="DMO Wiki at Twitter" alt="Twitter" /> @DMOWiki</a></li>')
        .append('<li><a href="/" class="js-toggle-dark-mode">Toggle dark mode</a></li>')
    ;


    $('.js-toggle-dark-mode').on('click', function (e) {
        e.preventDefault();
        var useTheme = getCookieValue('usetheme');

        var cookieValue = "usetheme=dark; expires=Sun, 25 Aug 2030 00:00:00 GMT";
        if (useTheme.length > 0) {
            cookieValue = "usetheme=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
        }
        document.cookie = cookieValue + "; secure";

        window.location.reload();
    });

    $("h3#p-navigation-label").css({
        'display': 'block',
        'padding': '0px 1.75em 0.25em 0.25em',
        'border': 'medium none',
    });

    $("#mw-panel div.portal div.body").css({
        "margin": "0px 0px 0px 1.25em",
        "background-image": "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIwAAAABCAAAAAAphRnkAAAAJ0lEQVQIW7XFsQEAIAyAMPD/b7uLWz8wS5youFW1UREfiIpH1Q2VBz7fGPS1dOGeAAAAAElFTkSuQmCC')",
    });

});