X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=resources%2Fsrc%2Fstartup%2Fstartup.js;h=5483ad23e8e91cf5543d9e39d0c0dae24c9c4b40;hp=03141b9fe35770ab85deadf9f580df62ab00f967;hb=01cdb1762c7207bd261ad03726a88cb9afc97bfb;hpb=32a243c457c4af126d697a6a591662c252e1f1d0 diff --git a/resources/src/startup/startup.js b/resources/src/startup/startup.js index 03141b9fe3..5483ad23e8 100644 --- a/resources/src/startup/startup.js +++ b/resources/src/startup/startup.js @@ -3,8 +3,8 @@ * * - Beware: This file MUST parse without errors on even the most ancient of browsers! */ -/* eslint-disable vars-on-top, no-unmodified-loop-condition */ -/* global mw, isCompatible, $VARS, $CODE */ +/* eslint-disable no-implicit-globals, vars-on-top, no-unmodified-loop-condition */ +/* global $VARS, $CODE */ /** * See @@ -47,7 +47,7 @@ * @param {string} [str] User agent, defaults to navigator.userAgent * @return {boolean} User agent is compatible with MediaWiki JS */ -window.isCompatible = function ( str ) { +function isCompatible( str ) { var ua = str || navigator.userAgent; return !!( // https://caniuse.com/#feat=es5 @@ -74,39 +74,43 @@ window.isCompatible = function ( str ) { // Note: Please extend the regex instead of adding new ones !ua.match( /MSIE 10|webOS\/1\.[0-4]|SymbianOS|Series60|NetFront|Opera Mini|S40OviBrowser|MeeGo|Android.+Glass|^Mozilla\/5\.0 .+ Gecko\/$|googleweblight|PLAYSTATION|PlayStation/ ) ); -}; +} -( function () { - var NORLQ; +if ( !isCompatible() ) { // Handle Grade C - if ( !isCompatible() ) { - // Undo speculative Grade A class. See ResourceLoaderClientHtml::getDocumentAttributes(). - document.documentElement.className = document.documentElement.className - .replace( /(^|\s)client-js(\s|$)/, '$1client-nojs$2' ); + // Undo speculative Grade A class. See ResourceLoaderClientHtml::getDocumentAttributes(). + document.documentElement.className = document.documentElement.className + .replace( /(^|\s)client-js(\s|$)/, '$1client-nojs$2' ); - // Process any callbacks for Grade C - NORLQ = window.NORLQ; - while ( NORLQ && NORLQ[ 0 ] ) { - NORLQ.shift()(); + // Process any callbacks for Grade C + while ( window.NORLQ && window.NORLQ[ 0 ] ) { + window.NORLQ.shift()(); + } + window.NORLQ = { + push: function ( fn ) { + fn(); } - window.NORLQ = { - push: function ( fn ) { - fn(); - } - }; + }; - // Clear and disable the Grade A queue - window.RLQ = { - push: function () {} - }; + // Clear and disable the Grade A queue + window.RLQ = { + push: function () {} + }; +} else { + // Handle Grade A - return; + if ( window.performance && performance.mark ) { + performance.mark( 'mwStartup' ); } + // This embeds mediawiki.js, which defines 'mw' and 'mw.loader'. + $CODE.defineLoader(); + /** * The $CODE and $VARS placeholders are substituted in ResourceLoaderStartUpModule.php. */ - function startUp() { + ( function () { + /* global mw */ mw.config = new mw.Map( $VARS.wgLegacyJavaScriptGlobals ); $CODE.registrations(); @@ -136,14 +140,5 @@ window.isCompatible = function ( str ) { window.NORLQ = { push: function () {} }; - } - - if ( window.performance && performance.mark ) { - performance.mark( 'mwStartup' ); - } - - // This embeds mediawiki.js, which defines 'mw' and 'mw.loader'. - $CODE.defineLoader(); - - startUp(); -}() ); + }() ); +}