User:Ruthven/helpVRTS.js: Difference between revisions
Appearance
Content deleted Content added
m link |
OTRS -> VRT |
||
Line 24: | Line 24: | ||
break; |
break; |
||
case 'queued' : |
case 'queued' : |
||
VrtsRep = '{{ |
VrtsRep = '{{Permission received|id=' + ticket + |
||
'|reason= |
'|reason=VRT ticket received and in the queue.}}'; |
||
PermRep = '\n|Permission={{ |
PermRep = '\n|Permission={{Permission received|id=' + ticket + |
||
'|reason= |
'|reason=VRT ticket received and in the queue.}}'; |
||
summary += '{{[[Template: |
summary += '{{[[Template:Permission received|Permission received]]}} and queued'; |
||
break; |
break; |
||
case 'received' : |
case 'received' : |
||
VrtsRep = '{{ |
VrtsRep = '{{Permission received|id=' + ticket + '}}'; |
||
PermRep = '\n|Permission={{ |
PermRep = '\n|Permission={{Permission received|id=' + ticket + '}}'; |
||
summary += '{{[[Template: |
summary += '{{[[Template:Permission received|Permission received]]}}'; |
||
break; |
break; |
||
default : |
default : |
||
Line 41: | Line 41: | ||
} |
} |
||
summary += ' using [[User:Ruthven/helpVRTS.js|helpVRTS]].'; |
summary += ' using [[User:Ruthven/helpVRTS.js|helpVRTS]].'; |
||
var rVRTS = new RegExp( /\{\{ |
var rVRTS = new RegExp( /\{\{Permission[_ ]pending\}\}/i ); |
||
if ( rVRTS.test( txt ) ) { |
if ( rVRTS.test( txt ) ) { |
||
txt = txt.replace( rVRTS, VrtsRep ); |
txt = txt.replace( rVRTS, VrtsRep ); |
Revision as of 14:54, 22 November 2022
//<nowiki>
( function ( mw, $ ) {
function processResult( doAction ) {
var ticket = prompt( 'Ticket number or process with empty parameter if left blank: ', '' );
if ( ticket === null || ticket === '' ) ticket = '<!-- EMPTY -->';
mw.notify( 'Processing request to tag with "' + doAction + '" with Ticket: ' + ticket,
{ title: 'Processing...', autoHide: false } );
var pageid = mw.config.get( 'wgArticleId' );
new mw.Api().get( {
action: 'query',
prop: 'revisions',
rvprop: 'content',
pageids: pageid
} ).done( function( pageContents ) {
mw.notify( 'Got page contents...', { title: 'Processing...', autoHide: false } );
var txt = pageContents.query.pages[ pageid ].revisions[ 0 ][ '*' ];
var summary = 'Marked as ';
var VrtsRep = '', PermRep = '';
switch ( doAction ) {
case 'perm' :
VrtsRep = '{{Permission ticket|id=' + ticket + '}}';
PermRep = '\n|Permission={{Permission ticket|id=' + ticket + '}}';
summary += '{{[[Template:Permission ticket|VRT Permission]]}} added';
break;
case 'queued' :
VrtsRep = '{{Permission received|id=' + ticket +
'|reason=VRT ticket received and in the queue.}}';
PermRep = '\n|Permission={{Permission received|id=' + ticket +
'|reason=VRT ticket received and in the queue.}}';
summary += '{{[[Template:Permission received|Permission received]]}} and queued';
break;
case 'received' :
VrtsRep = '{{Permission received|id=' + ticket + '}}';
PermRep = '\n|Permission={{Permission received|id=' + ticket + '}}';
summary += '{{[[Template:Permission received|Permission received]]}}';
break;
default :
mw.notify( 'There was an error processing your request.\n\n\t\t\t\t\tPlease try again.',
{ title: 'Error!', autoHide: false } );
return;
}
summary += ' using [[User:Ruthven/helpVRTS.js|helpVRTS]].';
var rVRTS = new RegExp( /\{\{Permission[_ ]pending\}\}/i );
if ( rVRTS.test( txt ) ) {
txt = txt.replace( rVRTS, VrtsRep );
} else {
var rPermission = new RegExp( /\n\| *Permission[ \t]*=.*/i );
if ( rPermission.test( txt ) ) {
txt = txt.replace( rPermission, PermRep );
} else {
mw.notify( 'No suitable place found to insert template!',
{ title: 'Error!', autoHide: false } );
return;
}
}
new mw.Api().postWithToken( 'edit', {
action: 'edit',
pageid: pageid,
text: txt,
summary: summary
} ).done( function( endResult ) {
mw.notify( '"' + doAction + '" was posted. Reloading page.',
{ title: 'Done!', autoHide: false } );
location.reload();
} );
} );
}
if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) {
var perm = mw.util.addPortletLink( 'p-tb', '#', 'VRTSpermission' );
$( perm ).click( function ( e ) {
e.preventDefault();
processResult( 'perm' );
} );
var queued = mw.util.addPortletLink( 'p-tb', '#', 'Queued VRTS' );
$( queued ).click( function ( e ) {
e.preventDefault();
processResult( 'queued' );
} );
var received = mw.util.addPortletLink( 'p-tb', '#', 'Received VRTS' );
$( received ).click( function ( e ) {
e.preventDefault();
processResult( 'received' );
} );
}
} ( mediaWiki, jQuery ) );
//</nowiki>