User:Acagastya/space.js

mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Regex_menu_framework.js&action=raw&ctype=text/javascript');

function spaceFIX { var txt=document.editform.wpTextbox1; regex(/ {2,}/g, ' '); regex(/ \./g, '.'); regex(/ \!/g, '!'); regex(/ \?/g, '?'); }

function ASCII { var txt=document.editform.wpTextbox1; regex(/’/g, "\'"); regex(/ʼ/g, "\'"); regex(/´/g, "\'"); regex(/ʹ/g, "\'"); regex(/ʻ/g, "\'"); regex(/ˈ/g, "\'"); regex(/ˊ/g, "\'"); regex(/̓/g, "\'"); regex(/̕ /g, "\'"); regex(/̓ /g, "\'"); regex(/՚/g, "\'"); regex(/ʹ/g, "\'"); regex(/΄/g, "\'"); regex(/᾽/g, "\'"); regex(/᾿/g, "\'"); regex(/′/g, "\'"); regex(/Ꞌ/g, "\'"); regex(/ꞌ/g, "\'"); regex(/＇/g, "\'"); /**/	regex(/“/g, "\"");	regex(/”/g, "\""); regex(/„/g, "\"");	regex(/”/g, "\""); regex(/»/g, "\"");	regex(/«/g, "\""); regex(/“/g, "\"");	regex(/「/g, "\""); regex(/„/g, "\"");	regex(/「/g, "\""); regex(/」/g, "\"");	regex(/《/g, "\""); regex(/》/g, "\""); }

function editSummary{ setoptions(minor='true'); setreason('space/ASCII related edits.', 'append'); doaction('diff');

}

function mainFUN { var txt=document.editform.wpTextbox1; spaceFIX; ASCII; editSummary; }

function prevDef ( e ) { e.preventDefault; }

function addLinks { var add = mw.util.addPortletLink; $( add('p-tb', '#', 'Space + ASCII', 'spacefix', 'Remove too much of the space, and ASCII fixes', 'w', , ) ).click(prevDef).click(mainFUN); $( add('p-tb', '#', 'Quote fix', 'quotefix', 'Takes care of the quotation symbols', , , '') ).click(prevDef).click(ASCII); }

if( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ){ $.when(		$.ready,		mw.loader.using( 'mediawiki.util' )	) .then( addLinks ); }