User:Billinghurst/TemplateScript.js

/** * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor. * @see https://meta.wikimedia.org/wiki/TemplateScript * @update-token */ // $.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function {	/*********	** Register scripts	*********/	pathoschild.TemplateScript.add([ // all pages { name: 'Rh', script: RunningHeader }, { name: 'clean up', script: cleanup }, { name: 'blpoem', script: blockpoem }, // various works { name: 'IndianBio', script: IndianBio, enabled: isIndianBio }, { name: 'internal nslink', script: nslink, enabled: isBiography }, { name: 'djvu pagelink', script: djvupagelink, enabled: isBiography } ]);	/*********	** Define scripts	*********/	/**	 * Cleanup for Page:The Indian Biographical Dictionary.djv.	 */	function IndianBio(editor) {		editor.forField('#wpHeaderTextbox')			.append('INDIAN BIOGRAPHICAL DICTIONARY, 1915.\n\n');		cleanup(editor);		editor			.replace(/([\n\s])([bmsd]\.)/g, '$1\'\'$2\'\'')			.replace(/([\n\s])(Address|Clubs?|educ|Publications|Recreations)\:/g, '$1\'\'$2\'\':')			.replace(/CLE\.?/g, 'C.I.E.')			// VU -> VII; followed by U in the middle of a word -> ll			.replace(/VU/g, 'VII')			.replace(/(\w)U(\w)/, '$1ll$2');	}	/**	 * Adds template 'DJVU page link'.	 */	function djvupagelink(editor) {		editor.replaceSelection(function(pre) { var work = isIrishBio ? 24 : ;			return ; });	}	/**	 * Set to internal namespace link, set specifically for subpage xref.	 */	function nslink(editor) {		editor.replaceSelection(function(pre) { return ''; });	} }); //