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

- new flags for mobile with android and iPhone

- bump minor version
This commit is contained in:
Dustin Diaz 2011-09-26 16:58:18 -07:00
parent 1ea37f33da
commit 970d1f1a73
5 changed files with 151 additions and 130 deletions

106
bowser.js
View File

@ -4,7 +4,16 @@
* https://github.com/ded/bowser
* MIT License
*/
!function (context) {
/*!
* Bowser - a browser detector
* https://github.com/ded/bowser
* MIT License | (c) Dustin Diaz 2011
*/
!function (name, definition) {
if (typeof define == 'function') define(definition)
else if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition()
else this[name] = definition()
}('bowser', function () {
/**
* navigator.userAgent =>
* Chrome: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57 Safari/534.24"
@ -12,58 +21,66 @@
* Safari: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1"
* IE: "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)"
* Firefox: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0) Gecko/20100101 Firefox/4.0"
* iPhone: "Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5"
* Android: "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; T-Mobile G2 Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
*/
var ua = navigator.userAgent,
ie = /msie/i.test(ua),
chrome = /chrome/i.test(ua),
safari = /safari/i.test(ua) && !chrome,
opera = /opera/i.test(ua),
firefox = /firefox/i.test(ua),
gecko = /gecko\//i.test(ua);
var ua = navigator.userAgent
, t = true
, ie = /msie/i.test(ua)
, chrome = /chrome/i.test(ua)
, safari = /safari/i.test(ua) && !chrome
, iphone = /iphone/i.test(ua)
, android = /android/i.test(ua)
, opera = /opera/i.test(ua)
, firefox = /firefox/i.test(ua)
, gecko = /gecko\//i.test(ua)
, webkitVersion = /version\/(\d+(\.\d+)?)/i
function detect() {
if (ie) {
return {
msie: 1,
version: ua.match(/msie (\d+(\.\d+)?);/i)[1]
};
if (ie) return {
msie: t
, version: ua.match(/msie (\d+(\.\d+)?);/i)[1]
}
if (chrome) {
return {
webkit: 1,
chrome: 1,
version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1]
};
if (chrome) return {
webkit: t
, chrome: t
, version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1]
}
if (safari) {
return {
webkit: 1,
safari: 1,
version: ua.match(/version\/(\d+(\.\d+)?)/i)[1]
};
if (iphone) return {
webkit: t
, iphone: t
, mobile: t
, version: ua.match(webkitVersion)[1]
}
if (opera) {
return {
opera: 1,
version: ua.match(/version\/(\d+(\.\d+)?)/i)[1]
};
if (android) return {
webkit: t
, android: t
, mobile: t
, version: ua.match(webkitVersion)[1]
}
if (safari) return {
webkit: t
, safari: t
, version: ua.match(webkitVersion)[1]
}
if (opera) return {
opera: t
, version: ua.match(webkitVersion)[1]
}
if (gecko) {
var o = {
gecko: 1,
version: ua.match(/firefox\/(\d+(\.\d+)?)/i)[1]
};
if (firefox) {
o.firefox = 1;
gecko: t
, version: ua.match(/firefox\/(\d+(\.\d+)?)/i)[1]
}
return o;
if (firefox) o.firefox = t
return o
}
}
var bowser = detect();
var bowser = detect()
// Graded Browser Support
// http://developer.yahoo.com/yui/articles/gbs
@ -72,7 +89,7 @@
(bowser.firefox && bowser.version >= 3.6) ||
(bowser.safari && bowser.version >= 5) ||
(bowser.opera && bowser.version >= 9.5)) {
bowser.a = true;
bowser.a = t;
}
else if ((bowser.msie && bowser.version < 6) ||
@ -80,13 +97,8 @@
(bowser.firefox && bowser.version < 3.6) ||
(bowser.safari && bowser.version < 5) ||
(bowser.opera && bowser.version < 9.5)) {
bowser.c = true;
} else {
bowser.x = true;
}
bowser.c = t
} else bowser.x = t
typeof module !== 'undefined' && module.exports ?
(module.exports.browser = bowser) :
(context.bowser = bowser);
}(this);
return bowser
})

5
bowser.min.js vendored
View File

@ -5,8 +5,7 @@
* MIT License
*//*!
* Bowser - a browser detector
* copyright Dustin Diaz 2011
* https://github.com/ded/bowser
* MIT License
* MIT License | (c) Dustin Diaz 2011
*/
!function(a){function i(){if(c)return{msie:1,version:b.match(/msie (\d+(\.\d+)?);/i)[1]};if(d)return{webkit:1,chrome:1,version:b.match(/chrome\/(\d+(\.\d+)?)/i)[1]};if(e)return{webkit:1,safari:1,version:b.match(/version\/(\d+(\.\d+)?)/i)[1]};if(f)return{opera:1,version:b.match(/version\/(\d+(\.\d+)?)/i)[1]};if(h){var a={gecko:1,version:b.match(/firefox\/(\d+(\.\d+)?)/i)[1]};g&&(a.firefox=1);return a}}var b=navigator.userAgent,c=/msie/i.test(b),d=/chrome/i.test(b),e=/safari/i.test(b)&&!d,f=/opera/i.test(b),g=/firefox/i.test(b),h=/gecko\//i.test(b),j=i();j.msie&&j.version>=6||j.chrome&&j.version>=8||j.firefox&&j.version>=3.6||j.safari&&j.version>=5||j.opera&&j.version>=9.5?j.a=!0:j.msie&&j.version<6||j.chrome&&j.version<8||j.firefox&&j.version<3.6||j.safari&&j.version<5||j.opera&&j.version<9.5?j.c=!0:j.x=!0,typeof module!="undefined"&&module.exports?module.exports.browser=j:a.bowser=j}(this)
!function(a,b){typeof define=="function"?define(b):typeof module!="undefined"&&module.exports?module.exports.browser=b():this[a]=b()}("bowser",function(){function l(){if(c)return{msie:b,version:a.match(/msie (\d+(\.\d+)?);/i)[1]};if(d)return{webkit:b,chrome:b,version:a.match(/chrome\/(\d+(\.\d+)?)/i)[1]};if(f)return{webkit:b,iphone:b,mobile:b,version:a.match(k)[1]};if(g)return{webkit:b,android:b,mobile:b,version:a.match(k)[1]};if(e)return{webkit:b,safari:b,version:a.match(k)[1]};if(h)return{opera:b,version:a.match(k)[1]};if(j){var l={gecko:b,version:a.match(/firefox\/(\d+(\.\d+)?)/i)[1]};return i&&(l.firefox=b),l}}var a=navigator.userAgent,b=!0,c=/msie/i.test(a),d=/chrome/i.test(a),e=/safari/i.test(a)&&!d,f=/iphone/i.test(a),g=/android/i.test(a),h=/opera/i.test(a),i=/firefox/i.test(a),j=/gecko\//i.test(a),k=/version\/(\d+(\.\d+)?)/i,m=l();return m.msie&&m.version>=6||m.chrome&&m.version>=8||m.firefox&&m.version>=3.6||m.safari&&m.version>=5||m.opera&&m.version>=9.5?m.a=b:m.msie&&m.version<6||m.chrome&&m.version<8||m.firefox&&m.version<3.6||m.safari&&m.version<5||m.opera&&m.version<9.5?m.c=b:m.x=b,m})

View File

@ -1,24 +1,25 @@
require('smoosh').config({
"JAVASCRIPT": {
"DIST_DIR": "./",
"bowser": [
"./src/copyright.js",
"./src/bowser.js"
"DIST_DIR": "./"
, "bowser": [
"./src/copyright.js"
, "./src/bowser.js"
]
},
"JSHINT_OPTS": {
"boss": true,
"forin": false,
"curly": true,
"debug": false,
"devel": false,
"evil": false,
"regexp": false,
"undef": false,
"sub": false,
"white": true,
"indent": 2,
"whitespace": true,
"asi": false
}
}).run().build().analyze();
, "JSHINT_OPTS": {
"boss": true
, "forin": false
, "curly": false
, "debug": false
, "devel": false
, "evil": false
, "regexp": false
, "undef": false
, "sub": true
, "white": false
, "indent": 2
, "whitespace": true
, "asi": true
, "laxbreak": true
}
}).run().build().analyze()

View File

@ -1,13 +1,16 @@
{
"name": "bowser",
"description": "a browser detector",
"keywords": ["ender", "browser", "sniff", "detection"],
"version": "0.0.5",
"homepage": "https://github.com/ded/bowser",
"author": "Dustin Diaz <@ded>",
"repository": {
"type": "git",
"url": "https://github.com/ded/bowser.git"
},
"main": "./bowser.js"
"name": "bowser"
, "description": "a browser detector"
, "keywords": ["ender", "browser", "sniff", "detection"]
, "version": "0.0.6"
, "homepage": "https://github.com/ded/bowser"
, "author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)"
, "main": "./bowser.js"
, "repository": {
"type": "git"
, "url": "https://github.com/ded/bowser.git"
}
, "devDependencies": {
"smoosh": "*"
}
}

View File

@ -1,10 +1,13 @@
/*!
* Bowser - a browser detector
* copyright Dustin Diaz 2011
* https://github.com/ded/bowser
* MIT License
* MIT License | (c) Dustin Diaz 2011
*/
!function (context) {
!function (name, definition) {
if (typeof define == 'function') define(definition)
else if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition()
else this[name] = definition()
}('bowser', function () {
/**
* navigator.userAgent =>
* Chrome: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57 Safari/534.24"
@ -12,58 +15,66 @@
* Safari: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1"
* IE: "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)"
* Firefox: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0) Gecko/20100101 Firefox/4.0"
* iPhone: "Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5"
* Android: "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; T-Mobile G2 Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
*/
var ua = navigator.userAgent,
ie = /msie/i.test(ua),
chrome = /chrome/i.test(ua),
safari = /safari/i.test(ua) && !chrome,
opera = /opera/i.test(ua),
firefox = /firefox/i.test(ua),
gecko = /gecko\//i.test(ua);
var ua = navigator.userAgent
, t = true
, ie = /msie/i.test(ua)
, chrome = /chrome/i.test(ua)
, safari = /safari/i.test(ua) && !chrome
, iphone = /iphone/i.test(ua)
, android = /android/i.test(ua)
, opera = /opera/i.test(ua)
, firefox = /firefox/i.test(ua)
, gecko = /gecko\//i.test(ua)
, webkitVersion = /version\/(\d+(\.\d+)?)/i
function detect() {
if (ie) {
return {
msie: 1,
version: ua.match(/msie (\d+(\.\d+)?);/i)[1]
};
if (ie) return {
msie: t
, version: ua.match(/msie (\d+(\.\d+)?);/i)[1]
}
if (chrome) {
return {
webkit: 1,
chrome: 1,
version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1]
};
if (chrome) return {
webkit: t
, chrome: t
, version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1]
}
if (safari) {
return {
webkit: 1,
safari: 1,
version: ua.match(/version\/(\d+(\.\d+)?)/i)[1]
};
if (iphone) return {
webkit: t
, iphone: t
, mobile: t
, version: ua.match(webkitVersion)[1]
}
if (opera) {
return {
opera: 1,
version: ua.match(/version\/(\d+(\.\d+)?)/i)[1]
};
if (android) return {
webkit: t
, android: t
, mobile: t
, version: ua.match(webkitVersion)[1]
}
if (safari) return {
webkit: t
, safari: t
, version: ua.match(webkitVersion)[1]
}
if (opera) return {
opera: t
, version: ua.match(webkitVersion)[1]
}
if (gecko) {
var o = {
gecko: 1,
version: ua.match(/firefox\/(\d+(\.\d+)?)/i)[1]
};
if (firefox) {
o.firefox = 1;
gecko: t
, version: ua.match(/firefox\/(\d+(\.\d+)?)/i)[1]
}
return o;
if (firefox) o.firefox = t
return o
}
}
var bowser = detect();
var bowser = detect()
// Graded Browser Support
// http://developer.yahoo.com/yui/articles/gbs
@ -72,7 +83,7 @@
(bowser.firefox && bowser.version >= 3.6) ||
(bowser.safari && bowser.version >= 5) ||
(bowser.opera && bowser.version >= 9.5)) {
bowser.a = true;
bowser.a = t;
}
else if ((bowser.msie && bowser.version < 6) ||
@ -80,13 +91,8 @@
(bowser.firefox && bowser.version < 3.6) ||
(bowser.safari && bowser.version < 5) ||
(bowser.opera && bowser.version < 9.5)) {
bowser.c = true;
} else {
bowser.x = true;
}
bowser.c = t
} else bowser.x = t
typeof module !== 'undefined' && module.exports ?
(module.exports.browser = bowser) :
(context.bowser = bowser);
}(this);
return bowser
})