Jump to content

User:Jackmcbarn/advancedtemplatesandbox.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Jackmcbarn (talk | contribs) at 02:51, 13 December 2013 (Created page with '/* Enables TemplateSandbox on all pages, and allows previewing with a template other than the current page being edited (e.g. preview as Template:Foo when actual...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/*
Enables TemplateSandbox on all pages, and allows previewing with a template other than the current page being edited (e.g. preview as Template:Foo when actually editing Template:Foo/sandbox)
To use, add the following line to [[Special:MyPage/common.js]]:
importScript('User:Jackmcbarn/advancedtemplatesandbox.js'); // Linkback: [[User:Jackmcbarn/advancedtemplatesandbox.js]]
The linkback allows easier tracking of who uses this script.
*/

(function() { // Begin wrapper to keep variables out of global scope

var editform = $('#templatesandbox-editform');
if(editform.is("fieldset"))
{
	// The full form is already loaded; just add the template name option
$('#wpTemplateSandboxTemplate').before("<span class=\"mw-templatesandbox-template\" id=\"wpTemplateSandboxTemplateLabel\"><label for=\"wpTemplateSandboxTemplate\">Template name:</label></span> ").after("<br />").replaceWith($('#wpTemplateSandboxTemplate').clone().attr({type: 'text', tabindex: $('#wpTemplateSandboxPage').attr('tabindex') - 0.5, size: 60, spellcheck: true}));
} else {
	// Only a skeleton loaded; reinitialize the whole form
	// XXX TODO
}

})(); // End wrapper to keep variables out of global scope