User:Ronhjones/pdcV2.js

// ( function ( mw, $ ) {	function processResult( doAction ) {		var txt = $( '#wpTextbox1' ).val;		var summary = $( '#wpSummary' ).val;		if ( !txt ) return;		switch ( doAction ) {			case 'nfr' :				txt = '\n' + txt;				summary += 'Tagging image - non free reduce - for image reduction as per non-free guideline Image resolution';				break;			case 'nor' :				txt = '\n' + txt;				summary += 'Tagging image for no reduction';				break;	           case 'ncs' :				txt.replace( /\{\{[\s\t\n\r]*([mc]t?w?c|needs[ -_]commons[ -_]category|((copy|move)[ -_]?)?to[ -_]?(wikimedia[ -_])?commons)[\s\t\n\r]*\}\}/ig, '' );				txt = '\n\n' + txt;				summary += 'Tagging image as on already on commons ';				break;			case 'mtc' :				txt = '\{\{Copy to Wikimedia Commons|human=' + mw.config.get( 'wgUserName' ) + '\}\}\n\n' + txt;				summary += 'Tagging image to be Copied to Wikimedia Commons '; break; case 'dnm' : txt = '\{\{Do not move to Commons|' + 'reason=USonly\}\}\n' + txt; summary += 'Tagging image "Do not move to Commons"'; break; default : alert( 'There was an error processing your request.\n\n\t\t\t\t\tPlease try again.' ); return; }		$( '#wpTextbox1' ).val( txt ); $( '#wpSummary' ).val( summary ); $( '#editform' ).submit;// uncomment this line when you're sure it's working as intended and you won't have to hit [Save page] }	function getEdit( doAction ) { if ( doAction && ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' ) ) { processResult( doAction ); } else { location.assign( mw.util.getUrl( mw.config.get( 'wgPageName' ), { action: 'edit', runThis: doAction } ) ); }	}	if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) { var runThis = mw.util.getParamValue( 'runThis' ); if ( runThis ) { getEdit( runThis ); } else { var doNfr = mw.util.addPortletLink( 'p-cactions', '#', 'nfr', 'ca-nfr' ); $( doNfr ).click( function ( e ) {				e.preventDefault;				getEdit( 'nfr' );			} ); var donor = mw.util.addPortletLink( 'p-cactions', '#', 'nor', 'ca-nor' ); $( donor ).click( function ( e ) {				e.preventDefault;				getEdit( 'nor' );			} ); var doMtc = mw.util.addPortletLink( 'p-cactions', '#', 'mtc', 'ca-mtc' ); $( doMtc ).click( function ( e ) {				e.preventDefault;				getEdit( 'mtc' );			} ); var dodnm = mw.util.addPortletLink( 'p-cactions', '#', 'dnm', 'ca-dnm' ); $( dodnm ).click( function ( e ) {				e.preventDefault;				getEdit( 'dnm' );			} ); var doNcs = mw.util.addPortletLink( 'p-cactions', '#', 'ncs', 'ca-ncs' ); $( doNcs ).click( function ( e ) {				e.preventDefault;				getEdit( 'ncs' );			} ); }	} } ( mediaWiki, jQuery ) ); //