diff --git a/bowser.js b/bowser.js index c19137c..851a1a3 100644 --- a/bowser.js +++ b/bowser.js @@ -5,9 +5,13 @@ */ !function (name, definition) { - if (typeof define == 'function') define(definition) - else if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition() - else this[name] = definition() + if (typeof define === 'function') { + define(definition); + } else if (typeof module !== 'undefined' && module.exports) { + module.exports[name] = definition(); + } else { + this[name] = definition(); + } }('bowser', function () { /** * navigator.userAgent => @@ -40,72 +44,80 @@ , seamonkey = /seamonkey\//i.test(ua) , webkitVersion = /version\/(\d+(\.\d+)?)/i , firefoxVersion = /firefox\/(\d+(\.\d+)?)/i - , o + , o; function detect() { - if (ie) return { + if (ie) { + return { msie: t , version: ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2] - } - if (opera) return { + }; + } else if (opera) { + return { opera: t , version: ua.match(webkitVersion) ? ua.match(webkitVersion)[1] : ua.match(/opr\/(\d+(\.\d+)?)/i) - } - if (chrome) return { + }; + } else if (chrome) { + return { webkit: t , chrome: t , version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1] - } - if (phantom) return { + }; + } else if (phantom) { + return { webkit: t , phantom: t , version: ua.match(/phantomjs\/(\d+(\.\d+)+)/i)[1] - } - if (touchpad) return { + }; + } else if (touchpad) { + return { webkit: t , touchpad: t , version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1] - } - if (iphone || ipad) { + }; + } else if (iphone || ipad) { o = { webkit: t , mobile: t , ios: t , iphone: iphone , ipad: ipad - } + }; // WTF: version is not part of user agent in web apps if (webkitVersion.test(ua)) { - o.version = ua.match(webkitVersion)[1] + o.version = ua.match(webkitVersion)[1]; } - return o - } - if (android) return { + return o; + } else if (android) { + return { webkit: t , android: t , mobile: t , version: (ua.match(webkitVersion) || ua.match(firefoxVersion))[1] - } - if (safari) return { + }; + } else if (safari) { + return { webkit: t , safari: t , version: ua.match(webkitVersion)[1] - } - if (gecko) { + }; + } else if (gecko) { o = { gecko: t , mozilla: t , version: ua.match(firefoxVersion)[1] - } - if (firefox) o.firefox = t - return o - } - if (seamonkey) return { + }; + if (firefox) o.firefox = t; + return o; + } else if (seamonkey) { + return { seamonkey: t , version: ua.match(/seamonkey\/(\d+(\.\d+)?)/i)[1] - } - return {} + }; + } else { + return {}; + } } var bowser = detect() @@ -125,8 +137,10 @@ (bowser.firefox && bowser.version < 4.0) || (bowser.safari && bowser.version < 5) || (bowser.opera && bowser.version < 10.0)) { - bowser.c = t - } else bowser.x = t + bowser.c = t; + } else { + bowser.x = t; + } - return bowser + return bowser; }) diff --git a/bowser.min.js b/bowser.min.js index 04f4764..bceae58 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)}: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[e]=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)}: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 diff --git a/src/bowser.js b/src/bowser.js index 35c1d5c..889be66 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -1,7 +1,11 @@ !function (name, definition) { - if (typeof define == 'function') define(definition) - else if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition() - else this[name] = definition() + if (typeof define === 'function') { + define(definition); + } else if (typeof module !== 'undefined' && module.exports) { + module.exports[name] = definition(); + } else { + this[name] = definition(); + } }('bowser', function () { /** * navigator.userAgent => @@ -34,72 +38,80 @@ , seamonkey = /seamonkey\//i.test(ua) , webkitVersion = /version\/(\d+(\.\d+)?)/i , firefoxVersion = /firefox\/(\d+(\.\d+)?)/i - , o + , o; function detect() { - if (ie) return { + if (ie) { + return { msie: t , version: ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2] - } - if (opera) return { + }; + } else if (opera) { + return { opera: t , version: ua.match(webkitVersion) ? ua.match(webkitVersion)[1] : ua.match(/opr\/(\d+(\.\d+)?)/i) - } - if (chrome) return { + }; + } else if (chrome) { + return { webkit: t , chrome: t , version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1] - } - if (phantom) return { + }; + } else if (phantom) { + return { webkit: t , phantom: t , version: ua.match(/phantomjs\/(\d+(\.\d+)+)/i)[1] - } - if (touchpad) return { + }; + } else if (touchpad) { + return { webkit: t , touchpad: t , version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1] - } - if (iphone || ipad) { + }; + } else if (iphone || ipad) { o = { webkit: t , mobile: t , ios: t , iphone: iphone , ipad: ipad - } + }; // WTF: version is not part of user agent in web apps if (webkitVersion.test(ua)) { - o.version = ua.match(webkitVersion)[1] + o.version = ua.match(webkitVersion)[1]; } - return o - } - if (android) return { + return o; + } else if (android) { + return { webkit: t , android: t , mobile: t , version: (ua.match(webkitVersion) || ua.match(firefoxVersion))[1] - } - if (safari) return { + }; + } else if (safari) { + return { webkit: t , safari: t , version: ua.match(webkitVersion)[1] - } - if (gecko) { + }; + } else if (gecko) { o = { gecko: t , mozilla: t , version: ua.match(firefoxVersion)[1] - } - if (firefox) o.firefox = t - return o - } - if (seamonkey) return { + }; + if (firefox) o.firefox = t; + return o; + } else if (seamonkey) { + return { seamonkey: t , version: ua.match(/seamonkey\/(\d+(\.\d+)?)/i)[1] - } - return {} + }; + } else { + return {}; + } } var bowser = detect() @@ -119,8 +131,10 @@ (bowser.firefox && bowser.version < 4.0) || (bowser.safari && bowser.version < 5) || (bowser.opera && bowser.version < 10.0)) { - bowser.c = t - } else bowser.x = t + bowser.c = t; + } else { + bowser.x = t; + } - return bowser + return bowser; })