User:Ronhjones/Adds.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at User:Ronhjones/Adds. |
( function ( mw, $ ) {
function processResult( doAction ) {
var txt = $( '#wpTextbox1' ).val();
var summary = $( '#wpSummary' ).val();
if ( !txt ) return;
switch ( doAction ) {
case 'flickr' :
txt = txt+'\n{{Flickr'+'review}}';
summary += 'Tagging image for Flickr review';
break;
case 'SVG' :
txt = '{{'+'SVG}}\n' + txt;
summary += 'Tagging image with SVG';
break;
case 'wrong' :
txt = '{{'+'Wrong license}}\n' + txt;
summary += 'Tagging image with Wrong license';
break;
case 'logo' :
txt = '{{Lo'+'go}}\n' + txt;
summary += 'Tagging image - Logo';
break;
case 'water' :
txt = '{{Water'+'mark}}\n' + txt;
summary += 'Tagging image - Watermark';
break;
case 'flickrpd' :
txt = '{{subst:Flickr-public'+' domain mark/subst}}\n' + txt;
summary += 'Flickr-public domain mark';
break;
case 'flickrdone' :
txt = txt+'\n{{Flickrreview|Ronhjones|{{subst'+':#time:Y-m-d}}}}';
summary += '[[Commons:Flickr files|Flickr review]]';
break;
case 'NoLR' :
txt=txt.replace(/\{\{[Ll]icenseReview\}\}/ig, '' );
summary += 'rem LR as it has a Flickrreview';
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 dowater = mw.util.addPortletLink( 'p-cactions', '#', 'water', 'ca-water' );
$( dowater ).click( function ( e ) {
e.preventDefault();
getEdit( 'water' );
} );
var doflickr = mw.util.addPortletLink( 'p-cactions', '#', 'flickr', 'ca-flickr' );
$( doflickr ).click( function ( e ) {
e.preventDefault();
getEdit( 'flickr' );
} );
var doSVG = mw.util.addPortletLink( 'p-cactions', '#', 'SVG', 'ca-SVG' );
$( doSVG).click( function ( e ) {
e.preventDefault();
getEdit( 'SVG' );
} );
var dowrong = mw.util.addPortletLink( 'p-cactions', '#', 'wrong', 'ca-wrong' );
$( dowrong).click( function ( e ) {
e.preventDefault();
getEdit( 'wrong' );
} );
var dologo = mw.util.addPortletLink( 'p-cactions', '#', 'logo', 'ca-logo' );
$( dologo).click( function ( e ) {
e.preventDefault();
getEdit( 'logo' );
} );
var doflickrdone= mw.util.addPortletLink( 'p-cactions', '#', 'flickrdone', 'ca-flickrdone' );
$( doflickrdone).click( function ( e ) {
e.preventDefault();
getEdit( 'flickrdone' );
} );
var doflickrpd = mw.util.addPortletLink( 'p-cactions', '#', 'flickrpd', 'ca-flickrpd' );
$( doflickrpd ).click( function ( e ) {
e.preventDefault();
getEdit( 'flickrpd' );
} );
var doNoLR = mw.util.addPortletLink( 'p-cactions', '#', 'NoLR', 'ca-NoLR' );
$( doNoLR ).click( function ( e ) {
e.preventDefault();
getEdit( 'NoLR' );
} );
}
}
} ( mediaWiki, jQuery ) );