|
|
| Line 1: |
Line 1: |
| //<nowiki> | | //<nowiki> |
| $(function() { | | $(function() { |
| var nighttime = 'on' === mw.storage.get('nightpedia'),
| |
| cssLoaded = nighttime ? lightsOff() : false;
| |
|
| |
|
| mw.util.addPortletLink('p-personal', '#', nighttime ? 'Daypedia' : 'Nightpedia', 'pt-nightpedia', '', 'np', '#pt-watchlist');
| |
|
| |
|
| $('#pt-nightpedia').on('click', function(e) { | | lightsOn(); |
| e.preventDefault();
| | |
| nighttime = !nighttime;
| |
| if (nighttime) {
| |
| lightsOn();
| |
| } else {
| |
| lightsOn();
| |
| }
| |
| });
| |
|
| |
|
| function lightsOn() { | | function lightsOn() { |
| Line 21: |
Line 11: |
| mw.storage.set('nightpedia', 'off'); | | mw.storage.set('nightpedia', 'off'); |
| } | | } |
| function lightsOff() {
| | |
| if(!cssLoaded) {
| |
| $('head').append(mw.loader.load('https://wiki.endmyopia.org/index.php?title=User:Sam.Watson/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> | | //</nowiki> |