From e89e8173f500678128134fd8e01fae595016e699 Mon Sep 17 00:00:00 2001 From: Faisal Salman Date: Mon, 18 Mar 2013 22:21:22 +0700 Subject: [PATCH] Fix error build --- component.json | 2 +- package.json | 2 +- src/ua-parser.js | 48 +++++++++++++++++++++------------------- src/ua-parser.min.js | 4 ++-- ua-parser-js.jquery.json | 2 +- 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/component.json b/component.json index bd20916..b9a21e3 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "ua-parser-js", - "version": "0.5.20", + "version": "0.5.22", "description": "Lightweight JavaScript-based user-agent string parser", "keywords": ["user-agent", "parser", "browser", "engine", "os", "device"], "scripts": ["src/ua-parser.js"], diff --git a/package.json b/package.json index 51f1c2c..dec569f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "title": "UA-Parser.JS", "name": "ua-parser-js", - "version": "0.5.20", + "version": "0.5.22", "author": "Faisal Salman (http://faisalman.com)", "description": "Lightweight JavaScript-based user-agent string parser", "keywords": [ diff --git a/src/ua-parser.js b/src/ua-parser.js index 225865d..f11465e 100644 --- a/src/ua-parser.js +++ b/src/ua-parser.js @@ -1,4 +1,4 @@ -// UAParser.js v0.5.21 +// UAParser.js v0.5.22 // Lightweight JavaScript-based User-Agent string parser // https://github.com/faisalman/ua-parser-js // @@ -39,7 +39,7 @@ has : function (str1, str2) { return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1; }, - isType : function (obj, str) { + is : function (obj, str) { return typeof obj === str; } }; @@ -55,19 +55,20 @@ rgx : function () { // loop through all regexes maps - for (var result, i = 0, j, k, p, matches, match, args = arguments; i < args.length; i += 2) { + for (var result, i = 0, j, k, p, q, matches, match, args = arguments; i < args.length; i += 2) { var regex = args[i], // even sequence (0,2,4,..) props = args[i + 1]; // odd sequence (1,3,5,..) // construct object barebones - if (util.isType(result, UNDEF_TYPE)) { + if (util.is(result, UNDEF_TYPE)) { result = {}; for (p in props) { - if (util.isType(p, OBJ_TYPE)) { - result[p[0]] = undefined; + q = props[p]; + if (util.is(q, OBJ_TYPE)) { + result[q[0]] = undefined; } else { - result[p] = undefined; + result[q] = undefined; } } } @@ -77,24 +78,25 @@ matches = regex[j].exec(this.getUA()); if (!!matches) { for (p in props) { - match = matches[k + 1]; + match = matches[++k]; + q = props[p]; // check if given property is actually array - if (util.isType(p, OBJ_TYPE)) { - if (p.length == 2) { + if (util.is(q, OBJ_TYPE)) { + if (q.length == 2) { // assign given value, ignore regex match - result[p[0]] = p[1]; - } else if (p.length == 3) { + result[q[0]] = q[1]; + } else if (q.length == 3) { // check whether function or regex - if (util.isType(p[1], FUNC_TYPE) && !(p[1].exec && p[1].test)) { + if (util.is(q[1], FUNC_TYPE) && !(q[1].exec && q[1].test)) { // call function (usually string mapper) - result[p[0]] = match ? p[1].call(this, match, p[2]) : undefined; + result[q[0]] = match ? q[1].call(this, match, q[2]) : undefined; } else { // sanitize match using given regex - result[p[0]] = match ? match.replace(p[1], p[2]) : undefined; + result[q[0]] = match ? match.replace(q[1], q[2]) : undefined; } } } else { - result[p] = match ? match : undefined; + result[q] = match ? match : undefined; } } break; @@ -110,9 +112,9 @@ for (var i in map) { // check if array - if (util.isType(map[i], OBJ_TYPE) && map[i].length > 0) { + if (util.is(map[i], OBJ_TYPE) && map[i].length > 0) { for (var j in map[i]) { - if (util.has(j, str)) { + if (util.has(map[i][j], str)) { return (i === UNKNOWN) ? undefined : i; } } @@ -465,13 +467,13 @@ // check js environment - if (!util.isType(exports, UNDEF_TYPE)) { + if (!util.is(exports, UNDEF_TYPE)) { // nodejs env - if (!util.isType(module, UNDEF_TYPE) && module.exports) { + if (!util.is(module, UNDEF_TYPE) && module.exports) { exports = module.exports = UAParser; } exports.UAParser = UAParser; - } else if (util.isType(define, FUNC_TYPE) && define.amd) { + } else if (util.is(define, FUNC_TYPE) && define.amd) { // requirejs env define(function() { return UAParser; @@ -480,7 +482,7 @@ // browser env window.UAParser = UAParser; // jQuery specific (optional) - if (!util.isType(window.jQuery, UNDEF_TYPE)) { + if (!util.is(window.jQuery, UNDEF_TYPE)) { var $ = window.jQuery; var parser = new UAParser(); $.ua = parser.getResult(); @@ -497,4 +499,4 @@ } } -})(this); \ No newline at end of file +})(this); diff --git a/src/ua-parser.min.js b/src/ua-parser.min.js index a166f5a..135d208 100644 --- a/src/ua-parser.min.js +++ b/src/ua-parser.min.js @@ -1,7 +1,7 @@ -// UAParser.js v0.5.20 +// UAParser.js v0.5.22 // Lightweight JavaScript-based User-Agent string parser // https://github.com/faisalman/ua-parser-js // // Copyright © 2012-2013 Faisalman // Dual licensed under GPLv2 & MIT -(function(e,t){"use strict";var n="",r="function",i="undefined",s="object",o="major",u="model",a="name",f="type",l="vendor",c="version",h="console",p="mobile",d="tablet",v={regex:function(){var e,o,u,a,f,l,c=arguments;for(o=0;o0){for(var o=0;o0){for(var s in n[i])if(m.has(n[i][s],e))return i===r?t:i}else if(m.has(n[i],e))return i===r?t:i;return e}},y={browser:{oldsafari:{major:{1:["/8","/1","/3"],2:"/4","?":"/"},version:{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}}},device:{sprint:{model:{"Evo Shift 4G":"7373KT"},vendor:{HTC:"APA",Sprint:"Sprint"}}},os:{windows:{version:{ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",RT:"ARM"}}}},b={browser:[[/(opera\smini)\/((\d+)?[\w\.-]+)/i,/(opera\s[mobiletab]+).+version\/((\d+)?[\w\.-]+)/i,/(opera).+version\/((\d+)?[\w\.]+)/i,/(opera)[\/\s]+((\d+)?[\w\.]+)/i],[f,h,u],[/\s(opr)\/((\d+)?[\w\.]+)/i],[[f,"Opera"],h,u],[/(kindle)\/((\d+)?[\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?((\d+)?[\w\.]+)*/i,/(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?((\d+)?[\w\.]*)/i,/ms(ie)\s((\d+)?[\w\.]+)/i,/(rekonq)((?:\/)[\w\.]+)*/i,/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt)\/((\d+)?[\w\.-]+)/i],[f,h,u],[/(yabrowser)\/((\d+)?[\w\.]+)/i],[[f,"Yandex"],h,u],[/(comodo_dragon)\/((\d+)?[\w\.]+)/i],[[f,/_/g," "],h,u],[/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?((\d+)?[\w\.]+)/i],[f,h,u],[/(dolfin)\/((\d+)?[\w\.]+)/i],[[f,"Dolphin"],h,u],[/((?:android.+)crmo|crios)\/((\d+)?[\w\.]+)/i],[[f,"Chrome"],h,u],[/version\/((\d+)?[\w\.]+).+?mobile\/\w+\s(safari)/i],[h,u,[f,"Mobile Safari"]],[/version\/((\d+)?[\w\.]+).+?(mobile\s?safari|safari)/i],[h,u,f],[/webkit.+?(mobile\s?safari|safari)((\/[\w\.]+))/i],[f,[u,g.str,y.browser.oldsafari.major],[h,g.str,y.browser.oldsafari.version]],[/(konqueror)\/((\d+)?[\w\.]+)/i,/(webkit|khtml)\/((\d+)?[\w\.]+)/i],[f,h,u],[/(navigator|netscape)\/((\d+)?[\w\.-]+)/i],[[f,"Netscape"],h,u],[/(swiftfox)/i,/(iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?((\d+)?[\w\.\+]+)/i,/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/((\d+)?[\w\.-]+)/i,/(mozilla)\/((\d+)?[\w\.]+).+rv\:.+gecko\/\d+/i,/(uc\s?browser|polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf)[\/\s]?((\d+)?[\w\.]+)/i,/(links)\s\(((\d+)?[\w\.]+)/i,/(gobrowser)\/?((\d+)?[\w\.]+)*/i,/(ice\s?browser)\/v?((\d+)?[\w\._]+)/i,/(mosaic)[\/\s]((\d+)?[\w\.]+)/i],[f,h,u]],device:[[/\((ipad|playbook);[\w\s\);-]+(rim|apple)/i],[a,c,[l,v]],[/(hp).+(touchpad)/i,/(kindle)\/([\w\.]+)/i,/\s(nook)[\w\s]+build\/(\w+)/i,/(dell)\s(strea[kpr\s\d]*[\dko])/i],[c,a,[l,v]],[/\((ip[honed]+);.+(apple)/i],[a,c,[l,d]],[/(blackberry)[\s-]?(\w+)/i,/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|huawei|meizu|motorola)[\s_-]?([\w-]+)*/i,/(hp)\s([\w\s]+\w)/i,/(asus)-?(\w+)/i],[c,a,[l,d]],[/\((bb10);\s(\w+)/i],[[c,"BlackBerry"],a,[l,d]],[/android.+((transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+))/i],[[c,"Asus"],a,[l,v]],[/(sony)\s(tablet\s[ps])/i],[c,a,[l,v]],[/(nintendo)\s([wids3u]+)/i],[c,a,[l,p]],[/((playstation)\s[3portablevi]+)/i],[[c,"Sony"],a,[l,p]],[/(sprint\s(\w+))/i],[[c,g.str,y.device.sprint.vendor],[a,g.str,y.device.sprint.model],[l,d]],[/(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i,/(zte)-(\w+)*/i,/(alcatel|geeksphone|huawei|lenovo|nexian|panasonic|;\ssony)[_\s-]?([\w-]+)*/i],[c,[a,/_/g," "],[l,d]],[/\s((milestone|droid[2x]?))[globa\s]*\sbuild\//i,/(mot)[\s-]?(\w+)*/i],[[c,"Motorola"],a,[l,d]],[/android.+\s((mz60\d|xoom[\s2]{0,2}))\sbuild\//i],[[c,"Motorola"],a,[l,v]],[/android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n8000|sgh-t8[56]9))/i],[[c,"Samsung"],a,[l,v]],[/((s[cgp]h-\w+|gt-\w+|galaxy\snexus))/i,/(sam[sung]*)[\s-]*(\w+-?[\w-]*)*/i,/sec-((sgh\w+))/i],[[c,"Samsung"],a,[l,d]],[/(sie)-(\w+)*/i],[[c,"Siemens"],a,[l,d]],[/(maemo|nokia).*(n900|lumia\s\d+)/i,/(nokia)[\s_-]?([\w-]+)*/i],[[c,"Nokia"],a,[l,d]],[/android\s3\.[\s\w-;]{10}((a\d{3}))/i],[[c,"Acer"],a,[l,v]],[/android\s3\.[\s\w-;]{10}(lg?)-([06cv9]{3,4})/i],[[c,"LG"],a,[l,v]],[/(lg)[e;\s-\/]+(\w+)*/i],[[c,"LG"],a,[l,d]],[/(mobile|tablet);.+rv\:.+gecko\//i],[l,c,a]],engine:[[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i,/(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i,/(icab)[\/\s]([23]\.[\d\.]+)/i],[f,h],[/rv\:([\w\.]+).*(gecko)/i],[h,f]],os:[[/(windows)\snt\s6\.2;\s(arm)/i,/(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i],[f,[h,g.str,y.os.windows.version]],[/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i],[[f,"Windows"],[h,g.str,y.os.windows.version]],[/\((bb)(10);/i],[[f,"BlackBerry"],h],[/(blackberry)\w*\/?([\w\.]+)*/i,/(tizen)\/([\w\.]+)/i,/(android|webos|palm\os|qnx|bada|rim\stablet\sos|meego)[\/\s-]?([\w\.]+)*/i],[f,h],[/(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i],[[f,"Symbian"],h],[/mozilla.+\(mobile;.+gecko.+firefox/i],[[f,"Firefox OS"],h],[/(nintendo|playstation)\s([wids3portablevu]+)/i,/(mint)[\/\s\(]?(\w+)*/i,/(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk)[\/\s-]?([\w\.-]+)*/i,/(hurd|linux)\s?([\w\.]+)*/i,/(gnu)\s?([\w\.]+)*/i],[f,h],[/(cros)\s[\w]+\s([\w\.]+\w)/i],[[f,"Chromium OS"],h],[/(sunos)\s?([\w\.]+\d)*/i],[[f,"Solaris"],h],[/\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]+)*/i],[f,h],[/(ip[honead]+)(?:.*os\s*([\w]+)*\slike\smac|;\sopera)/i],[[f,"iOS"],[h,/_/g,"."]],[/(mac\sos\sx)\s?([\w\s\.]+\w)*/i],[f,[h,/_/g,"."]],[/(haiku)\s(\w+)/i,/(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i,/(macintosh|mac(?=_powerpc)|plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos)/i,/(unix)\s?([\w\.]+)*/i],[f,h]]},w=function(t){var r=t||(e&&e.navigator&&e.navigator.userAgent?e.navigator.userAgent:n);if(!(this instanceof w))return(new w(t)).getResult();this.getBrowser=function(){return g.rgx.apply(this,b.browser)},this.getDevice=function(){return g.rgx.apply(this,b.device)},this.getEngine=function(){return g.rgx.apply(this,b.engine)},this.getOS=function(){return g.rgx.apply(this,b.os)},this.getResult=function(){return{browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice()}},this.getUA=function(){return r},this.setUA=function(e){return r=e,this},this.setUA(r)};if(!m.is(exports,s))!m.is(module,s)&&module.exports&&(exports=module.exports=w),exports.UAParser=w;else if(m.is(define,i)&&define.amd)define(function(){return w});else{e.UAParser=w;if(!m.is(e.jQuery,s)){var E=e.jQuery,S=new w;E.ua=S.getResult(),E.ua.get=function(){return S.getUA()},E.ua.set=function(e){S.setUA(e);var t=S.getResult();for(var n in t)E.ua[n]=t[n]}}}})(this); \ No newline at end of file diff --git a/ua-parser-js.jquery.json b/ua-parser-js.jquery.json index 503f995..95d88a0 100644 --- a/ua-parser-js.jquery.json +++ b/ua-parser-js.jquery.json @@ -1,7 +1,7 @@ { "title": "UA-Parser.JS", "name": "ua-parser-js", - "version": "0.5.20", + "version": "0.5.22", "description": "Lightweight JavaScript-based user-agent string parser", "keywords": [ "user-agent",