มีเดียวิกิ:Gadget-legacy.js

จาก วิกิพจนานุกรม พจนานุกรมเสรี

หมายเหตุ: หลังเผยแพร่ คุณอาจต้องล้างแคชเว็บเบราว์เซอร์ของคุณเพื่อดูการเปลี่ยนแปลง

  • ไฟร์ฟอกซ์ / ซาฟารี: กด Shift ค้างขณะคลิก Reload หรือกด Ctrl-F5 หรือ Ctrl-R (⌘-R บนแมค)
  • กูเกิล โครม: กด Ctrl-Shift-R (⌘-Shift-R บนแมค)
  • อินเทอร์เน็ตเอกซ์พลอเรอร์ และ Edge: กด Ctrl ค้างขณะคลิก Refresh หรือกด Ctrl-F5
  • โอเปร่า: กด Ctrl-F5
// {{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; }");
}