1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00

Add support for ipod, windowsphone, webos and blackberry.

This commit is contained in:
Hannes Diercks 2013-12-16 06:52:33 +01:00
parent 89cffac4a5
commit 8668678f8a
3 changed files with 134 additions and 5 deletions

View File

@ -13,11 +13,21 @@ if (bowser.msie && bowser.version <= 6) {
Detected Browsers Detected Browsers
----- -----
* msie * android
* safari[webkit] * blackberry
* chrome[webkit] * chrome[webkit]
* firefox[gecko] * firefox[gecko]
* ipad
* iphone
* ipod
* msie
* opera * opera
* phantomjs
* safari[webkit]
* seamonkey
* touchpad
* webos
* windows phone
Notes Notes
---- ----

View File

@ -18,17 +18,27 @@
, safari = /safari/i.test(ua) && !chrome && !phantom , safari = /safari/i.test(ua) && !chrome && !phantom
, iphone = /iphone/i.test(ua) , iphone = /iphone/i.test(ua)
, ipad = /ipad/i.test(ua) , ipad = /ipad/i.test(ua)
, ipod = /ipod/i.test(ua)
, touchpad = /touchpad/i.test(ua) , touchpad = /touchpad/i.test(ua)
, android = /android/i.test(ua) , android = /android/i.test(ua)
, opera = /opera/i.test(ua) || /opr/i.test(ua) , opera = /opera/i.test(ua) || /opr/i.test(ua)
, firefox = /firefox/i.test(ua) , firefox = /firefox/i.test(ua)
, gecko = /gecko\//i.test(ua) , gecko = /gecko\//i.test(ua)
, seamonkey = /seamonkey\//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 , webkitVersion = /version\/(\d+(\.\d+)?)/i
, firefoxVersion = /firefox[ \/](\d+(\.\d+)?)/i , firefoxVersion = /firefox[ \/](\d+(\.\d+)?)/i
, o = {} , o = {}
if (opera) { 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] 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(/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 if ((v = ua.match(/opera[ \/](\d+(\.\d+)?)/i)) && v.length > 1) v = v[1]
@ -61,20 +71,42 @@
, touchpad: t , touchpad: t
, version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1] , version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1]
} }
else if (iphone || ipad) { else if (iphone || ipad || ipod) {
if (ipod) iphone = false
o = { o = {
name : iphone ? 'iPhone' : 'iPad' name : iphone ? 'iPhone' : ipad ? 'iPad' : 'iPod'
, webkit: t , webkit: t
, mobile: t , mobile: t
, ios: t , ios: t
, iphone: iphone , iphone: iphone
, ipad: ipad , ipad: ipad
, ipod: ipod
} }
// WTF: version is not part of user agent in web apps // WTF: version is not part of user agent in web apps
if (webkitVersion.test(ua)) { if (webkitVersion.test(ua)) {
o.version = ua.match(webkitVersion)[1] o.version = ua.match(webkitVersion)[1]
} }
} }
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 = { else if (android) o = {
name: 'Android' name: 'Android'
, webkit: t , webkit: t

View File

@ -283,6 +283,7 @@ module.exports.useragents = {
, version: '5.0' , version: '5.0'
, iphone: true , iphone: true
, ipad: false , ipad: false
, ipod: false
, mobile: true , mobile: true
, webkit: true , webkit: true
, x: true , x: true
@ -292,6 +293,7 @@ module.exports.useragents = {
, version: '3.0' , version: '3.0'
, iphone: true , iphone: true
, ipad: false , ipad: false
, ipod: false
, mobile: true , mobile: true
, webkit: true , webkit: true
, x: true , x: true
@ -301,6 +303,7 @@ module.exports.useragents = {
, version: '4.0' , version: '4.0'
, iphone: true , iphone: true
, ipad: false , ipad: false
, ipod: false
, mobile: true , mobile: true
, webkit: true , webkit: true
, x: true , x: true
@ -310,6 +313,7 @@ module.exports.useragents = {
, version: '3.1' , version: '3.1'
, iphone: true , iphone: true
, ipad: false , ipad: false
, ipod: false
, mobile: true , mobile: true
, webkit: true , webkit: true
, x: true , x: true
@ -321,6 +325,7 @@ module.exports.useragents = {
, version: '6.0' , version: '6.0'
, iphone: false , iphone: false
, ipad: true , ipad: true
, ipod: false
, mobile: true , mobile: true
, webkit: true , webkit: true
, x: true , x: true
@ -330,6 +335,7 @@ module.exports.useragents = {
, version: '5.1' , version: '5.1'
, iphone: false , iphone: false
, ipad: true , ipad: true
, ipod: false
, mobile: true , mobile: true
, webkit: true , webkit: true
, x: true , x: true
@ -339,6 +345,7 @@ module.exports.useragents = {
, version: '5.0' , version: '5.0'
, iphone: false , iphone: false
, ipad: true , ipad: true
, ipod: false
, mobile: true , mobile: true
, webkit: true , webkit: true
, x: true , x: true
@ -348,11 +355,91 @@ module.exports.useragents = {
, version: '4.0' , version: '4.0'
, iphone: false , iphone: false
, ipad: true , ipad: true
, ipod: false
, mobile: true , mobile: true
, webkit: true , webkit: true
, x: true , x: true
} }
} }
, iPod: {
'Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5': {
ios: true
, version: '5.0'
, iphone: false
, ipad: false
, ipod: true
, mobile: true
, webkit: true
, x: true
}
, 'Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A93 Safari/419.3': {
ios: true
, version: '3.0'
, iphone: false
, ipad: false
, ipod: true
, mobile: true
, webkit: true
, x: true
}
}
, BlackBerry: {
'Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.1.0.346 Mobile Safari/534.11+': {
blackberry: true
, version: '7.1'
, webkit: true
, mobile: true
, x: true
}
, 'Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en-US) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.450 Mobile Safari/534.8+': {
blackberry: true
, version: '6.0'
, webkit: true
, mobile: true
, x: true
}
, 'BlackBerry9800/5.0.0.862 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/331 UNTRUSTED/1.0 3gpp-gba': {
blackberry: true
, version: '5.0'
, mobile: true
, x: true
}
, 'BlackBerry8320/4.5.0.52 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/179': {
blackberry: true
, version: '4.5'
, mobile: true
, x: true
}
}
, 'Windows Phone': {
'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)': {
windowsphone: true
, version: '10.0'
, mobile: true
, x: true
}
, 'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)': {
windowsphone: true
, version: '9.0'
, mobile: true
, x: true
}
, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; Nokia;N70)': {
windowsphone: true
, version: '7.0'
, mobile: true
, x: true
}
}
, WebOS: {
'Mozilla/5.0 (webOS/1.0; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Pre/1.0': {
webos: true
, webkit: true
, version: '1.0'
, mobile: true
, x: true
}
}
, Android: { , 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': { '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': {
android: true android: true