MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
imported>Hb1290
No edit summary
imported>Hb1290
No edit summary
Line 344: Line 344:
     proportionalResize();
     proportionalResize();
});
});
/*
//<nowiki>
* WikimediaUI Dark Mode
$(function() {
*
    var nighttime = 'on' === mw.storage.get('nightpedia'),
* Original authors:
        cssLoaded = nighttime ? lightsOff() : false;
* - Volker E. (Wikimedia Foundation Product Design)
* - Alex Hollender  (Wikimedia Foundation Product Design)
* - Ed Sanders
* - MusikAnimal
*
* Last updated: 2020-04-24
*/


// Load dependencies (remove when loading through ResourceLoader).
    mw.util.addPortletLink('p-personal', '#', nighttime ? 'Daypedia' : 'Nightpedia', 'pt-nightpedia', '', 'np', '#pt-watchlist');
mw.loader.load( 'https://en.wikipedia.org/w/index.php?title=User:Volker_E._(WMF)/dark-mode.css&action=raw&ctype=text/css', 'text/css' );
// User has dark color scheme preference set in operating system.
if ( window.matchMedia( '( prefers-color-scheme: dark )' ).matches || mw.storage.get( 'client-dark-mode-toggle' ) === '1' ) {
document.documentElement.className = 'client-dark-mode';
}
mw.util.addPortletLink( 'p-personal', '#', 'Dark mode', 'pt-darkmode', '', 'np', '#pt-watchlist' );


     $( '#pt-darkmode' ).on( 'click', function( e ) {
     $('#pt-nightpedia').on('click', function(e) {
    var $html = $( 'html' );
         e.preventDefault();
         e.preventDefault();
          
         nighttime = !nighttime;
         $html.toggleClass( 'client-dark-mode' );
        if (nighttime) {
         mw.storage.set(
            lightsOff();
'client-dark-mode-toggle',
        } else {
String( Number( $html.hasClass( 'client-dark-mode' ) ) )
            lightsOn();
);
        }
     } );
    });
} );/* DO NOT ADD CODE BELOW THIS LINE */
 
    function lightsOn() {
         $('html').removeClass('nighttime');
        $('#pt-nightpedia a').text('Nightpedia');
         mw.storage.set('nightpedia', 'off');
    }
    function lightsOff() {
        if(!cssLoaded) {
            $('head').append(mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:MusikAnimal/nightpedia.css&action=raw&ctype=text/css', 'text/css'));
        }
        $('html').addClass('nighttime');
        $('#pt-nightpedia a').text('Daypedia');
        mw.storage.set('nightpedia', 'on');
        return true;
     }
});
//</nowiki>
Anonymous user

Navigation menu