Created
May 27, 2018 12:04
-
-
Save sbouafif/56025068db75e7ee104349c296299f38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** OS **/ | |
var OSName="unknown"; | |
if (navigator.appVersion.indexOf("Win")!=-1) OSName="win"; | |
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="mac"; | |
if (navigator.appVersion.indexOf("X11")!=-1) OSName="unix"; | |
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="linux"; | |
$('html').addClass('os-'+OSName); | |
/** Browser **/ | |
/*eslint-disable*/ | |
// Opera 8.0+ | |
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; | |
if( isOpera ) { | |
$('html').addClass('browser-opera'); | |
} | |
// Firefox 1.0+ | |
var isFirefox = typeof InstallTrigger !== 'undefined'; | |
if( isFirefox ) { | |
$('html').addClass('browser-firefox'); | |
} | |
// Safari 3.0+ "[object HTMLElementConstructor]" | |
var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification)); | |
if( isSafari ) { | |
$('html').addClass('browser-safari'); | |
} | |
// Internet Explorer 6-11 | |
var isIE = /*@cc_on!@*/false || !!document.documentMode; | |
if( isIE ) { | |
$('html').addClass('browser-ie'); | |
} | |
// Edge 20+ | |
var isEdge = !isIE && !!window.StyleMedia; | |
if( isEdge ) { | |
$('html').addClass('browser-edge'); | |
} | |
// Chrome 1+ | |
var isChrome = !!window.chrome && !!window.chrome.webstore; | |
if( isChrome ) { | |
$('html').addClass('browser-chrome'); | |
} | |
// Blink engine detection | |
var isBlink = (isChrome || isOpera) && !!window.CSS; | |
if( isBlink ) { | |
$('html').addClass('browser-blink'); | |
} | |
// iOS version | |
var iOS = parseFloat( | |
('' + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0,''])[1]) | |
.replace('undefined', '3_2').replace('_', '.').replace('_', '') | |
) || false; | |
if( iOS ) { | |
if( iOS < 10.3 ) { | |
$('html').addClass('ios-'+iOS+' grid-not-supported'); | |
} | |
if (iOS < 10 ) { | |
$('.section-intro-bg video, .section-intro-bg .video-js').remove(); | |
} | |
} | |
/*eslint-disable*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment