X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fstartup.js;h=1d1455c43d8a784aa30783265aebf8a06e1fe295;hb=925a0ca04363939d7fcaf2de041ac4f835788677;hp=5ee295bd919fffb803f2855d6abf11434e551db5;hpb=e911dac97113bdd6f8a70588348630de447c462e;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/startup.js b/resources/src/startup.js index 5ee295bd91..1d1455c43d 100644 --- a/resources/src/startup.js +++ b/resources/src/startup.js @@ -12,7 +12,7 @@ if ( !window.performance ) { if ( !performance.mark ) { performance.mark = function () {}; } -performance.mark( 'mediaWikiStartUp' ); +performance.mark( 'mwLoadStart' ); /** * Returns false for Grade C supported browsers. @@ -25,7 +25,8 @@ performance.mark( 'mediaWikiStartUp' ); * - https://jquery.com/browser-support/ */ -/*jshint unused: false */ +/*jshint unused: false, evil: true */ +/*globals mw, RLQ: true, $VARS, $CODE */ function isCompatible( ua ) { if ( ua === undefined ) { ua = navigator.userAgent; @@ -67,6 +68,49 @@ function isCompatible( ua ) { ); } -/** - * The startUp() function will be auto-generated and added below. - */ +// Conditional script injection +( function () { + if ( !isCompatible() ) { + // Undo class swapping in case of an unsupported browser. + // See OutputPage::getHeadScripts(). + document.documentElement.className = document.documentElement.className + .replace( /(^|\s)client-js(\s|$)/, '$1client-nojs$2' ); + return; + } + + /** + * The $CODE and $VARS placeholders are substituted in ResourceLoaderStartUpModule.php. + */ + function startUp() { + mw.config = new mw.Map( $VARS.wgLegacyJavaScriptGlobals ); + + $CODE.registrations(); + + mw.config.set( $VARS.configuration ); + + // Must be after mw.config.set because these callbacks may use mw.loader which + // needs to have values 'skin', 'debug' etc. from mw.config. + window.RLQ = window.RLQ || []; + while ( RLQ.length ) { + RLQ.shift()(); + } + window.RLQ = { + push: function ( fn ) { + fn(); + } + }; + } + + var script = document.createElement( 'script' ); + script.src = $VARS.baseModulesUri; + script.onload = script.onreadystatechange = function () { + if ( !script.readyState || /loaded|complete/.test( script.readyState ) ) { + // Clean up + script.onload = script.onreadystatechange = null; + script = null; + // Callback + startUp(); + } + }; + document.getElementsByTagName( 'head' )[0].appendChild( script ); +}() );