User:Erutuon/scripts/TemplateScript.js

Hello, you have come here looking for the meaning of the word User:Erutuon/scripts/TemplateScript.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:Erutuon/scripts/TemplateScript.js, but we will also tell you about its etymology, its characteristics and you will know how to say User:Erutuon/scripts/TemplateScript.js in singular and plural. Everything you need to know about the word User:Erutuon/scripts/TemplateScript.js you have here. The definition of the word User:Erutuon/scripts/TemplateScript.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:Erutuon/scripts/TemplateScript.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
// <nowiki>

$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
	pathoschild.TemplateScript.add([
		{
			name: 'root cat ',
			isMinorEdit: true,
			enabled: false,
			category: 'templates',
			script: function(editor) {
				var ArabicLetter = '';
				var ArabicRoot = RegExp('(' + ArabicLetter + ') (' + ArabicLetter + ') (' + ArabicLetter + ')', 'g');
				editor
					.replace(
						ArabicRoot,
						'\n{{ar-root|$1|$2|$3|notext=1}}'
						)
					.appendEditSummary('add root category');
			}
		},
		{
			name: 'convert to non-gloss def',
			isMinorEdit: true,
			category: 'templates',
			script: function(editor) {
				editor
					.replace(/# ?(\{\{senseid+\}\}) ?(\{\{(?:lb|label)+\}\}) ?(.+)/g, '# $1 $2 {{non-gloss definition|$3}}')
					.replace(/# ?(\{\{(?:lb|label)+\}\}) ?(.+)/g, '# $1 {{non-gloss definition|$2}}')
					.replace(/# ?(.+)/g, '# {{non-gloss definition|$1}}')
					.appendEditSummary('add ]');
			}
		},
		{
			name: 'selection to non-gloss def',
			isMinorEdit: true,
			category: 'templates',
			script: function(editor) {
				editor
					.replaceSelection(function(selected) {
						var hasNumberedList = selected.includes('#');
						if ( hasNumberedList ) { return selected
							.replace(/# ?(\{\{senseid+\}\}) ?(\{\{(?:lb|label)+\}\}) ?(.+)/g, '# $1 $2 {{non-gloss definition|$3}}')
							.replace(/# ?(\{\{(?:lb|label)+\}\}) ?(.+)/g, '# $1 {{non-gloss definition|$2}}')
							.replace(/# ?(.+)/g, '# {{non-gloss definition|$1}}');
						} else {
							return '{{non-gloss definition|' + selected + '}}';
						}
					})
					.appendEditSummary('add ]');	
			}
		},
		{
			name: 'combine POS cats',
			category: 'templates',
			isMinorEdit: true,
			script: function(editor) {
				editor
					.replace(/\+ ?)+) (]+)\]\]/g, '{{catlangname||$2}}')
					.replace(/(.*getByCanonicalName\|(+)}}(?:\|+)+)}}\n?.*getByCanonicalName\|\2}}((?:\|+)+)/g, '$1$3')
					.replace(/(.*getByCanonicalName\|(+)}}(?:\|+)+)}}\n?.*getByCanonicalName\|\2}}((?:\|+)+)/g, '$1$3')
					.replace(/(.*getByCanonicalName\|(+)}}(?:\|+)+)}}\n?.*getByCanonicalName\|\2}}((?:\|+)+)/g, '$1$3');
			}
		},
		{
			name: '\'\'\' → ;',
			category: 'formatting',
			isMinorEdit: true,
			enabled: false,
			script: function(editor) {
				editor.replace(/\'\'\'(+)\'\'\'/g, '; $1');
			}
		},
		{
			name: 'chars (grc)',
			category: 'templates',
			script: function(editor) {
				editor.replaceSelection(
					function(selected)
					{
						var hasEquals = selected.includes("=");
						var param = '';
						selected = selected.replace(/\|/g, "!");
						if ( hasEquals ) {
							param = '2=' + selected;
						} else {
							param = selected;
						}
						return '{{subst:chars|grc|' + param + '}}';
					}
				);
			}
		},
		{
			name: 'templatize categories',
			category: 'templates',
			enabled: false,
			script: function(editor) {
				editor
					.replace(/\+)\]\]\n\+)\]\]\n\+)\]\]/g, '{{C|$1|$2|$3|$4}}')
					.replace(/\+)\]\]\n\+)\]\]/g, '{{C|$1|$2|$3}}');
			}
		},
		{
			name: 'ar-root nocat',
			isMinorEdit: true,
			enabled: false,
			category: 'templates',
			script: function(editor) {
				editor
					.replace(/(\{\{ar-root\|+)/g, '$1|nocat=1')
					.appendEditSummary('removed from Arabic category');
			}
		},
		{
			name: 'grc verb',
			editSummary: '',
			enabled: false,
			script: function(editor) {
				editor
					.replace(/conj-present(\|form=+)\|+(\|+)\|+/g, 'conj|pres$1$2')
					.replace(/conj-present\|+(\|+)\|+/g, 'conj|pres$1')
					.replace(/-(perf)ect*(\|form+)\|+\|+(\|+)\|+\|+(\|+)/g, '|$1$2$3$4')
					.replace(/-(perf)ect*\|+\|+(\|+)\|+\|+(\|+)/g, '|$1$2$3')
					.replace(/-(perf)ect*/g, '|$1')
					.replace(/conj-(imperf)ect(\|form=+)\|+\|+(\|+)/g, 'conj|$1$2$3')
					.replace(/conj-(imperf)ect\|+\|+(\|+)/g, 'conj|$1$2')
					.replace(/-aorist-(\d\|form+)\|*\|*(\|*)\|*(\|+)\|+\|+(\|+\|+)\|+/g, '|aor-$1$2$3$4')
					.replace(/-aorist-(\d)\|*\|*(\|*)\|*(\|*)\|*\|+(\|+\|+)\|+/g, '|aor-$1$2$3$4')
					.replace(/-aorist-(\d)/g, '|aor-$1')
					.replace(/-pluperfect*(\|form+)\|+(\|+\|+\|+)/g, '|plup$1$2')
					.replace(/-pluperfect*\|+(\|+\|+\|+)/g, '|plup$1')
					.replace(/-pluperfect*/g, '|plup')
					.replace(/-(fut)ure(\|form+)\|+(\|+)\|+((?:\|+)?)/g, '|$1$2$3$4')
					.replace(/-(fut)ure\|+(\|+)\|+(\|+)/g, '|$1$2$3')
					.replace(/-future-/g, '|fut-')
					.replace(/-future ?(p?)*(?=\|)/g, '|fut$1')
					.replace(/(+)σ/g, '$1')
					.replace(/grc-alt/g, 'alter|grc')
					.replace(/etyl(\|+)\|grc}} {{m\1/g, 'der|grc$1')
					.replace(/grc-cite/g, 'Q|grc')
					.replace(/(\{\{m\|+\|+\|)\|/g, '$1t=')
					.replace(/ I /g, ' to ')
					.replace(/\{\{prefix\|(+\|+)/g, '{{affix|$1-')
					.replace(/\|sc=Deva/g, '')
					.replace(/\{\{grc-ipa.*/g, '{{grc-IPA|}}')
					.replace(/\|gloss/g, '|t')
					.replace(/(\{\{...?fix)(\|+)\|lang=(+)/g, '$1|$3$2')
					.replace(/titleapp\=\(\{\{grc\-(\w+)\}\}\)/g, 'dial=$1')
					.replace(/m\|grc\|(+)\|(?:\||t\=)(+)\}\} \+ \{\{m\|grc\|(+)\|(?:\||t=)(+)/g, 'affix|grc|$1|t1=$2|$3|t2=$4')
					.replace(/( |\()(?:+ )?+ \{\{m(\|+)/g, '$1{{cog$2')
					.replace(/con-ε/g, 'con-e')
					.replace(/con-α/g, 'con-a')
					.replace(/con-ο/g, 'con-o')
					.replace(/-νυμι/g, '-numi')
					.replace(/-((?:pres|imperf))(?:ent|ect)/g, '|$1')
					.replace(/(pres+)((?:\|form+)?)(\|+)\|+/g, '$1$2$3')
					.replace(/(imperf+)((?:\|form+)?)\|+(\|+)/g, '$1$2$3')
					.replace(/(grc-verb)+/g, '$1')
					.replace(/grc-pron(?:(\|)(?:w=)?)?/g, 'grc-IPA$1')
					.replace(/(grc-conj.+)\|+η(?=\W)/g, '$1')
					.replace(/to am(?=\W)/g, 'to be')
					.appendEditSummary('updated conjugation tables and other cleanup, with the help of ]');
			}
		},
		{
			name: 'etym link cleanup',
			isMinorEdit: true,
			enabled: false,
			category: 'templates',
			script: function(editor) {
				editor
					.replace(/\{\{etyl\|(+)\|(+)\}\} (?:\'\')?\]+)\]\](?:\'\')?/g, '{{der|$2|$1|$3}}')
					.appendEditSummary('fix link with the help of ]');
			}
		},
		{
			name: 'Lua code',
			isMinorEdit: true,
			enabled: false,
			category: 'templates',
			script: function(editor) {
				editor.replaceSelection(function(selected) {
					var hasEquals = selected.includes("=");
					var param = '';
					if ( hasEquals ) {
						param = '2=' + selected;
					} else {
						param = selected;
					}
					return '{{code|lua|' + param + '}}';
					
				});
			},
		},
		{
			name: 'swung dash',
			enabled: false,
			category: 'characters',
			script: function(editor) {
				editor.replace(/~/g, '⁓');
			}
		},
		{
			name: 'subst',
			category: 'templates',
			enabled: false,
			script: function(editor) {
				editor.replaceSelection(function (selected) {
					return selected
						.replace(/\{\{(?:subst:)?/g, '{{subst:');
				});
			}
		},
		{
			name: 'der and rel',
			category: 'templates',
			enabled: false,
			script: function(editor) {
				editor.replaceSelection(
					function (selected) {
						var sectionType = ( selected.match(/=((?:Der|Rel))/).toLowerCase() || 'der' );
						// Use lang in first l template.
						var langCode = selected.match(/\{\{l\|(+)\|+/);
						var numberOfColumns = ( selected.match(/\{\{top(\d)\}\}/) || '3' );
						
						return selected
								.replace(/\n\* ?\{\{l\|+\|(+)\}\}/g, '\n|$1')
								.replace(/\n\{\{+\}\}/g, '')
								.replace(
									/((?:\n\|+)+)/g,
									'\n{{' + sectionType + numberOfColumns + '\n|lang=' + langCode + '$1\n}}'
									);
					}
				);
			}
			
		},
		{
			name: 'letters template',
			enabled: false,
			category: 'templates',
			script: function(editor) {
				var content = editor.get();
				var hasDoc = content.includes('list doc');
				var lang = content.match(/l(?:-self)\|(+)/);
				var nativeName = content.match(/\|hypernym=(?:\{\{l(?:-self)?\|+\|)?(+)(?:\|+)?(?:\}\})?/);
				var nativeNameParameter = '';
				if ( nativeName ) {
					nativeNameParameter = '|native name=' + nativeName  + '\n';
				} else {
					nativeNameParameter = '';
				}
				editor
					.replace(
						/list helper 2(?:\n\|.+)+\n\|list=/g,
						'letters\n|lang=' + ( lang || '' ) + '|sc=Latn\n' + nativeNameParameter
						)
					.replace(
						/(?:<!--+-->)?(\(?)\{\{l(?:-self)?\|+\|(+)(?:\|+)?\}\}\s*\{\{l(?:-self)?\|+\|(+)(?:\|+)?\}\}(\)?)(?:,? )?/g,
						'|$1$2/$3$4'
						)
					.replace(
						/(?:<!--+-->)?(\(?)\{\{l(?:-self)?\|+\|(+)(?:\|+)?\}\}(\)?)(?:,? )?/g,
						'|$1$2$3'
						)
					.replace(/\|()\/()/g, '|$1$2')
					.replace(/<!--+-->(?=\}\})/g, '')
					.replace(/(\}\})(<noinclude>)/, '$1<!--\n\n-->$2')
					.replace(/\s+$/, '')
					.appendEditSummary('converted to ] with the help of ]');
				
				if ( !hasDoc ) {
					editor
						.append('<!--\n\n--><noinclude>\n{{list doc}}\n</noinclude>')
						.appendEditSummary('added ] for documentation');
				}
			}
		},
		{
			name: 'fix T:lang',
			enabled: false,
			script: function(editor) {
				editor
					.replace(/\{\{(lang\|+\|+)\|\}\}/g, '{{$1}}')
					.replace(/\{\{(lang+)\|lang=+(*)\}\}/g, '{{$1$2}}')
					.appendEditSummary('fixing parameters of ] with the help of ]')
					.options({ minor: true });
			}
		},
		{
			name: 'temporary',
			isMinorEdit: true,
//			enabled: false,
			script: function(editor) {
				editor
					.replace(/\\]/g, '{{adverbial accusative|ar}}')
					.replace(/Adverbial accusative/g, '{{adverbial accusative|ar}}')
					.appendEditSummary('adding ], which also categorizes');
			}
		},
		{
			name: 'related and derived cleanup',
			category: 'templates',
			enabled: false,
			script: function(editor) {
				editor
					.replace()
					.replace();
			}
		},
	]);
});

// </nowiki>