diff --git a/bowser.js b/bowser.js index 9edefc1..252c5b0 100644 --- a/bowser.js +++ b/bowser.js @@ -81,12 +81,16 @@ var iphone = uaTest(/iphone/i) , ipad = uaTest(/ipad/i) + , ipod = uaTest(/ipod/i) , webkitVersion = versionTest(STR_VERSION + '\/') , firefoxVersion = versionTest(STR_FIREFOX + '[\/ ]') , o = {} , version = 0; - if (uaTest(/(msie|trident)/i)) { + if (uaTest(/windows phone/i)) { + o.windowsphone = o[STR_MOBILE] = TRUE; + o[STR_VERSION] = versionTest('iemobile\/'); + } else if (uaTest(/(msie|trident)/i)) { o[STR_MSIE] = TRUE; o[STR_VERSION] = versionTest('(msie |rv:)', 2); } else if (uaTest(/opera/i) || uaTest(/opr/i)) { @@ -101,15 +105,28 @@ } else if (uaTest(/touchpad/i)) { o.touchpad = o[STR_WEBKIT] = TRUE; o[STR_VERSION] = versionTest('touchpad\/'); - } else if (iphone || ipad) { + } else if (iphone || ipad || ipod) { o.ios = o[STR_MOBILE] = o[STR_WEBKIT] = TRUE; - // WTF: version is not part of user agent in web apps + // CAUTION: version is not part of user agent in web apps o[STR_VERSION] = webkitVersion; - if (iphone) { + if (ipod) { + o.ipod = TRUE; + } else if (iphone) { o.iphone = TRUE; } else if (ipad) { o.ipad = TRUE; } + } else if (uaTest(/blackberry/i)) { + o.blackberry = o[STR_MOBILE] = TRUE; + if (webkitVersion) { + o[STR_WEBKIT] = TRUE; + o[STR_VERSION] = webkitVersion; + } else { + o[STR_VERSION] = versionTest('blackberry[\\d]+\/'); + } + } else if (uaTest(/webos/i)) { + o.webos = o[STR_MOBILE] = o[STR_WEBKIT] = TRUE; + o[STR_VERSION] = webkitVersion || versionTest('wosbrowser\/'); } else if (uaTest(/android/i)) { o.android = o[STR_MOBILE] = o[STR_WEBKIT] = TRUE; o[STR_VERSION] = webkitVersion || firefoxVersion; diff --git a/bowser.min.js b/bowser.min.js index a7f0b78..24a6344 100644 --- a/bowser.min.js +++ b/bowser.min.js @@ -3,4 +3,4 @@ * https://github.com/ded/bowser * MIT License | (c) Dustin Diaz 2013 */ -!function(e,t){typeof define=="function"?define(t):typeof module!="undefined"&&module.exports?module.exports[e]=t():this[e]=t()}("bowser",function(){function f(f){function l(e){return e.test(f)}function c(e,t){var n=f.match(new RegExp(e+"(\\d+(\\.\\d+)?)","i"));return n?n[t||1]:0}var h=l(/iphone/i),p=l(/ipad/i),d=c(t+"/"),v=c(a+"[/ ]"),m={},g=0;return l(/(msie|trident)/i)?(m[r]=e,m[t]=c("(msie |rv:)",2)):l(/opera/i)||l(/opr/i)?(m[i]=e,m[t]=d||c("opr/")):l(/chrome/i)?(m[s]=m[o]=e,m[t]=c(s+"/")):l(/phantom/i)?(m.phantom=m[o]=e,m[t]=c("phantomjs/")):l(/touchpad/i)?(m.touchpad=m[o]=e,m[t]=c("touchpad/")):h||p?(m.ios=m[n]=m[o]=e,m[t]=d,h?m.iphone=e:p&&(m.ipad=e)):l(/android/i)?(m.android=m[n]=m[o]=e,m[t]=d||v):l(/safari/i)?(m[u]=m[o]=e,m[t]=d):l(/gecko\//i)?(m.gecko=m.mozilla=e,m[t]=v,l(/firefox/i)&&(m.firefox=e)):l(/seamonkey\//i)?(m.seamonkey=e,m[t]=c("seamonkey/")):m[t]=0,g=m[t],m[r]&&g>=8||m[s]&&g>=10||m[a]&&g>=4||m[u]&&g>=5||m[i]&&g>=10?m.a=e:m[r]&&g<8||m[s]&&g<10||m[a]&&g<4||m[u]&&g<5||m[i]&&g<10?m.c=e:m.x=e,m}var e=!0,t="version",n="mobile",r="msie",i="opera",s="chrome",o="webkit",u="safari",a="firefox",l=f(typeof navigator!="undefined"?navigator.userAgent:"");return l._detect=f,l}) \ No newline at end of file +!function(e,t){typeof define=="function"?define(t):typeof module!="undefined"&&module.exports?module.exports[e]=t():this[e]=t()}("bowser",function(){function f(f){function l(e){return e.test(f)}function c(e,t){var n=f.match(new RegExp(e+"(\\d+(\\.\\d+)?)","i"));return n?n[t||1]:0}var h=l(/iphone/i),p=l(/ipad/i),d=l(/ipod/i),v=c(t+"/"),m=c(a+"[/ ]"),g={},y=0;return l(/windows phone/i)?(g.windowsphone=g[n]=e,g[t]=c("iemobile/")):l(/(msie|trident)/i)?(g[r]=e,g[t]=c("(msie |rv:)",2)):l(/opera/i)||l(/opr/i)?(g[i]=e,g[t]=v||c("opr/")):l(/chrome/i)?(g[s]=g[o]=e,g[t]=c(s+"/")):l(/phantom/i)?(g.phantom=g[o]=e,g[t]=c("phantomjs/")):l(/touchpad/i)?(g.touchpad=g[o]=e,g[t]=c("touchpad/")):h||p||d?(g.ios=g[n]=g[o]=e,g[t]=v,d?g.ipod=e:h?g.iphone=e:p&&(g.ipad=e)):l(/blackberry/i)?(g.blackberry=g[n]=e,v?(g[o]=e,g[t]=v):g[t]=c("blackberry[\\d]+/")):l(/webos/i)?(g.webos=g[n]=g[o]=e,g[t]=v||c("wosbrowser/")):l(/android/i)?(g.android=g[n]=g[o]=e,g[t]=v||m):l(/safari/i)?(g[u]=g[o]=e,g[t]=v):l(/gecko\//i)?(g.gecko=g.mozilla=e,g[t]=m,l(/firefox/i)&&(g.firefox=e)):l(/seamonkey\//i)?(g.seamonkey=e,g[t]=c("seamonkey/")):g[t]=0,y=g[t],g[r]&&y>=8||g[s]&&y>=10||g[a]&&y>=4||g[u]&&y>=5||g[i]&&y>=10?g.a=e:g[r]&&y<8||g[s]&&y<10||g[a]&&y<4||g[u]&&y<5||g[i]&&y<10?g.c=e:g.x=e,g}var e=!0,t="version",n="mobile",r="msie",i="opera",s="chrome",o="webkit",u="safari",a="firefox",l=f(typeof navigator!="undefined"?navigator.userAgent:"");return l._detect=f,l}) \ No newline at end of file diff --git a/src/bowser.js b/src/bowser.js index 721da88..e5d1edc 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -75,12 +75,16 @@ var iphone = uaTest(/iphone/i) , ipad = uaTest(/ipad/i) + , ipod = uaTest(/ipod/i) , webkitVersion = versionTest(STR_VERSION + '\/') , firefoxVersion = versionTest(STR_FIREFOX + '[\/ ]') , o = {} , version = 0; - if (uaTest(/(msie|trident)/i)) { + if (uaTest(/windows phone/i)) { + o.windowsphone = o[STR_MOBILE] = TRUE; + o[STR_VERSION] = versionTest('iemobile\/'); + } else if (uaTest(/(msie|trident)/i)) { o[STR_MSIE] = TRUE; o[STR_VERSION] = versionTest('(msie |rv:)', 2); } else if (uaTest(/opera/i) || uaTest(/opr/i)) { @@ -95,15 +99,28 @@ } else if (uaTest(/touchpad/i)) { o.touchpad = o[STR_WEBKIT] = TRUE; o[STR_VERSION] = versionTest('touchpad\/'); - } else if (iphone || ipad) { + } else if (iphone || ipad || ipod) { o.ios = o[STR_MOBILE] = o[STR_WEBKIT] = TRUE; - // WTF: version is not part of user agent in web apps + // CAUTION: version is not part of user agent in web apps o[STR_VERSION] = webkitVersion; - if (iphone) { + if (ipod) { + o.ipod = TRUE; + } else if (iphone) { o.iphone = TRUE; } else if (ipad) { o.ipad = TRUE; } + } else if (uaTest(/blackberry/i)) { + o.blackberry = o[STR_MOBILE] = TRUE; + if (webkitVersion) { + o[STR_WEBKIT] = TRUE; + o[STR_VERSION] = webkitVersion; + } else { + o[STR_VERSION] = versionTest('blackberry[\\d]+\/'); + } + } else if (uaTest(/webos/i)) { + o.webos = o[STR_MOBILE] = o[STR_WEBKIT] = TRUE; + o[STR_VERSION] = webkitVersion || versionTest('wosbrowser\/'); } else if (uaTest(/android/i)) { o.android = o[STR_MOBILE] = o[STR_WEBKIT] = TRUE; o[STR_VERSION] = webkitVersion || firefoxVersion;