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

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