X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fstartup.js;h=312e7456988461b24eb9bab7950e7b8b28902177;hb=9af38c046c86a51f82891225e3ea6833566302d4;hp=e53e5f3d2938f16ba9029e4c0bd5f28fb509fa25;hpb=747f6f1b6020da86ff3f9189a9fff74e3cf16bf3;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/startup.js b/resources/src/startup.js index e53e5f3d29..312e745698 100644 --- a/resources/src/startup.js +++ b/resources/src/startup.js @@ -1,7 +1,7 @@ /** - * This script provides a function which is run to evaluate whether or not to - * continue loading jQuery and the MediaWiki modules. This code should work on - * even the most ancient of browsers, so be very careful when editing. + * Code in this file MUST work on even the most ancient of browsers! + * + * This file is where we decide whether to initialise the modern run-time. */ /*jshint unused: false, evil: true */ /*globals mw, RLQ: true, NORLQ: true, $VARS, $CODE, performance */ @@ -15,53 +15,60 @@ var mediaWikiLoadStart = ( new Date() ).getTime(), mwPerformance.mark( 'mwLoadStart' ); /** - * Returns false for Grade C supported browsers. + * See + * + * Capabilities required for modern run-time: + * - DOM Level 4 & Selectors API Level 1 + * - HTML5 & Web Storage + * - DOM Level 2 Events + * + * Browsers we support in our modern run-time (Grade A): + * - Chrome + * - IE 9+ + * - Firefox 3.5+ + * - Safari 4+ + * - Opera 10.5+ + * - Mobile Safari (iOS 1+) + * - Android 2.0+ * - * This function should only be used by the Startup module, do not expand it to - * be generally useful beyond startup. + * Browsers we support in our no-javascript run-time (Grade C): + * - IE 6+ + * - Firefox 3+ + * - Safari 3+ + * - Opera 10+ + * - WebOS < 1.5 + * - PlayStation + * - Symbian-based browsers + * - NetFront-based browser + * - Opera Mini + * - Nokia's Ovi Browser + * - MeeGo's browser + * - Google Glass * - * See also: - * - https://www.mediawiki.org/wiki/Compatibility#Browsers - * - https://jquery.com/browser-support/ + * Other browsers that pass the check are considered Grade X. */ -function isCompatible( ua ) { - if ( ua === undefined ) { - ua = navigator.userAgent; - } +function isCompatible( str ) { + var ua = str || navigator.userAgent; + return !!( + // http://caniuse.com/#feat=queryselector + 'querySelector' in document + + // http://caniuse.com/#feat=namevalue-storage + // https://developer.blackberry.com/html5/apis/v1_0/localstorage.html + // https://blog.whatwg.org/this-week-in-html-5-episode-30 + && 'localStorage' in window + + // http://caniuse.com/#feat=addeventlistener + && 'addEventListener' in window - // Browsers with outdated or limited JavaScript engines get the no-JS experience - return !( - // Internet Explorer < 9 - ( ua.indexOf( 'MSIE' ) !== -1 && parseFloat( ua.split( 'MSIE' )[ 1 ] ) < 9 ) || - // Firefox < 3 - ( ua.indexOf( 'Firefox/' ) !== -1 && parseFloat( ua.split( 'Firefox/' )[ 1 ] ) < 3 ) || - // Opera < 12 - ( ua.indexOf( 'Opera/' ) !== -1 && ( ua.indexOf( 'Version/' ) === -1 ? - // "Opera/x.y" - parseFloat( ua.split( 'Opera/' )[ 1 ] ) < 10 : - // "Opera/9.80 ... Version/x.y" - parseFloat( ua.split( 'Version/' )[ 1 ] ) < 12 - ) ) || - // "Mozilla/0.0 ... Opera x.y" - ( ua.indexOf( 'Opera ' ) !== -1 && parseFloat( ua.split( ' Opera ' )[ 1 ] ) < 10 ) || - // BlackBerry < 6 - ua.match( /BlackBerry[^\/]*\/[1-5]\./ ) || - // Open WebOS < 1.5 - ua.match( /webOS\/1\.[0-4]/ ) || - // Anything PlayStation based. - ua.match( /PlayStation/i ) || - // Any Symbian based browsers - ua.match( /SymbianOS|Series60/ ) || - // Any NetFront based browser - ua.match( /NetFront/ ) || - // Opera Mini, all versions - ua.match( /Opera Mini/ ) || - // Nokia's Ovi Browser - ua.match( /S40OviBrowser/ ) || - // MeeGo's browser - ua.match( /MeeGo/ ) || - // Google Glass browser groks JS but UI is too limited - ( ua.match( /Glass/ ) && ua.match( /Android/ ) ) + // Hardcoded exceptions for browsers that pass the requirement but we don't want to + // support in the modern run-time. + && !( + ua.match( /webOS\/1\.[0-4]/ ) || + ua.match( /PlayStation/i ) || + ua.match( /SymbianOS|Series60|NetFront|Opera Mini|S40OviBrowser|MeeGo/ ) || + ( ua.match( /Glass/ ) && ua.match( /Android/ ) ) + ) ); }