User:Slate/common.js

/* Directly from http://wow.gamepedia.com/MediaWiki:Common.js */ function setStoredValue(key, value, expiredays) { if (typeof(localStorage) == "undefined") { var exdate = new Date; exdate.setDate(exdate.getDate + (expiredays ? expiredays : 30)); document.cookie = key + "=" + escape(value) + ";expires=" + exdate.toGMTString; } else { try { localStorage[key] = value; } catch (e) { // Usually QUOTA_EXCEEDED_ERR }	} }

function getStoredValue(key, defaultValue) { if (typeof(localStorage) == "undefined") { if (document.cookie && document.cookie.length) { var varr = document.cookie.match("(?:^|;)\\s*" + key + "=([^;]*)"); if (varr.length == 2) return varr[1]; }		return defaultValue; }	return localStorage[key] == null ? defaultValue : localStorage[key]; }

// AJAX RC var ajaxPages = {"Special:RecentChanges" : 1}; var ajaxRCOverride = false; var rcRefresh = 120000;

function ajaxRC { appTo = $(".firstHeading"); appTo.append(' Auto-refresh:   '); $("#autoRefreshToggle").click(function {		setStoredValue("ajaxRC", $("#autoRefreshToggle").is(":checked") ? "on" : "off")		loadRCData	}); $("#autoRefreshProgress").hide; if (getStoredValue("ajaxRC") == "on" || ajaxRCOverride) { $("#autoRefreshToggle").attr("checked", "checked"); setTimeout("loadRCData;", rcRefresh); } } function handleAutocollapse(root) { var $ct = root.find(".mw-collapsible"); var $es = $ct.filter(".mw-autocollapse").not($ct.first).not(".mw-collapsed, .mw-uncollapsed, .mw-expanded"); $es.filter(function {		var link = $(this).find(".mw-collapsible-toggle a");		if (link.length) link.first.click;		return !link.length;	}).toggleClass("mw-collapsed mw-autocollapse"); } function loadRCData { if (!$("#autoRefreshToggle").is(":checked")) return; $('#autoRefreshProgress').show $(article).load(location.href + " "+article+" > *", function (data) {		handleAutocollapse($(article));		$(article + " .mw-collapsible").makeCollapsible;		$('#autoRefreshProgress').hide		if ($("#autoRefreshToggle").is(":checked")) setTimeout("loadRCData;", rcRefresh);	}); }

$(function {	article = "#bodyContent";	if (wgPageName && ajaxPages.hasOwnProperty(wgPageName) && !$("#autoRefreshToggle").length) ajaxRC; });