MediaWiki:InformationToArtwork.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at MediaWiki:InformationToArtwork. |
// <nowiki>
/*
Quick helper script to replace the information template with the artwork template.
Author: [[User:Multichill]], based on [[MediaWiki:Catcheck.js]] by [[User:Lupo]]
License: Quadruple licensed GFDL, GPL, LGPL and Creative Commons Attribution 3.0 (CC-BY-3.0)
Choose whichever license of these you like best :-)
*/
/*jshint curly:false*/
/*global mw:false, $:false*/
$(function() {
'use strict';
if (mw.config.get('wgNamespaceNumber') !== 6 || mw.config.get('wgAction') !== 'edit') {
return;
}
window.InformationToArtwork =
{
run : function ()
{
// Grab the text
var text = document.getElementById ('wpTextbox1');
// No text?
if (!text) return;
// Do the actual replace
text.value = (text.value || "").replace (/\s*\{\{Information\s*\n/i, "\n{{subst:Artwork/subst|subst=subst:\n");
// Set edit summary
var summary = document.getElementById ('wpSummary');
if (!summary) return;
var val = summary.value || "";
summary.value = val + (val ? ' ' : "") + "Replacing [[Template:Information|Information]] with [[Template:Artwork|Artwork]]";
// Are we sure we want to convert?
var convert = confirm('Are you sure you want to convert the Information template to the Artwork template?');
if (!convert) return;
// Autosave the page
document.editform.wpSave.click();
}
};
window.InformationToArtwork.run();
});
// </nowiki>