« MediaWiki:Gadget-Typo.js » : différence entre les versions

Contenu supprimé Contenu ajouté
rend le gadget indépendant de InsertButton
améliorations mineures du code
Ligne 23 :
exec: function() {
var namespace = mw.config.get('wgNamespaceNumber');
if (namespace % 2 === 1 || $.inArray(namespace, [ 4, 8 ]) !== -1) {
return;
}
var txt$textbox = $('#wpTextbox1').val();
var txt = $textbox.val();
for (var i = 0; i < $.typo.todo.length; ++i) {
txt = $.typo.todo[i](txt);
}
$('#wpTextbox1')textbox.val(txt);
},
};
 
if($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1 ) {
$(function() {
if($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !=== -1 ) {
return;
}
 
//typo
$.typo.add(function(str) {
Ligne 99 ⟶ 103 :
// réparation liens internes
str = str.replace(/\[\[ ?([^\]]*?) ?\]\]/g, "[[$1]]");
str = str.replace(/\[\[([^\]]*?)([ |_)]#([^\]]*?)\]\]/g, "[[$1#$3]]");
// syntaxe wiki
Ligne 150 ⟶ 154 :
//simplifier certains liens : [[Dog|dog]] to [[dog]] and [[Dog|dogs]] to [[dog]]s
$.typo.add(function(str) {
var m = str.match(/\[\[([^[]*?)\|([^[]*?)\]\]/g);
if (m) {
for (var i = 0; i < m.length; i++) {
Ligne 190 ⟶ 195 :
});
});
}