MediaWiki:Gadget-TemplateSandbox.js

/* 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.
 * Forked from https://en.wikipedia.org/wiki/User:Jackmcbarn/advancedtemplatesandbox.js

Known issues: This hardcodes contents of messages, rather than fetching them. The span is left as a span, rather than being changed to a fieldset. Tab indexes assume that we're the first thing after "Show changes". If we're not (or if any other code does this trick), tab order will be wrong. Also, it relies on non-integer tab indexes working.

if($('#wpTemplateSandboxPage').attr('type') == 'hidden') { $('#templatesandbox-editform').prepend(' Preview page with this template '); $('#wpTemplateSandboxPage').before(' Page title: ').after('').replaceWith($('#wpTemplateSandboxPage').clone.attr({type: 'text', tabindex: +($('#wpDiff').attr('tabIndex')) + 0.5, size: 60, spellcheck: true, 'data-mw-searchsuggest': '{"wrapAsLink":false}'}).addClass('mw-searchInput')); } if($('#wpTemplateSandboxTemplate').attr('type') == 'hidden') { $('#wpTemplateSandboxTemplate').before(' Template name: ').after(' ').replaceWith($('#wpTemplateSandboxTemplate').clone.attr({type: 'text', tabindex: +($('#wpDiff').attr('tabIndex')) + 0.25, size: 60, spellcheck: true})); }