Utilisateur:Yodin/common.js

La bibliothèque libre.

Note : après avoir enregistré vos modifications, il se peut que vous deviez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

  • Firefox / Safari : Maintenez la touche Maj (Shift) en cliquant sur le bouton Actualiser ou pressez Ctrl-F5 ou Ctrl-R (⌘-R sur un Mac) ;
  • Google Chrome : Appuyez sur Ctrl-Maj-R (⌘-Shift-R sur un Mac) ;
  • Internet Explorer : Maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5 ;
  • Opera : Allez dans Menu → Settings (Opera → Préférences sur un Mac) et ensuite à Confidentialité & sécurité → Effacer les données d'exploration → Images et fichiers en cache.
/**
 * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
 * @see [[meta:TemplateScript]]
 * @update-token [[File:Pathoschild/templatescript.js]]
 */
mw.loader.load('//tools-static.wmflabs.org/meta/scripts/pathoschild.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 [[File:Pathoschild/templatescript.js]]
 */
// <nowiki>
$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
	pathoschild.TemplateScript.add({
	name:'Wikisource format (fr)',
	forNamespaces: 'page',
	script: function(editor) {
		editor
			.replace(/'''/g, '%#%#%BOLD%#%#%')
			.replace(/''/g, '%#%#%ITALIC%#%#%')
			.replace(/[ ]+/g, ' ')
			.replace(/[^\S\r\n]+(\))/g, '$1')
			.replace(/(\()[^\S\r\n]+/g, '$1')
			.replace(/([^\s])([!?:;«»])/g, '$1 $2')
			.replace(/([!?:;«»])([^\s])/g, '$1 $2')
			.replace(/[^\S\r\n]+([\.\,\)])/g, '$1')
			.replace(/[ ]+(\n)/g, '$1')
			.replace(/^\s+/g, '')
			.replace(/\s+$/g, '')
			.replace(/\'/g, '’')
			.replace(/(\s|^)\"/g, '$1“')
			.replace(/\"/g, '”')
			.replace(/([^\s])-(\n)([^s]+)\s/g, '$1$3$2')
			.replace(/(<[^>]*)[“”]([^>]*>)/g, '$1"$2')
			.replace(/(<[^>]*)[“”]([^>]*>)/g, '$1"$2')
			.replace(/%#%#%BOLD%#%#%/g, "'''")
			.replace(/%#%#%ITALIC%#%#%/g, "''");
		editor.forField('#wpFooterTextbox').set('');
	}
});
	pathoschild.TemplateScript.add({
	name:'Reformat',
	forNamespaces: 'page',
	script: function(editor) {
		editor.forField('#wpHeaderTextbox').set(editor.forField('#wpHeaderTextbox').get().toUpperCase());
		editor.forField('#wpHeaderTextbox').replace(/\{\{NUMÉROTATION\|\{\{SC\|([^\}]+)\}\}\|(\d+)}}/g, '{{nr|$2|{{all-sc|$1}}}}')
		.replace(/\{\{NUMÉROTATION\|\{\{SC\|([^\}]+)\}\}\|\|(\d+)}}/g, '{{nr||{{all-sc|$1}}|$2}}');
		editor.replace(/\{\{ligat\|o\|e\}\}/g,'œ')
		.replace(/\{\{ligat\|O\|E\}\}/g,'Œ')
		.replace(/\{\{ligat\|a\|e\}\}/g,'æ')
		.replace(/\{\{ligat\|A\|E\}\}/g,'Æ');
		editor.forField('#wpFooterTextbox').set('');
	}
});
});
// </nowiki>