User:Alexis Jazz/Factotum/modules/FileTemplates.js

//Factotum module to insert common file templates

if (mw.config.get('wgNamespaceNumber')==6){

if ( typeof window.FTTModules == 'undefined' ) { window.FTTModules=[]; }

window.FTTModules.push({'load':['afterOpenForm'],'afterOpenFormFunc':function(){

FTT.MD.fileTemplates = {};

FTT.MD.fileTemplates.int = FTT.loadedModulesInt;

window.FTTModules[FTT.MD.fileTemplates.int].extraUI = new OO.ui.DropdownInputWidget({label:'File templates',options:[

{data:'',label:'File templates'},

{data:'{{subst:tmlogoc}}',label:'Logo+TM+MTC'},

{data:'{{Information\n|description=\n|author=\n|source=\n|date=\n}}',label:'Information'},

{data:'{{Non-free use rationale 2\n|Description = \n|Author = \n|Source =\n|Date = \n|Article = \n|Purpose = Illustrate subject of article.\n|Replaceability = None are available.\n|Minimality = check\n|Publication = \n|Commercial = check\n}}',label:'Non-free rationale'},

{data:'{{Cc-by-sa-3.0}}',label:'CC BY-SA 3.0'},

{data:'{{Cc-by-sa-4.0}}',label:'CC BY-SA 4.0'},

{data:'{{Cc-by-4.0}}',label:'CC BY 4.0'},

{data:'{{CC0}}',label:'CC0'},

{data:'{{PD-old-70}}',label:'PD-old-70'},

{data:'{{PD-US-expired}}',label:'PD US expired'},

{data:'{{PD-old-auto|deathyear=FTTCRT}}',label:'PD old auto'}

]});

window.FTTModules[FTT.MD.fileTemplates.int].extraUI.on('change',function(){

FTT.MD.fileTemplates.fileInsertsValue = window.FTTModules[FTT.MD.fileTemplates.int].extraUI.getValue();

if (FTT.MD.fileTemplates.fileInsertsValue.match(/FTTCRT/) ) {

FTT.fileInsertsBefore = FTT.MD.fileTemplates.fileInsertsValue.replace(/FTTCRT.*/,'');

FTT.fileInsertsAfter = FTT.MD.fileTemplates.fileInsertsValue.replace(/.*FTTCRT/,'');

} else {

FTT.fileInsertsBefore = FTT.MD.fileTemplates.fileInsertsValue;

FTT.fileInsertsAfter = '';

}

FTT.UITextInput.encapsulateContent(FTT.fileInsertsBefore,FTT.fileInsertsAfter);

});

}});}

//