Skip to content

Commit

Permalink
Smaller dectect.js. Inline optimizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
leodutra committed Mar 13, 2012
1 parent 433df87 commit 90b36ca
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

(function($){
function detect(ua){
var os = (this.os = {}), browser = (this.browser = {}),
var os = this.os = {}, browser = this.browser = {},
webkit = ua.match(/WebKit\/([\d.]+)/),
android = ua.match(/(Android)\s+([\d.]+)/),
ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
Expand All @@ -13,12 +13,11 @@
touchpad = webos && ua.match(/TouchPad/),
blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/);

if (webkit) browser.version = webkit[1];
browser.webkit = !!webkit;
if (browser.webkit = !!webkit) browser.version = webkit[1];

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 (iphone) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.');
if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.');
if (webos) os.webos = true, os.version = webos[2];
if (touchpad) os.touchpad = true;
if (blackberry) os.blackberry = true, os.version = blackberry[2];
Expand Down

0 comments on commit 90b36ca

Please sign in to comment.