MediaWiki:Gadget-afchelper.js: Difference between revisions
Content deleted Content added
Johnrdorazio (talk | contribs) m 1 revision imported |
Johnrdorazio (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
/* Uploaded from https://github.com/WPAFC/afch-rewrite, commit: b193a94ff067f330108cbf3e7ae56af084a8b584 (master) */ |
|||
/////////////////////////////////////////////// |
|||
//<nowiki> |
|||
//////// Yet Another AfC Helper Script //////// |
|||
⚫ | |||
//// https://en.wikipedia.org/wiki/WP:AFCH //// |
|||
// Check that we're in the right namespace and on the right page |
|||
//// https://github.com/WPAFC/afch-rewrite //// |
|||
switch ( mw.config.get( 'wgNamespaceNumber' ) ) { |
|||
/////////////////////////////////////////////// |
|||
case 4: // Wikipedia |
|||
case 5: // Wikipedia talk |
|||
⚫ | |||
var pageName = mw.config.get( 'wgTitle' ); |
|||
if ( /^(?:User:|Draft:|Wikipedia(?:_talk)?:Articles_for_creation)/.test( mw.config.get( 'wgPageName' ) ) && |
|||
// return nothing for now, all drafts are now under Draft namespace |
|||
mw.config.get('wgPageName') !== 'Wikipedia:Articles_for_creation/Redirects' ) { |
|||
// currently only the article submission script is running here. |
|||
// These dependencies are also enforced by the gadget definition, this is a fallback |
|||
// to be used when script(s) for other modules such as category and |
|||
// in case people ure using the gadget indirectly . |
|||
// redirect requests are reintergrated into here. |
|||
mw.loader.using( ['mediawiki.api', 'mediawiki.util', 'mediawiki.user', 'jquery.chosen'] ).done( function() { |
|||
if ( pageName !== 'Articles for creation/sandbox' ) { |
|||
importScript( 'User:Enterprisey/afch-master.js' ); |
|||
return; |
|||
} |
|||
break; |
|||
case 2: // User |
|||
case 118: // Draft |
|||
break; |
|||
default: |
|||
return; |
|||
} |
} |
||
}( mediaWiki, importScript ) ); |
|||
// Initialize the AFCH object |
|||
window.AFCH = {}; |
|||
// Set up constants |
|||
AFCH.consts = {}; |
|||
AFCH.consts.scriptpath = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScript' ); |
|||
// These next two statements (setting beta and baseurl) may be modified |
|||
// by the uploading script! If you change them, check that the uploading |
|||
// script at scripts/upload.py doesn't break. |
|||
AFCH.consts.beta = false; |
|||
AFCH.consts.baseurl = AFCH.consts.scriptpath + |
|||
'?action=raw&ctype=text/javascript&title=MediaWiki:Gadget-afchelper.js'; |
|||
$.getScript( AFCH.consts.baseurl + '/core.js' ).done( function () { |
|||
var loaded = AFCH.load( 'submissions' ); // perhaps eventually there will be more modules besides just 'submissions' |
|||
if ( !loaded ) { |
|||
mw.notify( 'AFCH could not be loaded: ' + ( AFCH.error || 'unknown error' ), |
|||
{ title: 'AFCH error' } ); |
|||
} |
|||
} ); |
|||
}() ); |
|||
//</nowiki> |
Latest revision as of 10:40, August 19, 2021
/* Uploaded from https://github.com/WPAFC/afch-rewrite, commit: b193a94ff067f330108cbf3e7ae56af084a8b584 (master) */
//<nowiki>
( function () {
// Check that we're in the right namespace and on the right page
switch ( mw.config.get( 'wgNamespaceNumber' ) ) {
case 4: // Wikipedia
case 5: // Wikipedia talk
var pageName = mw.config.get( 'wgTitle' );
// return nothing for now, all drafts are now under Draft namespace
// currently only the article submission script is running here.
// to be used when script(s) for other modules such as category and
// redirect requests are reintergrated into here.
if ( pageName !== 'Articles for creation/sandbox' ) {
return;
}
break;
case 2: // User
case 118: // Draft
break;
default:
return;
}
// Initialize the AFCH object
window.AFCH = {};
// Set up constants
AFCH.consts = {};
AFCH.consts.scriptpath = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScript' );
// These next two statements (setting beta and baseurl) may be modified
// by the uploading script! If you change them, check that the uploading
// script at scripts/upload.py doesn't break.
AFCH.consts.beta = false;
AFCH.consts.baseurl = AFCH.consts.scriptpath +
'?action=raw&ctype=text/javascript&title=MediaWiki:Gadget-afchelper.js';
$.getScript( AFCH.consts.baseurl + '/core.js' ).done( function () {
var loaded = AFCH.load( 'submissions' ); // perhaps eventually there will be more modules besides just 'submissions'
if ( !loaded ) {
mw.notify( 'AFCH could not be loaded: ' + ( AFCH.error || 'unknown error' ),
{ title: 'AFCH error' } );
}
} );
}() );
//</nowiki>