« Utilisateur:Thibaut120094/deln.js » : différence entre les versions

Contenu supprimé Contenu ajouté
mAucun résumé des modifications
Ligne 3 :
 
Retire les sauts de lignes parasites et autres machins générés par l'OCR
*/
$.typo2 = {
todo: [],
add: function(fonction) {
$.typo2.todo.push(fonction);
},
exec: function() {
var namespace = mw.config.get('wgNamespaceNumber');
if (namespace % 2 == 1 || $.inArray(namespace, [ 4, 8 ]) != -1) {
return;
}
var txt = $('#wpTextbox1').val();
for (var i = 0; i < $.typo2.todo.length; ++i) {
txt = $.typo2.todo[i](txt);
}
$('#wpTextbox1').val(txt);
},
};
 
avec des corrections de 0x010C
if($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1 ) {
*/
$(function() {
//typo
$.typo2.add(function(str) {
str = str.replace(/\n/g, "");
str = str.replace(/- /g, "");
str = str.replace(/¬/g, "");
return $.trim(str);
});
 
// Only launch the script when editing non-talk pages
$.when(
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
mw.loader.using( [ 'ext.gadget.InsertButton' ] )
var namespace =&& mw.config.get( 'wgNamespaceNumber' ); % 2 !== 1
).then(function() {
&& $.inArray( mw.config.get( 'wgNamespaceNumber' ), [ 4, 8 ] ) === -1 )
window.insert_button.editForm( {
{
'img_classic' : '//upload.wikimedia.org/wikipedia/commons/0/04/Button_NW.png',
add:$( function(fonction) {
'img_advanced' : '//upload.wikimedia.org/wikipedia/commons/c/cb/Toolbaricon_regular_n.png',
mw.loader.using( [ 'ext.gadgetwikiEditor.InsertButtontoolbar' ], function() {
'tooltip' : 'Retrait des sauts de ligne parasites',
}
'img_id' : 'wsDeln',
// Remove all useless lines
'on_click' : $.typo2.exec
// Called when the user click the button added bellow
} );
exec: var lineRemover = function() {
} );
var txtstr = $( '#wpTextbox1' ).val();
});
str = str.replace(/\n/g, "");
str = str.replace(/- /g, "");
str = str.replace(/¬/g, "");
$( '#wpTextbox1' ).val(txt str.trim() );
};
}
// Add a button to the WikiEditor toolbar , in the main section
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'insert',
'tools': {
'wsDeln': {
'tooltip' label: 'Retrait des sauts de ligne parasites',
type: 'button',
'img_classic' icon: '//upload.wikimedia.org/wikipedia/commons/0c/04cb/Button_NWToolbaricon_regular_n.png',
action: {
type: 'callback',
execute: lineRemover
return; }
}
}
} );
} );
}, );
}