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

Content deleted Content added
m Updating AFCH: master @ 0a97f1
Updating AFCH: shortdesc @ fff341
 
(4 intermediate revisions by the same user not shown)
Line 1:
/* Uploaded from https://github.com/WPAFC/afch-rewrite, commit: 0a97f1e43288055fc5ced82ddd94d95d55b4ca57fff341a397ca8da111f2e8c1bad547ba6bee0842 (mastershortdesc) */
//<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 = {
if ( pageName =!== 'Wikipedia:Articles for creation/Redirectssandbox' ) {
// `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
// Return false and break out of the loop if already found
break;
return !!subscriptToLoad;
default:
} );
return;
 
// Special case: don't initialize submissions.js on
// Wikipedia:Articles for creation/Redirects, since that
// isn't a draft
if ( pageName === 'Wikipedia:Articles for creation/Redirects' ) {
subscriptToLoad = null;
}
 
// Initialize the AFCH object
if ( subscriptToLoad ) {
window.AFCH = {};
// Initialize the AFCH object
window.AFCH = {};
 
// Set up constants
AFCH.consts = {};
 
AFCH.consts.scriptpath = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScript' );
// Master version data
AFCH.consts.version = '0.9';
AFCH.consts.versionName = 'Hatted Hamster';
 
// These next two statements (setting beta and baseurl) may be modified
// FIXME: Change when moving into production
// by the uploading script! If you change them, check that the uploading
AFCH.consts.beta = true;
// script at scripts/upload.py doesn't break.
AFCH.consts.versionbeta = '0.9'true;
AFCH.consts.baseurl = AFCH.consts.scriptpath +
'?action=raw&ctype=text/javascript&title=User:Enterprisey/afch-dev.js';
 
$.when(
AFCH.consts.scriptpath = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScript' );
$.getScript( AFCH.consts.baseurl =+ AFCH'/core.consts.scriptpathjs' +),
$.getScript( 'https://tools-static.wmflabs.org/cdnjs/ajax/libs/hogan.js/3.0.2/hogan.min.js' )
'?action=raw&ctype=text/javascript&title=User:Enterprisey/afch-dev.js';
).done( function () {
 
var loaded = AFCH.load( 'submissions' ); // perhaps eventually there will be more modules besides just 'submissions'
$.getScript( AFCH.consts.baseurl + '/core.js' ).done( function () {
if ( !loaded ) {
var loaded = AFCH.load( subscriptToLoad );
mw.notify( 'AFCH could not be loaded: ' + ( AFCH.error || 'unknown error' ),
if ( !loaded ) {
mw.notify({ 'AFCH could not be loadedtitle: 'AFCH + ( AFCH.error || 'unknown error'} ),;
]}
{ title: 'AFCH error' } );
} );
}
}() );
}
}( jQuery, mediaWiki ) );
//</nowiki>