MediaWiki:Common.js: Difference between revisions

From Donate
Jump to navigation Jump to search
Content deleted Content added
put helper function here where (fingers crossed) the ampersand won't get broken
 
Pgehres (WMF) (talk | contribs)
m formatting
Line 1: Line 1:
/**
/* Any JavaScript here will be loaded for all users on every page load. */
* Any JavaScript here will be loaded for all users on every page load.
**/


function parseParams(url) {
function parseParams( url ) {
// Helper function to get querystring parameters as a JS object
// Helper function to get querystring parameters as a JS object
// Located here as MediaWiki messes up the ampersand when included inline using rawHTML
// Located here as MediaWiki messes up the ampersand when included inline using rawHTML
var ret={};
var ret={};
if (url.indexOf('?')===-1) { return ret; }
if ( url.indexOf( '?' ) === -1 ) {
return ret;
}
var s=url.split('?').slice(1).join();
var t=s.split('&');
var s = url.split( '?' ).slice( 1 ).join();
for (var i=0; i<t.length; ++i) {
var t = s.split( '&' );
var z=t[i].split('=');
for ( var i = 0; i < t.length; ++i ) {
z.push(null);
var z = t[ i ].split( '=' );
ret[z[0]]=z[1];
z.push( null );
ret[ z[ 0 ] ] = z[ 1 ];
}
}
return ret;
return ret;

Revision as of 19:01, 22 March 2012

/**
 * Any JavaScript here will be loaded for all users on every page load. 
 **/

function parseParams( url ) {
    // Helper function to get querystring parameters as a JS object
    // Located here as MediaWiki messes up the ampersand when included inline using rawHTML
    var ret={};
    if ( url.indexOf( '?' ) === -1 ) {
        return ret; 
    }
    var s = url.split( '?' ).slice( 1 ).join();
    var t = s.split( '&' );
    for ( var i = 0; i < t.length; ++i ) {
        var z = t[ i ].split( '=' );
        z.push( null );
        ret[ z[ 0 ] ] = z[ 1 ];
    }
    return ret;
}