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

Content deleted Content added
Updating AFCH: master @ 2f1956
Updating AFCH: shortdesc @ fff341
 
(7 intermediate revisions by the same user not shown)
Line 1:
/* Uploaded from https://github.com/WPAFC/afch-rewrite, commit: 2f19566ece98b38472dbb1d917a6935aa1d2409dfff341a397ca8da111f2e8c1bad547ba6bee0842 (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 = {
'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';
// script at scripts/upload.py doesn't break.
AFCH.consts.versionName = 'Hatted Hamster';
AFCH.consts.versionbeta = '0.9'true;
AFCH.consts.baseurl = AFCH.consts.scriptpath +
'?action=raw&ctype=text/javascript&title=User:Enterprisey/afch-dev.js';
 
$.when(
// FIXME: Change when moving into production
$.getScript( AFCH.consts.betabaseurl =+ '/core.js' true;),
$.getScript( 'https://tools-static.wmflabs.org/cdnjs/ajax/libs/hogan.js/3.0.2/hogan.min.js' )
 
).done( function () {
AFCH.consts.scriptpath = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScript' );
var loaded = AFCH.load( 'submissions' ); // perhaps eventually there will be more modules besides just 'submissions'
AFCH.consts.baseurl = AFCH.consts.scriptpath +
if ( !loaded ) {
'?action=raw&ctype=text/javascript&title=User:Enterprisey/afch-dev.js';
mw.notify( 'AFCH could not be loaded: ' + ( AFCH.error || 'unknown error' ),
 
{ title: 'AFCH error' } );
$.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>