ಮೀಡಿಯವಿಕಿ:Gadget-prefill-template-preview.js
ಗೋಚರ
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)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* 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]);
}
});
}