mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
fixed indentation
This commit is contained in:
parent
ebfaba07e5
commit
4fdd74d05a
202
bowser.js
202
bowser.js
@ -5,61 +5,70 @@
|
||||
*/
|
||||
|
||||
!function (name, definition) {
|
||||
if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition()
|
||||
else if (typeof define == 'function') define(definition)
|
||||
if (typeof define == 'function') define(definition)
|
||||
else if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition()
|
||||
else this[name] = definition()
|
||||
}('bowser', function () {
|
||||
/**
|
||||
* navigator.userAgent =>
|
||||
* Chrome: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57 Safari/534.24"
|
||||
* Opera: "Opera/9.80 (Macintosh; Intel Mac OS X 10.6.7; U; en) Presto/2.7.62 Version/11.01"
|
||||
* Safari: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1"
|
||||
* IE: "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)"
|
||||
* IE>=11: "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; Media Center PC 6.0; rv:11.0) like Gecko"
|
||||
* Firefox: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0) Gecko/20100101 Firefox/4.0"
|
||||
* iPhone: "Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5"
|
||||
* iPad: "Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5",
|
||||
* iPod: "Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5"
|
||||
* Android: "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; T-Mobile G2 Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
|
||||
* Touchpad: "Mozilla/5.0 (hp-tabled;Linux;hpwOS/3.0.5; U; en-US)) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/234.83 Safari/534.6 TouchPad/1.0"
|
||||
* PhantomJS: "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.5.0 Safari/534.34"
|
||||
* Amazon Silk: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.0.22.153_10033210) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true"
|
||||
* See useragents.js for examples of navigator.userAgent
|
||||
*/
|
||||
|
||||
var ua = navigator.userAgent
|
||||
, t = true
|
||||
, ie = /(msie|trident)/i.test(ua)
|
||||
, chrome = /chrome|crios/i.test(ua)
|
||||
, phantom = /phantom/i.test(ua)
|
||||
, iphone = /iphone/i.test(ua)
|
||||
, ipad = /ipad/i.test(ua)
|
||||
, ipod = /ipod/i.test(ua)
|
||||
, touchpad = /touchpad/i.test(ua)
|
||||
, silk = /silk/i.test(ua)
|
||||
, safari = /safari/i.test(ua) && !chrome && !phantom && !silk
|
||||
, android = /android/i.test(ua)
|
||||
, opera = /opera/i.test(ua) || /opr/i.test(ua)
|
||||
, firefox = /firefox/i.test(ua)
|
||||
, gecko = /gecko\//i.test(ua)
|
||||
, seamonkey = /seamonkey\//i.test(ua)
|
||||
, webkitVersion = /version\/(\d+(\.\d+)?)/i
|
||||
, firefoxVersion = /firefox\/(\d+(\.\d+)?)/i
|
||||
, mobile = /mobile/i.test(ua)
|
||||
, o
|
||||
var t = true,
|
||||
v /* temporary placeholder for versions. */
|
||||
|
||||
function detect() {
|
||||
function detect(ua) {
|
||||
|
||||
if (ie) return {
|
||||
var ie = /(msie|trident)/i.test(ua)
|
||||
, chrome = /chrome|crios/i.test(ua)
|
||||
, phantom = /phantom/i.test(ua)
|
||||
, iphone = /iphone/i.test(ua)
|
||||
, ipad = /ipad/i.test(ua)
|
||||
, ipod = /ipod/i.test(ua)
|
||||
, touchpad = /touchpad/i.test(ua)
|
||||
, silk = /silk/i.test(ua)
|
||||
, safari = /safari/i.test(ua) && !chrome && !phantom && !silk
|
||||
, android = /android/i.test(ua)
|
||||
, opera = /opera/i.test(ua) || /opr/i.test(ua)
|
||||
, firefox = /firefox/i.test(ua)
|
||||
, gecko = /gecko\//i.test(ua)
|
||||
, seamonkey = /seamonkey\//i.test(ua)
|
||||
, webos = /webos/i.test(ua)
|
||||
, windowsphone = /windows phone/i.test(ua)
|
||||
, blackberry = /blackberry/i.test(ua)
|
||||
, webkitVersion = /version\/(\d+(\.\d+)?)/i
|
||||
, firefoxVersion = /firefox[ \/](\d+(\.\d+)?)/i
|
||||
, mobile = /mobile/i.test(ua)
|
||||
, o = {}
|
||||
|
||||
if (windowsphone) o = {
|
||||
name: 'Windows Phone'
|
||||
, windowsphone: t
|
||||
, mobile: t
|
||||
, version: ua.match(/iemobile\/(\d+(\.\d+)?)/i)[1]
|
||||
}
|
||||
else if (opera) {
|
||||
if ((v = ua.match(webkitVersion)) && v.length > 1) v = v[1]
|
||||
else if ((v = ua.match(/opr\/(\d+(\.\d+)?)/i)) && v.length > 1) v = v[1]
|
||||
else if ((v = ua.match(/opera[ \/](\d+(\.\d+)?)/i)) && v.length > 1) v = v[1]
|
||||
else v = 0
|
||||
o = {
|
||||
name: 'Opera'
|
||||
, opera: t
|
||||
, version: v
|
||||
}
|
||||
if (android) {
|
||||
o.android = true
|
||||
o.mobile = true
|
||||
}
|
||||
if (chrome) {
|
||||
o.webkit = true
|
||||
}
|
||||
} else if (ie) o = {
|
||||
name: 'Internet Explorer'
|
||||
, msie: t
|
||||
, version: ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]
|
||||
}
|
||||
if (opera) return {
|
||||
name: 'Opera'
|
||||
, opera: t
|
||||
, version: ua.match(webkitVersion) ? ua.match(webkitVersion)[1] : ua.match(/opr\/(\d+(\.\d+)?)/i)[1]
|
||||
}
|
||||
if (chrome) return {
|
||||
else if (chrome) o = {
|
||||
name: 'Chrome'
|
||||
, webkit: t
|
||||
, chrome: t
|
||||
@ -69,31 +78,31 @@
|
||||
, ios: !!ua.match(/crios/i)
|
||||
, mobile: mobile
|
||||
}
|
||||
if (phantom) return {
|
||||
else if (phantom) o = {
|
||||
name: 'PhantomJS'
|
||||
, webkit: t
|
||||
, phantom: t
|
||||
, version: ua.match(/phantomjs\/(\d+(\.\d+)+)/i)[1]
|
||||
, version: ua.match(/phantomjs\/(\d+(\.\d+)?)/i)[1]
|
||||
}
|
||||
if (touchpad) return {
|
||||
else if (touchpad) o = {
|
||||
name: 'TouchPad'
|
||||
, webkit: t
|
||||
, touchpad: t
|
||||
, version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1]
|
||||
}
|
||||
|
||||
if (silk) return {
|
||||
name: 'Amazon Silk'
|
||||
, webkit: t
|
||||
, android: t
|
||||
, mobile: t
|
||||
, version : ua.match(/silk\/(\d+(\.\d+)?)/i)[1]
|
||||
}
|
||||
if (iphone || ipad || ipod) {
|
||||
else if (silk) o = {
|
||||
name: 'Amazon Silk'
|
||||
, webkit: t
|
||||
, android: t
|
||||
, mobile: t
|
||||
, version : ua.match(/silk\/(\d+(\.\d+)?)/i)[1]
|
||||
}
|
||||
else if (iphone || ipad || ipod) {
|
||||
if (ipod) iphone = false
|
||||
o = {
|
||||
name : iphone ? 'iPhone' : ipad ? 'iPad' : 'iPod'
|
||||
, webkit: t
|
||||
, mobile: iphone
|
||||
, mobile: t
|
||||
, ios: t
|
||||
, iphone: iphone
|
||||
, ipad: ipad
|
||||
@ -103,61 +112,88 @@
|
||||
if (webkitVersion.test(ua)) {
|
||||
o.version = ua.match(webkitVersion)[1]
|
||||
}
|
||||
return o
|
||||
}
|
||||
if (android) return {
|
||||
else if (blackberry) {
|
||||
o = {
|
||||
name: 'BlackBerry'
|
||||
, blackberry: t
|
||||
, mobile: t
|
||||
}
|
||||
if ((v = ua.match(webkitVersion))) {
|
||||
o.version = v[1]
|
||||
o.webkit = t
|
||||
} else {
|
||||
o.version = ua.match(/blackberry[\d]+\/(\d+(\.\d+)?)/i)[1]
|
||||
}
|
||||
}
|
||||
else if (webos) o = {
|
||||
name: 'WebOS'
|
||||
, mobile: t
|
||||
, webkit: t
|
||||
, webos: t
|
||||
, version: (ua.match(webkitVersion) || ua.match(/wosbrowser\/(\d+(\.\d+)?)/i))[1]
|
||||
}
|
||||
else if (android) o = {
|
||||
name: 'Android'
|
||||
, webkit: t
|
||||
, android: t
|
||||
, mobile: t
|
||||
, version: (ua.match(webkitVersion) || ua.match(firefoxVersion))[1]
|
||||
}
|
||||
if (safari) return {
|
||||
else if (safari) o = {
|
||||
name: 'Safari'
|
||||
, webkit: t
|
||||
, safari: t
|
||||
, version: ua.match(webkitVersion)[1]
|
||||
, version: ((v = ua.match(webkitVersion)) ? v[1] : 0)
|
||||
}
|
||||
if (gecko) {
|
||||
else if (gecko) {
|
||||
o = {
|
||||
name: 'Gecko'
|
||||
, gecko: t
|
||||
, mozilla: t
|
||||
, version: ua.match(firefoxVersion)[1]
|
||||
, version: ((v = ua.match(firefoxVersion)) && v? v[1] : 0)
|
||||
}
|
||||
if (firefox) {
|
||||
o.name = 'Firefox';
|
||||
o.firefox = t;
|
||||
}
|
||||
return o
|
||||
}
|
||||
if (seamonkey) return {
|
||||
else if (seamonkey) o = {
|
||||
name: 'SeaMonkey'
|
||||
, seamonkey: t
|
||||
, version: ua.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]
|
||||
}
|
||||
return {}
|
||||
|
||||
// Graded Browser Support
|
||||
// http://developer.yahoo.com/yui/articles/gbs
|
||||
if ((o.msie && o.version >= 9) ||
|
||||
(o.chrome && o.version >= 20) ||
|
||||
(o.firefox && o.version >= 10.0) ||
|
||||
(o.safari && o.version >= 5) ||
|
||||
(o.opera && o.version >= 10.0)) {
|
||||
o.a = t;
|
||||
}
|
||||
|
||||
else if ((o.msie && o.version < 9) ||
|
||||
(o.chrome && o.version < 20) ||
|
||||
(o.firefox && o.version < 10.0) ||
|
||||
(o.safari && o.version < 5) ||
|
||||
(o.opera && o.version < 10.0)) {
|
||||
o.c = t
|
||||
} else o.x = t
|
||||
|
||||
return o
|
||||
}
|
||||
|
||||
var bowser = detect()
|
||||
var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent : '')
|
||||
|
||||
// Graded Browser Support
|
||||
// http://developer.yahoo.com/yui/articles/gbs
|
||||
if ((bowser.msie && bowser.version >= 9) ||
|
||||
(bowser.chrome && bowser.version >= 20) ||
|
||||
(bowser.firefox && bowser.version >= 10.0) ||
|
||||
(bowser.safari && bowser.version >= 5) ||
|
||||
(bowser.opera && bowser.version >= 10.0)) {
|
||||
bowser.a = t;
|
||||
}
|
||||
|
||||
else if ((bowser.msie && bowser.version < 9) ||
|
||||
(bowser.chrome && bowser.version < 20) ||
|
||||
(bowser.firefox && bowser.version < 10.0) ||
|
||||
(bowser.safari && bowser.version < 5) ||
|
||||
(bowser.opera && bowser.version < 10.0)) {
|
||||
bowser.c = t
|
||||
} else bowser.x = t
|
||||
/*
|
||||
* Set our detect method to the main bowser object so we can
|
||||
* reuse it to test other user agents.
|
||||
* This is needed to implement future tests.
|
||||
*/
|
||||
bowser._detect = detect;
|
||||
|
||||
return bowser
|
||||
});
|
||||
|
2
bowser.min.js
vendored
2
bowser.min.js
vendored
@ -3,4 +3,4 @@
|
||||
* https://github.com/ded/bowser
|
||||
* MIT License | (c) Dustin Diaz 2013
|
||||
*/
|
||||
!function(e,t){typeof module!="undefined"&&module.exports?module.exports.browser=t():typeof define=="function"?define(t):this[e]=t()}("bowser",function(){function w(){return n?{name:"Internet Explorer",msie:t,version:e.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:h?{name:"Opera",opera:t,version:e.match(m)?e.match(m)[1]:e.match(/opr\/(\d+(\.\d+)?)/i)[1]}:r?{name:"Chrome",webkit:t,chrome:t,version:e.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1],ipad:o,iphone:s,ios:!!e.match(/crios/i),mobile:y}:i?{name:"PhantomJS",webkit:t,phantom:t,version:e.match(/phantomjs\/(\d+(\.\d+)+)/i)[1]}:a?{name:"TouchPad",webkit:t,touchpad:t,version:e.match(/touchpad\/(\d+(\.\d+)?)/i)[1]}:f?{name:"Amazon Silk",webkit:t,android:t,mobile:t,version:e.match(/silk\/(\d+(\.\d+)?)/i)[1]}:s||o||u?(b={name:s?"iPhone":o?"iPad":"iPod",webkit:t,mobile:s,ios:t,iphone:s,ipad:o,ipod:u},m.test(e)&&(b.version=e.match(m)[1]),b):c?{name:"Android",webkit:t,android:t,mobile:t,version:(e.match(m)||e.match(g))[1]}:l?{name:"Safari",webkit:t,safari:t,version:e.match(m)[1]}:d?(b={name:"Gecko",gecko:t,mozilla:t,version:e.match(g)[1]},p&&(b.name="Firefox",b.firefox=t),b):v?{name:"SeaMonkey",seamonkey:t,version:e.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]}:{}}var e=navigator.userAgent,t=!0,n=/(msie|trident)/i.test(e),r=/chrome|crios/i.test(e),i=/phantom/i.test(e),s=/iphone/i.test(e),o=/ipad/i.test(e),u=/ipod/i.test(e),a=/touchpad/i.test(e),f=/silk/i.test(e),l=/safari/i.test(e)&&!r&&!i&&!f,c=/android/i.test(e),h=/opera/i.test(e)||/opr/i.test(e),p=/firefox/i.test(e),d=/gecko\//i.test(e),v=/seamonkey\//i.test(e),m=/version\/(\d+(\.\d+)?)/i,g=/firefox\/(\d+(\.\d+)?)/i,y=/mobile/i.test(e),b,E=w();return E.msie&&E.version>=9||E.chrome&&E.version>=20||E.firefox&&E.version>=10||E.safari&&E.version>=5||E.opera&&E.version>=10?E.a=t:E.msie&&E.version<9||E.chrome&&E.version<20||E.firefox&&E.version<10||E.safari&&E.version<5||E.opera&&E.version<10?E.c=t:E.x=t,E})
|
||||
!function(e,t){typeof define=="function"?define(t):typeof module!="undefined"&&module.exports?module.exports.browser=t():this[e]=t()}("bowser",function(){function n(n){var r=/(msie|trident)/i.test(n),i=/chrome|crios/i.test(n),s=/phantom/i.test(n),o=/iphone/i.test(n),u=/ipad/i.test(n),a=/ipod/i.test(n),f=/touchpad/i.test(n),l=/silk/i.test(n),c=/safari/i.test(n)&&!i&&!s&&!l,h=/android/i.test(n),p=/opera/i.test(n)||/opr/i.test(n),d=/firefox/i.test(n),m=/gecko\//i.test(n),g=/seamonkey\//i.test(n),y=/webos/i.test(n),b=/windows phone/i.test(n),w=/blackberry/i.test(n),E=/version\/(\d+(\.\d+)?)/i,S=/firefox[ \/](\d+(\.\d+)?)/i,x=/mobile/i.test(n),T={};return b?T={name:"Windows Phone",windowsphone:e,mobile:e,version:n.match(/iemobile\/(\d+(\.\d+)?)/i)[1]}:p?((t=n.match(E))&&t.length>1?t=t[1]:(t=n.match(/opr\/(\d+(\.\d+)?)/i))&&t.length>1?t=t[1]:(t=n.match(/opera[ \/](\d+(\.\d+)?)/i))&&t.length>1?t=t[1]:t=0,T={name:"Opera",opera:e,version:t},h&&(T.android=!0,T.mobile=!0),i&&(T.webkit=!0)):r?T={name:"Internet Explorer",msie:e,version:n.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:i?T={name:"Chrome",webkit:e,chrome:e,version:n.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1],ipad:u,iphone:o,ios:!!n.match(/crios/i),mobile:x}:s?T={name:"PhantomJS",webkit:e,phantom:e,version:n.match(/phantomjs\/(\d+(\.\d+)?)/i)[1]}:f?T={name:"TouchPad",webkit:e,touchpad:e,version:n.match(/touchpad\/(\d+(\.\d+)?)/i)[1]}:l?T={name:"Amazon Silk",webkit:e,android:e,mobile:e,version:n.match(/silk\/(\d+(\.\d+)?)/i)[1]}:o||u||a?(a&&(o=!1),T={name:o?"iPhone":u?"iPad":"iPod",webkit:e,mobile:e,ios:e,iphone:o,ipad:u,ipod:a},E.test(n)&&(T.version=n.match(E)[1])):w?(T={name:"BlackBerry",blackberry:e,mobile:e},(t=n.match(E))?(T.version=t[1],T.webkit=e):T.version=n.match(/blackberry[\d]+\/(\d+(\.\d+)?)/i)[1]):y?T={name:"WebOS",mobile:e,webkit:e,webos:e,version:(n.match(E)||n.match(/wosbrowser\/(\d+(\.\d+)?)/i))[1]}:h?T={name:"Android",webkit:e,android:e,mobile:e,version:(n.match(E)||n.match(S))[1]}:c?T={name:"Safari",webkit:e,safari:e,version:(t=n.match(E))?t[1]:0}:m?(T={name:"Gecko",gecko:e,mozilla:e,version:(t=n.match(S))&&t?t[1]:0},d&&(T.name="Firefox",T.firefox=e)):g&&(T={name:"SeaMonkey",seamonkey:e,version:n.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]}),T.msie&&T.version>=9||T.chrome&&T.version>=20||T.firefox&&T.version>=10||T.safari&&T.version>=5||T.opera&&T.version>=10?T.a=e:T.msie&&T.version<9||T.chrome&&T.version<20||T.firefox&&T.version<10||T.safari&&T.version<5||T.opera&&T.version<10?T.c=e:T.x=e,T}var e=!0,t,r=n(typeof navigator!="undefined"?navigator.userAgent:"");return r._detect=n,r})
|
@ -126,7 +126,7 @@
|
||||
, webkit: t
|
||||
, webos: t
|
||||
, version: (ua.match(webkitVersion) || ua.match(/wosbrowser\/(\d+(\.\d+)?)/i))[1]
|
||||
}
|
||||
}
|
||||
else if (android) o = {
|
||||
name: 'Android'
|
||||
, webkit: t
|
||||
|
Loading…
Reference in New Issue
Block a user