MediaWiki:Gadget-afchelper.js: Difference between revisions

m 1 revision imported
m top: clean up, replaced: Wikipedia → Bharatpedia (3)
Line 4: Line 4:
// Check that we're in the right namespace and on the right page
// Check that we're in the right namespace and on the right page
switch ( mw.config.get( 'wgNamespaceNumber' ) ) {
switch ( mw.config.get( 'wgNamespaceNumber' ) ) {
case 4: // Wikipedia
case 4: // Bharatpedia
case 5: // Wikipedia talk
case 5: // Bharatpedia talk
var i = -1;
var i = -1;
var pageName = mw.config.get( 'wgTitle' );
var pageName = mw.config.get( 'wgTitle' );
Line 13: Line 13:
}
}
}
}
if ( pageName === 'Wikipedia:Articles_for_creation/Redirects' ) {
if ( pageName === 'Bharatpedia:Articles_for_creation/Redirects' ) {
return;
return;
}
}

Revision as of 16:58, 10 June 2021

/* Uploaded from https://github.com/WPAFC/afch-rewrite, commit: c9ba43e1d5672f35dd3fcd4138d9378ffa9defa1 (master) */
//<nowiki>
( function () {
	// Check that we're in the right namespace and on the right page
	switch ( mw.config.get( 'wgNamespaceNumber' ) ) {
		case 4: // Bharatpedia
		case 5: // Bharatpedia talk
			var i = -1;
			var pageName = mw.config.get( 'wgTitle' );
			while ( ++i < 22 ) { // 'Articles for creation/'.length === 22
				if ( pageName.charCodeAt( i ) !== 'Articles for creation/'.charCodeAt( i ) ) {
					return;
				}
			}
			if ( pageName === 'Bharatpedia:Articles_for_creation/Redirects' ) {
				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>