MediaWiki:Gadget-legacy.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Note – after saving, you may have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

See also: Special:Gadgets.


// {{documentation}}
/** LegacyScripts **/
/*jshint maxerr:1048576, strict:true, undef:true, latedef:true, es5:true */
/*global mw, jQuery, importScript, importScriptURI, $, ObjectStorage */
/* ==importScript== */
/**
 * do NOT use this function
 **/
var importScriptFromWikibits = window.importScript;
window.importScript = function (page, wiki, oldid) {
	if (!wiki && !oldid) return importScriptFromWikibits(page);
	
	mw.log.warn("importScript called with more than one argument. This is deprecated and may be unreliable. Please use mw.loader.load directly");
	var url = (wiki ? encodeURIComponent(wiki) : mw.config.get('wgScript')) + '?title=' +
		mw.util.wikiUrlencode(page) +
		(oldid ? '&oldid=' + encodeURIComponent(oldid) : '') +
		'&action=raw&ctype=text/javascript';
	return mw.loader.load(url);
};

/* ==Cookies== */

window.setCookie = function setCookie(cookieName, cookieValue) {
	/*global escape */
	mw.log.warn("deprecated function setCookie called; use jQuery.cookie instead");
	var today = new Date();
	var expire = new Date();
	var nDays = 30;
	expire.setTime(today.getTime() + (3600000 * 24 * nDays));
	document.cookie = cookieName + "=" + escape(cookieValue) +
		";path=/" +
		";expires=" + expire.toGMTString();
};

window.getCookie = function getCookie(cookieName) {
	/*global unescape */
	mw.log.warn("deprecated function getCookie called; use jQuery.cookie instead");
	
	cookieName = String(cookieName);
	var start = document.cookie.indexOf(cookieName + "=");
	if (start === -1) return "";
	var len = start + cookieName.length + 1;
	if ((!start) && (cookieName !== document.cookie.substring(0, cookieName.length)))
		return "";
	var end = document.cookie.indexOf(";", len);
	if (end === -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len, end));
};

/*  ==[[MediaWiki:Youhavenewmessages]] to display differently for non-newbies with JS than for others= */
/* Suspected unresponsive page culprit: see the GP (Nov. 2010, "Blocking script execution on each page") */
if (mw.config.get('wgUserGroups') && mw.config.get('wgUserGroups').indexOf("autoconfirmed") == -1) {
	mw.util.addCSS(".visible-to-anons { display: inline; }");
}

/* ==Import [[User:Yair rand/newentrywiz.js]]== */
jQuery(document).ready(function () {
	if (document.getElementById('necplaceholder')) {
		importScript('User:Yair rand/newentrywiz.js');
	}
});