mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
Merge pull request #45 from BendingBender/add-bada-detection
Added bada detection
This commit is contained in:
commit
be6296cb7f
@ -27,6 +27,7 @@ Flags set for detected Browsers[Engines]
|
||||
* BlackBerry native browser as `blackberry`[`webkit`]
|
||||
* WebOS native browser as `webos`[`webkit`]
|
||||
* Amazon Kindle browser as `silk`[`webkit`]
|
||||
* Bada browser as `bada`[`webkit`]
|
||||
|
||||
For all detected browsers the browser version is set in the `version` field.
|
||||
|
||||
@ -39,10 +40,11 @@ Flags set for detected mobile Operating Systems
|
||||
* `blackberry`
|
||||
* `firefoxos`
|
||||
* `webos` (`touchpad`)
|
||||
* `bada`
|
||||
|
||||
Android, iOS, Windows Phone, and WebOS will all report the OS version number if it is contained in the UA string in the `osversion` field. iOS is always reported as `ios` and additionally as `iphone`/`ipad`/`ipod`, whichever one matches best. If WebOS device is an HP TouchPad the flag `touchpad` is additionally set.
|
||||
Android, iOS, Windows Phone, WebOS, and Bada will all report the OS version number if it is contained in the UA string in the `osversion` field. iOS is always reported as `ios` and additionally as `iphone`/`ipad`/`ipod`, whichever one matches best. If WebOS device is an HP TouchPad the flag `touchpad` is additionally set.
|
||||
|
||||
All detected mobile OSes are additionally flagged `mobile`, **if they are not running on a tablet device**. If a tablet is detected, the flag `tablet` is set instead.
|
||||
All detected mobile OSes are additionally flagged `mobile`, **if they are not powering a tablet device**. If a tablet device is detected, the flag `tablet` is set instead.
|
||||
|
||||
Notes
|
||||
----
|
||||
|
17
bowser.js
17
bowser.js
@ -41,6 +41,7 @@
|
||||
, windowsphone = /windows phone/i.test(ua)
|
||||
, blackberry = /(blackberry|\bbb\d+)/i.test(ua)
|
||||
, rimtablet = /rim\stablet/i.test(ua)
|
||||
, bada = /bada\//i.test(ua)
|
||||
, webkitVersion = /version\/(\d+(\.\d+)?)/i
|
||||
, firefoxVersion = /firefox[ \/](\d+(\.\d+)?)/i
|
||||
, mobile = /mobi/i.test(ua)
|
||||
@ -135,6 +136,14 @@
|
||||
};
|
||||
touchpad && (o.touchpad = t)
|
||||
}
|
||||
else if (bada) {
|
||||
o = {
|
||||
name: 'Bada'
|
||||
, webkit: t
|
||||
, bada: t
|
||||
, version: getVersion(ua, /dolfin\/(\d+(\.\d+)?)/i, 1)
|
||||
};
|
||||
}
|
||||
else if (gecko) {
|
||||
o = {
|
||||
name: 'Gecko'
|
||||
@ -186,16 +195,18 @@
|
||||
osVersion = getVersion(ua, /(?:web|hpw)os\/(\d+(\.\d+)*)/i, 1);
|
||||
} else if (rimtablet) {
|
||||
osVersion = getVersion(ua, /rim\stablet\sos\s(\d+(\.\d+)*)/i, 1);
|
||||
} else if (bada) {
|
||||
osVersion = getVersion(ua, /bada\/(\d+(\.\d+)*)/i, 1);
|
||||
}
|
||||
if (osVersion) {
|
||||
o.osversion = osVersion;
|
||||
}
|
||||
|
||||
// device type extraction
|
||||
var osMajorVersion = (osVersion || "").split('.')[0];
|
||||
if (tablet || ipad || rimtablet || silk || touchpad || (android && (osMajorVersion == 3 || (osMajorVersion == 4 && !mobile)))) {
|
||||
var osMajorVersion = (osVersion || '').split('.')[0];
|
||||
if (tablet || ipad || (android && (osMajorVersion == 3 || (osMajorVersion == 4 && !mobile))) || rimtablet || silk || touchpad) {
|
||||
o.tablet = t
|
||||
} else if (iphone || ipod || (android && mobile) || windowsphone || blackberry || webos || mobile) {
|
||||
} else if (iphone || ipod || (android && mobile) || windowsphone || blackberry || webos || bada || mobile) {
|
||||
o.mobile = t
|
||||
}
|
||||
|
||||
|
2
bowser.min.js
vendored
2
bowser.min.js
vendored
@ -3,4 +3,4 @@
|
||||
* https://github.com/ded/bowser
|
||||
* MIT License | (c) Dustin Diaz 2014
|
||||
*/
|
||||
!function(e,t){typeof module!="undefined"&&module.exports?module.exports.browser=t():typeof define=="function"?define(t):this[e]=t()}("bowser",function(){function n(e,t,n){var r=e.match(t);return r&&r.length>n&&r[n]||0}function r(r){var i=/(msie|trident)/i.test(r),s=/chrome|crios|crmo/i.test(r),o=/phantom/i.test(r),u=/iphone/i.test(r),a=/ipad/i.test(r),f=/ipod/i.test(r),l=/silk/i.test(r),c=/safari/i.test(r)&&!s&&!o&&!l,h=/android/i.test(r),p=/opera/i.test(r)||/opr/i.test(r),d=/firefox/i.test(r),m=/gecko\//i.test(r),g=/seamonkey\//i.test(r),y=/(?:web|hpw)os/i.test(r),b=/touchpad\//i.test(r),w=/windows phone/i.test(r),E=/(blackberry|\bbb\d+)/i.test(r),S=/rim\stablet/i.test(r),x=/version\/(\d+(\.\d+)?)/i,T=/firefox[ \/](\d+(\.\d+)?)/i,N=/mobi/i.test(r),C=/tablet/i.test(r),k={};f&&(u=!1);if(w)k={name:"Windows Phone",windowsphone:e,msie:e,version:n(r,/iemobile\/(\d+(\.\d+)?)/i,1)};else if(p)t=n(r,x,1)||n(r,/opr\/(\d+(\.\d+)?)/i,1)||n(r,/opera[ \/](\d+(\.\d+)?)/i,1),k={name:"Opera",opera:e,version:t},h&&(k.android=e),s&&(k.webkit=e);else if(i)k={name:"Internet Explorer",msie:e,version:n(r,/(msie |rv:)(\d+(\.\d+)?)/i,2)};else if(s){k={name:"Chrome",webkit:e,chrome:e,version:n(r,/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i,1)},h&&(k.android=e);if(a||f||u)k[u?"iphone":a?"ipad":"ipod"]=e,k.ios=e}else o?k={name:"PhantomJS",webkit:e,phantom:e,version:n(r,/phantomjs\/(\d+(\.\d+)?)/i,1)}:l?k={name:"Amazon Silk",silk:e,webkit:e,android:e,version:n(r,/silk\/(\d+(\.\d+)?)/i,1)}:u||a||f?(k={name:u?"iPhone":a?"iPad":"iPod",webkit:e,ios:e},k[u?"iphone":a?"ipad":"ipod"]=e,x.test(r)&&(k.version=n(r,x,1))):E||S?(k={name:"BlackBerry",blackberry:e},(t=n(r,x,1))?(k.version=t,k.webkit=e):k.version=n(r,/blackberry[\d]+\/(\d+(\.\d+)?)/i,1)):y?(k={name:"WebOS",webkit:e,webos:e,version:n(r,x,1)||n(r,/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i,1)},b&&(k.touchpad=e)):m?(k={name:"Gecko",gecko:e,mozilla:e,version:n(r,T,1)},g?(k.name="SeaMonkey",k.seamonkey=e,k.version=n(r,/seamonkey\/(\d+(\.\d+)?)/i,1)):d&&(k.name="Firefox",k.firefox=e),h?k.android=e:!h&&d&&/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(r)&&(k.firefoxos=e)):h?k={name:"Android",webkit:e,android:e,version:n(r,x,1)}:c&&(k={name:"Safari",webkit:e,safari:e,version:n(r,x,1)});var L;h?(L=n(r,/android[ \/-](\d+(\.\d+)*)/i,1),L&&(k.osversion=L)):u||a||f?(L=n(r,/os (\d+([_\s]\d+)*) like mac os x/i,1),L=(L||"").replace(/[_\s]/g,".")):w?L=n(r,/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,1):y?L=n(r,/(?:web|hpw)os\/(\d+(\.\d+)*)/i,1):S&&(L=n(r,/rim\stablet\sos\s(\d+(\.\d+)*)/i,1)),L&&(k.osversion=L);var A=(L||"").split(".")[0];if(C||a||S||l||b||h&&(A==3||A==4&&!N))k.tablet=e;else if(u||f||h&&N||w||E||y||N)k.mobile=e;return k.msie&&k.version>=9||k.chrome&&k.version>=20||k.firefox&&k.version>=10||k.safari&&k.version>=5||k.opera&&k.version>=10||k.ios&&k.osversion&&k.osversion.split(".")[0]>=6?k.a=e:k.msie&&k.version<9||k.chrome&&k.version<20||k.firefox&&k.version<10||k.safari&&k.version<5||k.opera&&k.version<10||k.ios&&k.osversion&&k.osversion.split(".")[0]<6?k.c=e:k.x=e,k}var e=!0,t,i=r(typeof navigator!="undefined"?navigator.userAgent:"");return i._detect=r,i})
|
||||
!function(e,t){typeof module!="undefined"&&module.exports?module.exports.browser=t():typeof define=="function"?define(t):this[e]=t()}("bowser",function(){function n(e,t,n){var r=e.match(t);return r&&r.length>n&&r[n]||0}function r(r){var i=/(msie|trident)/i.test(r),s=/chrome|crios|crmo/i.test(r),o=/phantom/i.test(r),u=/iphone/i.test(r),a=/ipad/i.test(r),f=/ipod/i.test(r),l=/silk/i.test(r),c=/safari/i.test(r)&&!s&&!o&&!l,h=/android/i.test(r),p=/opera/i.test(r)||/opr/i.test(r),d=/firefox/i.test(r),m=/gecko\//i.test(r),g=/seamonkey\//i.test(r),y=/(?:web|hpw)os/i.test(r),b=/touchpad\//i.test(r),w=/windows phone/i.test(r),E=/(blackberry|\bbb\d+)/i.test(r),S=/rim\stablet/i.test(r),x=/bada\//i.test(r),T=/version\/(\d+(\.\d+)?)/i,N=/firefox[ \/](\d+(\.\d+)?)/i,C=/mobi/i.test(r),k=/tablet/i.test(r),L={};f&&(u=!1);if(w)L={name:"Windows Phone",windowsphone:e,msie:e,version:n(r,/iemobile\/(\d+(\.\d+)?)/i,1)};else if(p)t=n(r,T,1)||n(r,/opr\/(\d+(\.\d+)?)/i,1)||n(r,/opera[ \/](\d+(\.\d+)?)/i,1),L={name:"Opera",opera:e,version:t},h&&(L.android=e),s&&(L.webkit=e);else if(i)L={name:"Internet Explorer",msie:e,version:n(r,/(msie |rv:)(\d+(\.\d+)?)/i,2)};else if(s){L={name:"Chrome",webkit:e,chrome:e,version:n(r,/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i,1)},h&&(L.android=e);if(a||f||u)L[u?"iphone":a?"ipad":"ipod"]=e,L.ios=e}else o?L={name:"PhantomJS",webkit:e,phantom:e,version:n(r,/phantomjs\/(\d+(\.\d+)?)/i,1)}:l?L={name:"Amazon Silk",silk:e,webkit:e,android:e,version:n(r,/silk\/(\d+(\.\d+)?)/i,1)}:u||a||f?(L={name:u?"iPhone":a?"iPad":"iPod",webkit:e,ios:e},L[u?"iphone":a?"ipad":"ipod"]=e,T.test(r)&&(L.version=n(r,T,1))):E||S?(L={name:"BlackBerry",blackberry:e},(t=n(r,T,1))?(L.version=t,L.webkit=e):L.version=n(r,/blackberry[\d]+\/(\d+(\.\d+)?)/i,1)):y?(L={name:"WebOS",webkit:e,webos:e,version:n(r,T,1)||n(r,/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i,1)},b&&(L.touchpad=e)):x?L={name:"Bada",webkit:e,bada:e,version:n(r,/dolfin\/(\d+(\.\d+)?)/i,1)}:m?(L={name:"Gecko",gecko:e,mozilla:e,version:n(r,N,1)},g?(L.name="SeaMonkey",L.seamonkey=e,L.version=n(r,/seamonkey\/(\d+(\.\d+)?)/i,1)):d&&(L.name="Firefox",L.firefox=e),h?L.android=e:!h&&d&&/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(r)&&(L.firefoxos=e)):h?L={name:"Android",webkit:e,android:e,version:n(r,T,1)}:c&&(L={name:"Safari",webkit:e,safari:e,version:n(r,T,1)});var A;h?(A=n(r,/android[ \/-](\d+(\.\d+)*)/i,1),A&&(L.osversion=A)):u||a||f?(A=n(r,/os (\d+([_\s]\d+)*) like mac os x/i,1),A=(A||"").replace(/[_\s]/g,".")):w?A=n(r,/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,1):y?A=n(r,/(?:web|hpw)os\/(\d+(\.\d+)*)/i,1):S?A=n(r,/rim\stablet\sos\s(\d+(\.\d+)*)/i,1):x&&(A=n(r,/bada\/(\d+(\.\d+)*)/i,1)),A&&(L.osversion=A);var O=(A||"").split(".")[0];if(k||a||h&&(O==3||O==4&&!C)||S||l||b)L.tablet=e;else if(u||f||h&&C||w||E||y||x||C)L.mobile=e;return L.msie&&L.version>=9||L.chrome&&L.version>=20||L.firefox&&L.version>=10||L.safari&&L.version>=5||L.opera&&L.version>=10||L.ios&&L.osversion&&L.osversion.split(".")[0]>=6?L.a=e:L.msie&&L.version<9||L.chrome&&L.version<20||L.firefox&&L.version<10||L.safari&&L.version<5||L.opera&&L.version<10||L.ios&&L.osversion&&L.osversion.split(".")[0]<6?L.c=e:L.x=e,L}var e=!0,t,i=r(typeof navigator!="undefined"?navigator.userAgent:"");return i._detect=r,i})
|
@ -35,6 +35,7 @@
|
||||
, windowsphone = /windows phone/i.test(ua)
|
||||
, blackberry = /(blackberry|\bbb\d+)/i.test(ua)
|
||||
, rimtablet = /rim\stablet/i.test(ua)
|
||||
, bada = /bada\//i.test(ua)
|
||||
, webkitVersion = /version\/(\d+(\.\d+)?)/i
|
||||
, firefoxVersion = /firefox[ \/](\d+(\.\d+)?)/i
|
||||
, mobile = /mobi/i.test(ua)
|
||||
@ -129,6 +130,14 @@
|
||||
};
|
||||
touchpad && (o.touchpad = t)
|
||||
}
|
||||
else if (bada) {
|
||||
o = {
|
||||
name: 'Bada'
|
||||
, webkit: t
|
||||
, bada: t
|
||||
, version: getVersion(ua, /dolfin\/(\d+(\.\d+)?)/i, 1)
|
||||
};
|
||||
}
|
||||
else if (gecko) {
|
||||
o = {
|
||||
name: 'Gecko'
|
||||
@ -180,16 +189,18 @@
|
||||
osVersion = getVersion(ua, /(?:web|hpw)os\/(\d+(\.\d+)*)/i, 1);
|
||||
} else if (rimtablet) {
|
||||
osVersion = getVersion(ua, /rim\stablet\sos\s(\d+(\.\d+)*)/i, 1);
|
||||
} else if (bada) {
|
||||
osVersion = getVersion(ua, /bada\/(\d+(\.\d+)*)/i, 1);
|
||||
}
|
||||
if (osVersion) {
|
||||
o.osversion = osVersion;
|
||||
}
|
||||
|
||||
// device type extraction
|
||||
var osMajorVersion = (osVersion || "").split('.')[0];
|
||||
if (tablet || ipad || rimtablet || silk || touchpad || (android && (osMajorVersion == 3 || (osMajorVersion == 4 && !mobile)))) {
|
||||
var osMajorVersion = (osVersion || '').split('.')[0];
|
||||
if (tablet || ipad || (android && (osMajorVersion == 3 || (osMajorVersion == 4 && !mobile))) || rimtablet || silk || touchpad) {
|
||||
o.tablet = t
|
||||
} else if (iphone || ipod || (android && mobile) || windowsphone || blackberry || webos || mobile) {
|
||||
} else if (iphone || ipod || (android && mobile) || windowsphone || blackberry || webos || bada || mobile) {
|
||||
o.mobile = t
|
||||
}
|
||||
|
||||
|
@ -846,6 +846,32 @@ module.exports.useragents = {
|
||||
, x: true
|
||||
}
|
||||
}
|
||||
, Bada: {
|
||||
'Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S8500/S8500XPKJ1; U; Bada/2.0; it-it) AppleWebKit/534.20 (KHTML, like Gecko) Dolfin/3.0 WVGA SMM-MMS/1.2.0 OPN-B': {
|
||||
bada: true
|
||||
, osversion: '2.0'
|
||||
, webkit: true
|
||||
, version: '3.0'
|
||||
, mobile: true
|
||||
, x: true
|
||||
}
|
||||
, 'Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S8500/S8500XXJL2; U; Bada/1.2; de-de) AppleWebKit/533.1 (KHTML, like Gecko) Dolfin/2.2 Mobile WVGA SMM-MMS/1.2.0 OPN-B': {
|
||||
bada: true
|
||||
, osversion: '1.2'
|
||||
, webkit: true
|
||||
, version: '2.2'
|
||||
, mobile: true
|
||||
, x: true
|
||||
}
|
||||
, 'Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S8500/S8500XXJF4; U; Bada/1.0; fr-fr) AppleWebKit/533.1 (KHTML, like Gecko) Dolfin/2.0 Mobile WVGA SMM-MMS/1.2.0 OPN-B': {
|
||||
bada: true
|
||||
, osversion: '1.0'
|
||||
, webkit: true
|
||||
, version: '2.0'
|
||||
, mobile: true
|
||||
, x: true
|
||||
}
|
||||
}
|
||||
, PhantomJS: {
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.5.0 Safari/534.34': {
|
||||
phantom: true
|
||||
|
Loading…
Reference in New Issue
Block a user