From 647b7d77f8d1b6309276750684cbb9441701ad0d Mon Sep 17 00:00:00 2001 From: Bob Lauer Date: Thu, 5 Dec 2013 14:00:02 -0600 Subject: [PATCH] Added name property --- bowser.js | 35 ++++++++++++++++++++++++----------- bowser.min.js | 2 +- src/bowser.js | 35 ++++++++++++++++++++++++----------- 3 files changed, 49 insertions(+), 23 deletions(-) diff --git a/bowser.js b/bowser.js index dac6084..34ccdf1 100644 --- a/bowser.js +++ b/bowser.js @@ -45,31 +45,37 @@ function detect() { if (ie) return { - msie: t + name: 'Internet Explorer' + , msie: t , version: ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2] } if (opera) return { - opera: t + name: 'Opera' + , opera: t , version: ua.match(webkitVersion) ? ua.match(webkitVersion)[1] : ua.match(/opr\/(\d+(\.\d+)?)/i)[1] } if (chrome) return { - webkit: t + name: 'Chrome' + , webkit: t , chrome: t , version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1] } if (phantom) return { - webkit: t + name: 'PhantomJS' + , webkit: t , phantom: t , version: ua.match(/phantomjs\/(\d+(\.\d+)+)/i)[1] } if (touchpad) return { - webkit: t + name: 'TouchPad' + , webkit: t , touchpad: t , version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1] } if (iphone || ipad) { o = { - webkit: t + name : iphone ? 'iPhone' : 'iPad' + , webkit: t , mobile: t , ios: t , iphone: iphone @@ -82,27 +88,34 @@ return o } if (android) return { - webkit: t + name: 'Android' + , webkit: t , android: t , mobile: t , version: (ua.match(webkitVersion) || ua.match(firefoxVersion))[1] } if (safari) return { - webkit: t + name: 'Safari' + , webkit: t , safari: t , version: ua.match(webkitVersion)[1] } if (gecko) { o = { - gecko: t + name: 'Gecko' + , gecko: t , mozilla: t , version: ua.match(firefoxVersion)[1] } - if (firefox) o.firefox = t + if (firefox) { + o.name = 'Firefox'; + o.firefox = t; + } return o } if (seamonkey) return { - seamonkey: t + name: 'SeaMonkey' + , seamonkey: t , version: ua.match(/seamonkey\/(\d+(\.\d+)?)/i)[1] } return {} diff --git a/bowser.min.js b/bowser.min.js index c2b4ad1..775037f 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.browser=t():this[e]=t()}("bowser",function(){function g(){return n?{msie:t,version:e.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:l?{opera:t,version:e.match(d)?e.match(d)[1]:e.match(/opr\/(\d+(\.\d+)?)/i)[1]}:r?{webkit:t,chrome:t,version:e.match(/chrome\/(\d+(\.\d+)?)/i)[1]}:i?{webkit:t,phantom:t,version:e.match(/phantomjs\/(\d+(\.\d+)+)/i)[1]}:a?{webkit:t,touchpad:t,version:e.match(/touchpad\/(\d+(\.\d+)?)/i)[1]}:o||u?(m={webkit:t,mobile:t,ios:t,iphone:o,ipad:u},d.test(e)&&(m.version=e.match(d)[1]),m):f?{webkit:t,android:t,mobile:t,version:(e.match(d)||e.match(v))[1]}:s?{webkit:t,safari:t,version:e.match(d)[1]}:h?(m={gecko:t,mozilla:t,version:e.match(v)[1]},c&&(m.firefox=t),m):p?{seamonkey:t,version:e.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]}:{}}var e=navigator.userAgent,t=!0,n=/(msie|trident)/i.test(e),r=/chrome/i.test(e),i=/phantom/i.test(e),s=/safari/i.test(e)&&!r&&!i,o=/iphone/i.test(e),u=/ipad/i.test(e),a=/touchpad/i.test(e),f=/android/i.test(e),l=/opera/i.test(e)||/opr/i.test(e),c=/firefox/i.test(e),h=/gecko\//i.test(e),p=/seamonkey\//i.test(e),d=/version\/(\d+(\.\d+)?)/i,v=/firefox\/(\d+(\.\d+)?)/i,m,y=g();return y.msie&&y.version>=8||y.chrome&&y.version>=10||y.firefox&&y.version>=4||y.safari&&y.version>=5||y.opera&&y.version>=10?y.a=t:y.msie&&y.version<8||y.chrome&&y.version<10||y.firefox&&y.version<4||y.safari&&y.version<5||y.opera&&y.version<10?y.c=t:y.x=t,y}) \ No newline at end of file +!function(e,t){typeof define=="function"?define(t):typeof module!="undefined"&&module.exports?module.exports.browser=t():this[e]=t()}("bowser",function(){function g(){return n?{name:"Internet Explorer",msie:t,version:e.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:l?{name:"Opera",opera:t,version:e.match(d)?e.match(d)[1]:e.match(/opr\/(\d+(\.\d+)?)/i)[1]}:r?{name:"Chrome",webkit:t,chrome:t,version:e.match(/chrome\/(\d+(\.\d+)?)/i)[1]}: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]}:o||u?(m={name:o?"iPhone":"iPad",webkit:t,mobile:t,ios:t,iphone:o,ipad:u},d.test(e)&&(m.version=e.match(d)[1]),m):f?{name:"Android",webkit:t,android:t,mobile:t,version:(e.match(d)||e.match(v))[1]}:s?{name:"Safari",webkit:t,safari:t,version:e.match(d)[1]}:h?(m={name:"Gecko",gecko:t,mozilla:t,version:e.match(v)[1]},c&&(m.name="Firefox",m.firefox=t),m):p?{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/i.test(e),i=/phantom/i.test(e),s=/safari/i.test(e)&&!r&&!i,o=/iphone/i.test(e),u=/ipad/i.test(e),a=/touchpad/i.test(e),f=/android/i.test(e),l=/opera/i.test(e)||/opr/i.test(e),c=/firefox/i.test(e),h=/gecko\//i.test(e),p=/seamonkey\//i.test(e),d=/version\/(\d+(\.\d+)?)/i,v=/firefox\/(\d+(\.\d+)?)/i,m,y=g();return y.msie&&y.version>=8||y.chrome&&y.version>=10||y.firefox&&y.version>=4||y.safari&&y.version>=5||y.opera&&y.version>=10?y.a=t:y.msie&&y.version<8||y.chrome&&y.version<10||y.firefox&&y.version<4||y.safari&&y.version<5||y.opera&&y.version<10?y.c=t:y.x=t,y}) \ No newline at end of file diff --git a/src/bowser.js b/src/bowser.js index dfb0d78..b914e0b 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -39,31 +39,37 @@ function detect() { if (ie) return { - msie: t + name: 'Internet Explorer' + , msie: t , version: ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2] } if (opera) return { - opera: t + name: 'Opera' + , opera: t , version: ua.match(webkitVersion) ? ua.match(webkitVersion)[1] : ua.match(/opr\/(\d+(\.\d+)?)/i)[1] } if (chrome) return { - webkit: t + name: 'Chrome' + , webkit: t , chrome: t , version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1] } if (phantom) return { - webkit: t + name: 'PhantomJS' + , webkit: t , phantom: t , version: ua.match(/phantomjs\/(\d+(\.\d+)+)/i)[1] } if (touchpad) return { - webkit: t + name: 'TouchPad' + , webkit: t , touchpad: t , version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1] } if (iphone || ipad) { o = { - webkit: t + name : iphone ? 'iPhone' : 'iPad' + , webkit: t , mobile: t , ios: t , iphone: iphone @@ -76,27 +82,34 @@ return o } if (android) return { - webkit: t + name: 'Android' + , webkit: t , android: t , mobile: t , version: (ua.match(webkitVersion) || ua.match(firefoxVersion))[1] } if (safari) return { - webkit: t + name: 'Safari' + , webkit: t , safari: t , version: ua.match(webkitVersion)[1] } if (gecko) { o = { - gecko: t + name: 'Gecko' + , gecko: t , mozilla: t , version: ua.match(firefoxVersion)[1] } - if (firefox) o.firefox = t + if (firefox) { + o.name = 'Firefox'; + o.firefox = t; + } return o } if (seamonkey) return { - seamonkey: t + name: 'SeaMonkey' + , seamonkey: t , version: ua.match(/seamonkey\/(\d+(\.\d+)?)/i)[1] } return {}