User:Krinkle/Scripts/InLoad.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/**
 * 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());
				}
			});
		}
	});
});