//<nowiki>
(function() {
var nighttime, cssLoaded;
mw.loader.using('jquery.jStorage', function() {
mw.util.addPortletLink("p-personal", "#", "Nightpedia", "pt-nightpedia", "", "np", "#pt-watchlist");
var nighttime = $.jStorage.get("nightpediaTime") === "nighttime",
cssLoaded = nighttime ? lightsOff() : false;
});
$("#pt-nightpedia").on("click", function(e) {
e.preventDefault();
nighttime = !nighttime;
if(nighttime) {
lightsOff();
} else {
lightsOn();
}
});
function lightsOn() {
$("body").removeClass("nighttime");
$("#pt-nightpedia a").text("Nightpedia");
$.jStorage.set("nightpediaTime", "daytime");
}
function lightsOff() {
if(!cssLoaded) importStylesheet("User:MusikAnimal/nightpedia.css");
$("body").addClass("nighttime");
$("#pt-nightpedia a").text("Daypedia");
$.jStorage.set("nightpediaTime", "nighttime");
return true;
}
}());
//</nowiki>
|