MediaWiki:Gadget-prefill-template-preview.js

/* MediaWiki:Gadget-prefill-template-preview.js */ /* * Fill in the "preview with" field for commonly edited templates and modules * that should be previewed before saving. Typically used for data stored in * the Template: or Module: namespace, rather than actual code. * */

// Maps edited wikipage name to the wikipage name it should be previewed with. const pagemap = { 'Template:New_texts/data/2021.json': 'Wikisource:Works/2021', 'Module:PotM/data': 'Module:PotM/test' }; const page = mw.config.get('wgPageName'); // Current page const $sandbox = $('#wpTemplateSandboxPage input'); // The "Preview with" textbox

if (page in pagemap) { $( => {		// Only when the box is empty (don't overwrite the user's own thing)		if (!$sandbox.val) {			$sandbox.val(pagemap[page]);		}	}); }