User:Vghfr/EasyTemplates/Easytemplates.js
Appearance
< User:Vghfr | EasyTemplates
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
This user script seems to have a documentation page at User:Vghfr/EasyTemplates/Easytemplates. |
//<nowiki>
const mwUtil = mw.util;
const menuPlainText = [
'Citation',
'Cleanup',
'Copyedit',
'Timing',
'Expand'
];
const menuID = [
'pt-Citation',
'pt-Cleanup',
'pt-Copyedit',
'pt-Timing',
'pt-Expansion'
];
const template =
[
'{{more citations needed}}',
'{{cleanup|reason=',
'{{copy edit}}',
'{{current}}',
'{{Missing information|'
];
//These functions do eventually need to be cleaned up into a single function, if possible.
function citation(){
document.editform.wpTextbox1.value = template[0] + "\n" + document.editform.wpTextbox1.value;
}
function cleanup(){
let reason = window.prompt("Enter the reason for cleanup",'Reason');
document.editform.wpTextbox1.value = template[1] + reason+"}}"+"\n" + document.editform.wpTextbox1.value;
}
function copyedit(){
document.editform.wpTextbox1.value = template[2] + "\n" + document.editform.wpTextbox1.value;
}
function timing(){
document.editform.wpTextbox1.value = template[3] + "\n" + document.editform.wpTextbox1.value;
}
function expand(){
let text = window.prompt("What is the subject that requires expansion?",'Subject');
document.editform.wpTextbox1.value = template[4] + text+"}}"+"\n" + document.editform.wpTextbox1.value;
}
$( document ).ready( function () {
//Initialization code
mw.util.addPortlet('p-easyT', 'EasyTemplates', '#p-cactions');
let menuGenStep = menuPlainText.length-menuPlainText.length;
let length =menuPlainText.length;
while (menuGenStep < length){
//Generates menu, as well as linking to insertion function
mw.util.addPortletLink('p-easyT', "javascript:"+ menuPlainText[menuGenStep].toLowerCase()+"();", menuPlainText[menuGenStep],menuID[menuGenStep]);
menuGenStep++;
}
mw.util.addPortletLink('p-easyT', 'https://en.wikipedia.org/w/index.php?title=User:Vghfr/EasyTemplates/Easytemplates.js', 'Script (dev link)');
});
//</nowiki>