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> | ||
$(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- | $('#pt-nightpedia').on('click', function(e) { | ||
e.preventDefault(); | e.preventDefault(); | ||
nighttime = !nighttime; | |||
$html. | if (nighttime) { | ||
mw.storage.set( | lightsOff(); | ||
} else { | |||
lightsOn(); | |||
} | |||
} | }); | ||
} );/ | |||
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> | |||