MediaWiki:Common.js: Difference between revisions

From Digimon Masters Online Wiki - DMO Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 20: Line 20:
         var useTheme = getCookieValue('usetheme');
         var useTheme = getCookieValue('usetheme');


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

Revision as of 00:29, 7 February 2021

/* 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-orange; 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')",
    });

});