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

Merge pull request #47 from BendingBender/add-tizen-detection

Added tizen detection
This commit is contained in:
Dustin Diaz 2014-03-01 10:11:03 -08:00
commit 87616180cf
5 changed files with 82 additions and 22 deletions

View File

@ -28,6 +28,7 @@ Flags set for detected Browsers[Engines]
* WebOS native browser as `webos`[`webkit`]
* Amazon Kindle browser as `silk`[`webkit`]
* Bada browser as `bada`[`webkit`]
* Tizen browser as `tizen`[`webkit`]
For all detected browsers the browser version is set in the `version` field.
@ -41,8 +42,9 @@ Flags set for detected mobile Operating Systems
* `firefoxos`
* `webos` (`touchpad`)
* `bada`
* `tizen`
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.
Android, iOS, Windows Phone, WebOS, Bada, and Tizen 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 powering a tablet device**. If a tablet device is detected, the flag `tablet` is set instead.

View File

@ -41,7 +41,8 @@
, windowsphone = /windows phone/i.test(ua)
, blackberry = /(blackberry|\bbb\d+)/i.test(ua)
, rimtablet = /rim\stablet/i.test(ua)
, bada = /bada\//i.test(ua)
, bada = /bada/i.test(ua)
, tizen = /tizen/i.test(ua)
, webkitVersion = /version\/(\d+(\.\d+)?)/i
, firefoxVersion = /(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i
, mobile = /mobi/i.test(ua)
@ -144,6 +145,14 @@
, version: getVersion(ua, /dolfin\/(\d+(\.\d+)?)/i, 1)
};
}
else if (tizen) {
o = {
name: 'Tizen'
, webkit: t
, tizen: t
, version: getVersion(ua, /(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i, 1) || getVersion(ua, webkitVersion, 1)
};
}
else if (gecko) {
o = {
name: 'Gecko'
@ -181,14 +190,8 @@
// OS version extraction
var osVersion;
if (android) {
osVersion = getVersion(ua, /android[ \/-](\d+(\.\d+)*)/i, 1);
if (osVersion) {
o.osversion = osVersion;
}
} else if (iphone || ipad || ipod) {
osVersion = getVersion(ua, /os (\d+([_\s]\d+)*) like mac os x/i, 1);
osVersion = (osVersion || "").replace(/[_\s]/g, '.');
if (tizen) {
osVersion = getVersion(ua, /tizen[\/\s](\d+(\.\d+)*)/i, 1);
} else if (windowsphone) {
osVersion = getVersion(ua, /windows phone (?:os)?\s?(\d+(\.\d+)*)/i, 1);
} else if (webos) {
@ -197,6 +200,11 @@
osVersion = getVersion(ua, /rim\stablet\sos\s(\d+(\.\d+)*)/i, 1);
} else if (bada) {
osVersion = getVersion(ua, /bada\/(\d+(\.\d+)*)/i, 1);
} else if (iphone || ipad || ipod) {
osVersion = getVersion(ua, /os (\d+([_\s]\d+)*) like mac os x/i, 1);
osVersion = (osVersion || "").replace(/[_\s]/g, '.');
} else if (android) {
osVersion = getVersion(ua, /android[ \/-](\d+(\.\d+)*)/i, 1);
}
if (osVersion) {
o.osversion = osVersion;
@ -206,7 +214,7 @@
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 || bada || mobile) {
} else if (iphone || ipod || (android && mobile) || windowsphone || blackberry || webos || bada || tizen || mobile) {
o.mobile = t
}

2
bowser.min.js vendored
View File

@ -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|iceweasel)/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|iceweasel)[ \/](\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})
!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|iceweasel)/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=/tizen/i.test(r),N=/version\/(\d+(\.\d+)?)/i,C=/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i,k=/mobi/i.test(r),L=/tablet/i.test(r),A={};f&&(u=!1);if(w)A={name:"Windows Phone",windowsphone:e,msie:e,version:n(r,/iemobile\/(\d+(\.\d+)?)/i,1)};else if(p)t=n(r,N,1)||n(r,/opr\/(\d+(\.\d+)?)/i,1)||n(r,/opera[ \/](\d+(\.\d+)?)/i,1),A={name:"Opera",opera:e,version:t},h&&(A.android=e),s&&(A.webkit=e);else if(i)A={name:"Internet Explorer",msie:e,version:n(r,/(msie |rv:)(\d+(\.\d+)?)/i,2)};else if(s){A={name:"Chrome",webkit:e,chrome:e,version:n(r,/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i,1)},h&&(A.android=e);if(a||f||u)A[u?"iphone":a?"ipad":"ipod"]=e,A.ios=e}else o?A={name:"PhantomJS",webkit:e,phantom:e,version:n(r,/phantomjs\/(\d+(\.\d+)?)/i,1)}:l?A={name:"Amazon Silk",silk:e,webkit:e,android:e,version:n(r,/silk\/(\d+(\.\d+)?)/i,1)}:u||a||f?(A={name:u?"iPhone":a?"iPad":"iPod",webkit:e,ios:e},A[u?"iphone":a?"ipad":"ipod"]=e,N.test(r)&&(A.version=n(r,N,1))):E||S?(A={name:"BlackBerry",blackberry:e},(t=n(r,N,1))?(A.version=t,A.webkit=e):A.version=n(r,/blackberry[\d]+\/(\d+(\.\d+)?)/i,1)):y?(A={name:"WebOS",webkit:e,webos:e,version:n(r,N,1)||n(r,/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i,1)},b&&(A.touchpad=e)):x?A={name:"Bada",webkit:e,bada:e,version:n(r,/dolfin\/(\d+(\.\d+)?)/i,1)}:T?A={name:"Tizen",webkit:e,tizen:e,version:n(r,/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i,1)||n(r,N,1)}:m?(A={name:"Gecko",gecko:e,mozilla:e,version:n(r,C,1)},g?(A.name="SeaMonkey",A.seamonkey=e,A.version=n(r,/seamonkey\/(\d+(\.\d+)?)/i,1)):d&&(A.name="Firefox",A.firefox=e),h?A.android=e:!h&&d&&/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(r)&&(A.firefoxos=e)):h?A={name:"Android",webkit:e,android:e,version:n(r,N,1)}:c&&(A={name:"Safari",webkit:e,safari:e,version:n(r,N,1)});var O;T?O=n(r,/tizen[\/\s](\d+(\.\d+)*)/i,1):w?O=n(r,/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,1):y?O=n(r,/(?:web|hpw)os\/(\d+(\.\d+)*)/i,1):S?O=n(r,/rim\stablet\sos\s(\d+(\.\d+)*)/i,1):x?O=n(r,/bada\/(\d+(\.\d+)*)/i,1):u||a||f?(O=n(r,/os (\d+([_\s]\d+)*) like mac os x/i,1),O=(O||"").replace(/[_\s]/g,".")):h&&(O=n(r,/android[ \/-](\d+(\.\d+)*)/i,1)),O&&(A.osversion=O);var M=(O||"").split(".")[0];if(L||a||h&&(M==3||M==4&&!k)||S||l||b)A.tablet=e;else if(u||f||h&&k||w||E||y||x||T||k)A.mobile=e;return A.msie&&A.version>=9||A.chrome&&A.version>=20||A.firefox&&A.version>=10||A.safari&&A.version>=5||A.opera&&A.version>=10||A.ios&&A.osversion&&A.osversion.split(".")[0]>=6?A.a=e:A.msie&&A.version<9||A.chrome&&A.version<20||A.firefox&&A.version<10||A.safari&&A.version<5||A.opera&&A.version<10||A.ios&&A.osversion&&A.osversion.split(".")[0]<6?A.c=e:A.x=e,A}var e=!0,t,i=r(typeof navigator!="undefined"?navigator.userAgent:"");return i._detect=r,i})

View File

@ -35,7 +35,8 @@
, windowsphone = /windows phone/i.test(ua)
, blackberry = /(blackberry|\bbb\d+)/i.test(ua)
, rimtablet = /rim\stablet/i.test(ua)
, bada = /bada\//i.test(ua)
, bada = /bada/i.test(ua)
, tizen = /tizen/i.test(ua)
, webkitVersion = /version\/(\d+(\.\d+)?)/i
, firefoxVersion = /(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i
, mobile = /mobi/i.test(ua)
@ -138,6 +139,14 @@
, version: getVersion(ua, /dolfin\/(\d+(\.\d+)?)/i, 1)
};
}
else if (tizen) {
o = {
name: 'Tizen'
, webkit: t
, tizen: t
, version: getVersion(ua, /(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i, 1) || getVersion(ua, webkitVersion, 1)
};
}
else if (gecko) {
o = {
name: 'Gecko'
@ -175,14 +184,8 @@
// OS version extraction
var osVersion;
if (android) {
osVersion = getVersion(ua, /android[ \/-](\d+(\.\d+)*)/i, 1);
if (osVersion) {
o.osversion = osVersion;
}
} else if (iphone || ipad || ipod) {
osVersion = getVersion(ua, /os (\d+([_\s]\d+)*) like mac os x/i, 1);
osVersion = (osVersion || "").replace(/[_\s]/g, '.');
if (tizen) {
osVersion = getVersion(ua, /tizen[\/\s](\d+(\.\d+)*)/i, 1);
} else if (windowsphone) {
osVersion = getVersion(ua, /windows phone (?:os)?\s?(\d+(\.\d+)*)/i, 1);
} else if (webos) {
@ -191,6 +194,11 @@
osVersion = getVersion(ua, /rim\stablet\sos\s(\d+(\.\d+)*)/i, 1);
} else if (bada) {
osVersion = getVersion(ua, /bada\/(\d+(\.\d+)*)/i, 1);
} else if (iphone || ipad || ipod) {
osVersion = getVersion(ua, /os (\d+([_\s]\d+)*) like mac os x/i, 1);
osVersion = (osVersion || "").replace(/[_\s]/g, '.');
} else if (android) {
osVersion = getVersion(ua, /android[ \/-](\d+(\.\d+)*)/i, 1);
}
if (osVersion) {
o.osversion = osVersion;
@ -200,7 +208,7 @@
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 || bada || mobile) {
} else if (iphone || ipod || (android && mobile) || windowsphone || blackberry || webos || bada || tizen || mobile) {
o.mobile = t
}

View File

@ -886,6 +886,48 @@ module.exports.useragents = {
, x: true
}
}
, Tizen: {
'Mozilla/5.0 (Linux; Tizen 2.2; sdk) AppleWebKit/537.3 (KHTML, like Gecko) Version/2.2 Mobile Safari/537.3': {
tizen: true
, osversion: '2.2'
, webkit: true
, version: '2.2'
, mobile: true
, x: true
}
, 'Mozilla/5.0 (Linux; Tizen 2.1; sdk) AppleWebKit/537.3 (KHTML, like Gecko) Version/2.1 Mobile Safari/537.3': {
tizen: true
, osversion: '2.1'
, webkit: true
, version: '2.1'
, mobile: true
, x: true
}
, 'Mozilla/5.0 (Linux; U; Tizen 2.0; en-us) AppleWebKit/537.1 (KHTML, like Gecko) Mobile TizenBrowser/2.0': {
tizen: true
, osversion: '2.0'
, webkit: true
, version: '2.0'
, mobile: true
, x: true
}
, 'Mozilla/5.0 (Linux; U; Tizen/1.0 like Android; en-us; AppleWebKit/534.46 (KHTML, like Gecko) Tizen Browser/1.0 Mobile': {
tizen: true
, osversion: '1.0'
, webkit: true
, version: '1.0'
, mobile: true
, x: true
}
, 'Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-i9500/1.0; U; Tizen/1.0 like Android; en-us) AppleWebKit/534.46 (KHTML, like Gecko) SLP Browser/1.0 Mobile': {
tizen: true
, osversion: '1.0'
, webkit: true
, version: '1.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