MediaWiki:InLoad.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
/**
 * InLoad
 * Created on June 29th, 2010
 *
 * @version 0.2.1 (2012-01-24)
 * @source meta.wikimedia.org/wiki/User:Krinkle/Scripts/InLoad
 * @author Krinkle
 * @license Released in the public domain
 * @tracking [[File:Krinkle InLoad.js]]
 */
/*jslint browser: true */
/*global $,mw*/
mw.loader.using('mediawiki.util', function () {
	"use strict";
	$(document).ready(function ($) {
		var tLoad, tLoadRender;
		tLoad = mw.util.getParamValue('load');
		if (tLoad !== null && tLoad !== '') {
			$.ajax({
				url: mw.util.wikiScript() + '?' + $.param({title: tLoad, action: 'raw' }),
				dataType: 'text',
				success: function (data) {
					$('#wpTextbox1').text(data);
				}
			});
		}
		tLoadRender = mw.util.getParamValue('loadrender');
		if (tLoadRender !== null && tLoadRender !== '') {
			$.ajax({
				url: mw.util.wikiScript() + '?' + $.param({title: tLoadRender, action: 'render' }),
				dataType: 'html',
				success: function (data) {
					$('#wpTextbox1').html($(data).filter('#loadrender').eq(0).text());
				}
			});
		}
	});
});