Browse files

Add blackberry detection in $.os

  • Loading branch information...
1 parent d4d51fe commit 441c42b6d773b9ba88cd3f22bd51380d2d70f556 @peutetre peutetre committed Jan 12, 2011
Showing with 10 additions and 2 deletions.
  1. +3 −1 src/detect.js
  2. +7 −1 test/detect.html
View
4 src/detect.js
@@ -4,11 +4,13 @@
android = ua.match(/(Android)\s+([\d.]+)/),
iphone = ua.match(/(iPhone\sOS)\s([\d_]+)/),
ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
- webos = ua.match(/(webOS)\/([\d.]+)/);
+ webos = ua.match(/(webOS)\/([\d.]+)/),
+ blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/);
if (android) os.android = true, os.version = android[2];
if (iphone) os.ios = true, os.version = iphone[2].replace(/_/g, '.'), os.iphone = true;
if (ipad) os.ios = true, os.version = ipad[2].replace(/_/g, '.'), os.ipad = true;
if (webos) os.webos = true, os.version = webos[2];
+ if (blackberry) os.blackberry = true, os.version = blackberry[2];
return os;
}
$.os = detect(navigator.userAgent);
View
8 test/detect.html
@@ -26,7 +26,9 @@
Android_1_5: "Mozilla/5.0 (Linux; U; Android 1.5; de-; HTC Magic Build/PLAT-RC33) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1",
- Android_2_1: "Mozilla/5.0 (Linux; U; Android 2.1-update1; en-us; Nexus One Build/ERE27) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17 Chrome/4.1.249.1025"
+ Android_2_1: "Mozilla/5.0 (Linux; U; Android 2.1-update1; en-us; Nexus One Build/ERE27) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17 Chrome/4.1.249.1025",
+
+ BlackBerry_6_0_0_141: "Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en-GB) AppleWebKit/534.1+ (KHTML, like Gecko) Version/6.0.0.141 Mobile Safari/534.1+"
};
function detect(t, os, version, ua){
@@ -59,6 +61,10 @@
t.assert($.__detect(UA.iOS_4_0_iPhone).iphone);
},
+ testBlackBerry: function(t) {
+ detect(t, "blackberry", "6.0.0.141", UA.BlackBerry_6_0_0_141);
+ },
+
testBrowser: function(t){
navigator.userAgent = UA.iOS_4_0_iPhone;
t.assert($.browser);

0 comments on commit 441c42b

Please sign in to comment.