User:DemonDays64/Scripts/Dumb quotes.js: Difference between revisions

Content deleted Content added
yo no soy muy bueno con los scripts
Formatting
Line 1:
// Make sure the utilities module is loaded (will only load if not already)
mw.loader.using( 'mediawiki.util', function () {
 
$( document ).ready( function () {
 
//add a tab on the left
var dumbQuotesLink = mw.util.addPortletLink( "p-tb", "#", "Dumb quotes", "t-dumb-quotes" );
$(dumbQuotesLink).click( function ( event ) {
event.preventDefault();
setDumbQuotes();
} );
 
function setEditSummary() {
document.editform.wpMinoredit.checked = true;
document.editform.wpSummary.value = 'Replaced smart quotes with dumb. Problem? [[User talk:DemonDays64|Tell me]].';
doaction('diff');
}
function setDumbQuotes() {
var singleQuoteRegex = {
find: /(‘|’)/g,
replace: "'"
}
 
var doubleQuoteRegex = {
find: /(“|”)/g,
replace: '"'
}
 
var originalPage = document.editform.wpTextbox1.value;
var modifiedPage = originalPage;
 
modifiedPage = modifiedPage.replace(singleQuoteRegex.find, singleQuoteRegex.replace);
modifiedPage = modifiedPage.replace(doubleQuoteRegex.find, doubleQuoteRegex.replace);
document.editform.wpTextbox1.value = modifiedPage;
setEditSummary();
document.editform.diff();
}
} );
} );