User:Enterprisey/afch-dev.js: Difference between revisions

Content deleted Content added
m Updating AFCH: master @ a6f9ad
Updating AFCH: master @ cffd8f
Line 1:
/* Uploaded from https://github.com/WPAFC/afch-rewrite, commit: a6f9ad227ef773dfd4530711ba002b21d472d6b3cffd8f5795d4575fa090c05827fcbb39eadab8cc (master) */
//<nowiki>
( function ( $, mw ) {
// Check that we're in the right namespace and on the right page
var subscriptToLoad = false,
pageName switch =( mw.config.get( 'wgPageNamewgNamespaceNumber' ).replace( /_/g,) ' ' ),{
case 4: // Wikipedia
 
case 5: // Wikipedia talk
// `loadMap` determines which scripts should be loaded
var pageName = mw.config.get( 'wgTitle' );
// on each page. Each key is a subscript name and
// return nothing for now, all drafts are now under Draft namespace
// its value is a list of page prefixes on which it
// currently only the article submission script is running here.
// should be loaded.
// to be used when script(s) for other modules such as category and
 
// redirect requests are reintergrated into here.
loadMap = {
'Wikipediaif talk:( pageName !== 'Articles for creation/sandbox', ) {
// `submissions.js` is for reviewing textual
return false;
// Articles for Creation submissions.
submissions: [
'Wikipedia:Articles for creation/',
'Wikipedia talk:Articles for creation/',
'User:',
'Draft:'
]
};
 
$.each( loadMap, function ( script, prefixes ) {
$.each( prefixes, function ( _, prefix ) {
if ( pageName.indexOf( prefix ) === 0 ) {
subscriptToLoad = script;
return false;
}
} ) break;
case 2: // User
case 118: // Draft
break;
default:
return;
}
 
// Initialize the AFCH object
// Return false and break out of the loop if already found
window.AFCH = {};
return !!subscriptToLoad;
} );
 
// Set up constants
if ( subscriptToLoad ) {
AFCH.consts = {};
// Initialize the AFCH object
window.AFCH = {};
 
AFCH.consts.scriptpath = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScript' );
// Set up constants
AFCH.consts = {};
 
// These next two statements (setting beta and baseurl) may be modified
// Master version data
// by the uploading script! If you change them, check that the uploading
AFCH.consts.version = '0.9.1';
// script at scripts/upload.py doesn't break.
AFCH.consts.versionName = 'Imperial Ibex';
AFCH.consts.versionbeta = '0.9.1'true;
AFCH.consts.baseurl = AFCH.consts.scriptpath +
'?action=raw&ctype=text/javascript&title=User:Enterprisey/afch-dev.js';
 
$.getScript( AFCH.consts.baseurl + '/core.js' ).done( function () {
// FIXME: Change when moving into production
var loaded = AFCH.load( 'submissions' ); // perhaps eventually there will be more modules besides just 'submissions'
AFCH.consts.beta = true;
if ( !loaded ) {
 
mw.notify( 'AFCH could not be loaded: ' + ( AFCH.error || 'unknown error' ),
AFCH.consts.scriptpath = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScript' );
{ title: 'AFCH error' } );
AFCH.consts.baseurl = AFCH.consts.scriptpath +
]}
'?action=raw&ctype=text/javascript&title=User:Enterprisey/afch-dev.js';
} );
 
}() );
$.getScript( AFCH.consts.baseurl + '/core.js' ).done( function () {
var loaded = AFCH.load( subscriptToLoad );
if ( !loaded ) {
mw.notify( 'AFCH could not be loaded: ' + ( AFCH.error || 'unknown error' ),
{ title: 'AFCH error' } );
}
} );
}
}( jQuery, mediaWiki ) );
//</nowiki>