mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 07:58:45 +03:00
Fix jshint eror
This commit is contained in:
commit
3d2d8d5d84
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "0.7.5",
|
"version": "0.7.6",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Faisal Salman <fyzlman@gmail.com>"
|
"Faisal Salman <fyzlman@gmail.com>"
|
||||||
],
|
],
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "0.7.5",
|
"version": "0.7.6",
|
||||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||||
"keywords": ["user-agent", "parser", "browser", "engine", "os", "device", "cpu"],
|
"keywords": ["user-agent", "parser", "browser", "engine", "os", "device", "cpu"],
|
||||||
"scripts": ["src/ua-parser.js"],
|
"scripts": ["src/ua-parser.js"],
|
||||||
|
4
dist/ua-parser.min.js
vendored
4
dist/ua-parser.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
Package.describe({
|
Package.describe({
|
||||||
name: 'faisalman:ua-parser-js',
|
name: 'faisalman:ua-parser-js',
|
||||||
version: '0.7.5',
|
version: '0.7.6',
|
||||||
summary: 'Lightweight JavaScript-based user-agent string parser',
|
summary: 'Lightweight JavaScript-based user-agent string parser',
|
||||||
git: 'https://github.com/faisalman/ua-parser-js.git',
|
git: 'https://github.com/faisalman/ua-parser-js.git',
|
||||||
documentation: 'readme.md'
|
documentation: 'readme.md'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"title": "UAParser.js",
|
"title": "UAParser.js",
|
||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "0.7.5",
|
"version": "0.7.6",
|
||||||
"author": "Faisal Salman <fyzlman@gmail.com> (http://faisalman.com)",
|
"author": "Faisal Salman <fyzlman@gmail.com> (http://faisalman.com)",
|
||||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* UAParser.js v0.7.5
|
* UAParser.js v0.7.6
|
||||||
* Lightweight JavaScript-based User-Agent string parser
|
* Lightweight JavaScript-based User-Agent string parser
|
||||||
* https://github.com/faisalman/ua-parser-js
|
* https://github.com/faisalman/ua-parser-js
|
||||||
*
|
*
|
||||||
@ -16,14 +16,14 @@
|
|||||||
/////////////
|
/////////////
|
||||||
|
|
||||||
|
|
||||||
var LIBVERSION = '0.7.5',
|
var LIBVERSION = '0.7.6',
|
||||||
EMPTY = '',
|
EMPTY = '',
|
||||||
UNKNOWN = '?',
|
UNKNOWN = '?',
|
||||||
FUNC_TYPE = 'function',
|
FUNC_TYPE = 'function',
|
||||||
UNDEF_TYPE = 'undefined',
|
UNDEF_TYPE = 'undefined',
|
||||||
OBJ_TYPE = 'object',
|
OBJ_TYPE = 'object',
|
||||||
STR_TYPE = 'string',
|
STR_TYPE = 'string',
|
||||||
MAJOR = 'major',
|
MAJOR = 'major', // deprecated
|
||||||
MODEL = 'model',
|
MODEL = 'model',
|
||||||
NAME = 'name',
|
NAME = 'name',
|
||||||
TYPE = 'type',
|
TYPE = 'type',
|
||||||
@ -86,11 +86,11 @@
|
|||||||
props = args[i + 1]; // odd sequence (1,3,5,..)
|
props = args[i + 1]; // odd sequence (1,3,5,..)
|
||||||
|
|
||||||
// construct object barebones
|
// construct object barebones
|
||||||
if (typeof(result) === UNDEF_TYPE) {
|
if (typeof result === UNDEF_TYPE) {
|
||||||
result = {};
|
result = {};
|
||||||
for (p in props) {
|
for (p in props) {
|
||||||
q = props[p];
|
q = props[p];
|
||||||
if (typeof(q) === OBJ_TYPE) {
|
if (typeof q === OBJ_TYPE) {
|
||||||
result[q[0]] = undefined;
|
result[q[0]] = undefined;
|
||||||
} else {
|
} else {
|
||||||
result[q] = undefined;
|
result[q] = undefined;
|
||||||
@ -107,9 +107,9 @@
|
|||||||
match = matches[++k];
|
match = matches[++k];
|
||||||
q = props[p];
|
q = props[p];
|
||||||
// check if given property is actually array
|
// check if given property is actually array
|
||||||
if (typeof(q) === OBJ_TYPE && q.length > 0) {
|
if (typeof q === OBJ_TYPE && q.length > 0) {
|
||||||
if (q.length == 2) {
|
if (q.length == 2) {
|
||||||
if (typeof(q[1]) == FUNC_TYPE) {
|
if (typeof q[1] == FUNC_TYPE) {
|
||||||
// assign modified match
|
// assign modified match
|
||||||
result[q[0]] = q[1].call(this, match);
|
result[q[0]] = q[1].call(this, match);
|
||||||
} else {
|
} else {
|
||||||
@ -118,7 +118,7 @@
|
|||||||
}
|
}
|
||||||
} else if (q.length == 3) {
|
} else if (q.length == 3) {
|
||||||
// check whether function or regex
|
// check whether function or regex
|
||||||
if (typeof(q[1]) === FUNC_TYPE && !(q[1].exec && q[1].test)) {
|
if (typeof q[1] === FUNC_TYPE && !(q[1].exec && q[1].test)) {
|
||||||
// call function (usually string mapper)
|
// call function (usually string mapper)
|
||||||
result[q[0]] = match ? q[1].call(this, match, q[2]) : undefined;
|
result[q[0]] = match ? q[1].call(this, match, q[2]) : undefined;
|
||||||
} else {
|
} else {
|
||||||
@ -143,7 +143,7 @@
|
|||||||
|
|
||||||
for (var i in map) {
|
for (var i in map) {
|
||||||
// check if array
|
// check if array
|
||||||
if (typeof(map[i]) === OBJ_TYPE && map[i].length > 0) {
|
if (typeof map[i] === OBJ_TYPE && map[i].length > 0) {
|
||||||
for (var j = 0; j < map[i].length; j++) {
|
for (var j = 0; j < map[i].length; j++) {
|
||||||
if (util.has(map[i][j], str)) {
|
if (util.has(map[i][j], str)) {
|
||||||
return (i === UNKNOWN) ? undefined : i;
|
return (i === UNKNOWN) ? undefined : i;
|
||||||
@ -280,8 +280,8 @@
|
|||||||
/android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)/i // Android Browser
|
/android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)/i // Android Browser
|
||||||
], [VERSION, [NAME, 'Android Browser']], [
|
], [VERSION, [NAME, 'Android Browser']], [
|
||||||
|
|
||||||
/FBAV\/((\d+)?[\w\.]+);/i // Facebook App for iOS
|
/FBAV\/([\w\.]+);/i // Facebook App for iOS
|
||||||
], [VERSION, MAJOR, [NAME, 'Facebook']], [
|
], [VERSION, [NAME, 'Facebook']], [
|
||||||
|
|
||||||
/version\/([\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari
|
/version\/([\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari
|
||||||
], [VERSION, [NAME, 'Mobile Safari']], [
|
], [VERSION, [NAME, 'Mobile Safari']], [
|
||||||
@ -520,6 +520,9 @@
|
|||||||
/(alcatel|geeksphone|huawei|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]+)*/i
|
/(alcatel|geeksphone|huawei|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]+)*/i
|
||||||
// Alcatel/GeeksPhone/Huawei/Lenovo/Nexian/Panasonic/Sony
|
// Alcatel/GeeksPhone/Huawei/Lenovo/Nexian/Panasonic/Sony
|
||||||
], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [
|
], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [
|
||||||
|
|
||||||
|
/(nexus\s9)/i // HTC Nexus 9
|
||||||
|
], [MODEL, [VENDOR, 'HTC'], [TYPE, TABLET]], [
|
||||||
|
|
||||||
/[\s\(;](xbox(?:\sone)?)[\s\);]/i // Microsoft Xbox
|
/[\s\(;](xbox(?:\sone)?)[\s\);]/i // Microsoft Xbox
|
||||||
], [MODEL, [VENDOR, 'Microsoft'], [TYPE, CONSOLE]], [
|
], [MODEL, [VENDOR, 'Microsoft'], [TYPE, CONSOLE]], [
|
||||||
@ -553,10 +556,10 @@
|
|||||||
/(nokia)[\s_-]?([\w-]+)*/i
|
/(nokia)[\s_-]?([\w-]+)*/i
|
||||||
], [[VENDOR, 'Nokia'], MODEL, [TYPE, MOBILE]], [
|
], [[VENDOR, 'Nokia'], MODEL, [TYPE, MOBILE]], [
|
||||||
|
|
||||||
/android\s3\.[\s\w-;]{10}(a\d{3})/i // Acer
|
/android\s3\.[\s\w;-]{10}(a\d{3})/i // Acer
|
||||||
], [MODEL, [VENDOR, 'Acer'], [TYPE, TABLET]], [
|
], [MODEL, [VENDOR, 'Acer'], [TYPE, TABLET]], [
|
||||||
|
|
||||||
/android\s3\.[\s\w-;]{10}(lg?)-([06cv9]{3,4})/i // LG Tablet
|
/android\s3\.[\s\w;-]{10}(lg?)-([06cv9]{3,4})/i // LG Tablet
|
||||||
], [[VENDOR, 'LG'], MODEL, [TYPE, TABLET]], [
|
], [[VENDOR, 'LG'], MODEL, [TYPE, TABLET]], [
|
||||||
/(lg) netcast\.tv/i // LG SmartTV
|
/(lg) netcast\.tv/i // LG SmartTV
|
||||||
], [VENDOR, MODEL, [TYPE, SMARTTV]], [
|
], [VENDOR, MODEL, [TYPE, SMARTTV]], [
|
||||||
@ -734,10 +737,10 @@
|
|||||||
////////////////
|
////////////////
|
||||||
|
|
||||||
|
|
||||||
var _UAParser = function (uastring, extensions) {
|
var UAParser = function (uastring, extensions) {
|
||||||
|
|
||||||
if (!(this instanceof _UAParser)) {
|
if (!(this instanceof UAParser)) {
|
||||||
return new _UAParser(uastring, extensions).getResult();
|
return new UAParser(uastring, extensions).getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY);
|
var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY);
|
||||||
@ -781,16 +784,16 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
_UAParser.VERSION = LIBVERSION;
|
UAParser.VERSION = LIBVERSION;
|
||||||
_UAParser.BROWSER = {
|
UAParser.BROWSER = {
|
||||||
NAME : NAME,
|
NAME : NAME,
|
||||||
MAJOR : MAJOR,
|
MAJOR : MAJOR, // deprecated
|
||||||
VERSION : VERSION
|
VERSION : VERSION
|
||||||
};
|
};
|
||||||
_UAParser.CPU = {
|
UAParser.CPU = {
|
||||||
ARCHITECTURE : ARCHITECTURE
|
ARCHITECTURE : ARCHITECTURE
|
||||||
};
|
};
|
||||||
_UAParser.DEVICE = {
|
UAParser.DEVICE = {
|
||||||
MODEL : MODEL,
|
MODEL : MODEL,
|
||||||
VENDOR : VENDOR,
|
VENDOR : VENDOR,
|
||||||
TYPE : TYPE,
|
TYPE : TYPE,
|
||||||
@ -801,11 +804,11 @@
|
|||||||
WEARABLE: WEARABLE,
|
WEARABLE: WEARABLE,
|
||||||
EMBEDDED: EMBEDDED
|
EMBEDDED: EMBEDDED
|
||||||
};
|
};
|
||||||
_UAParser.ENGINE = {
|
UAParser.ENGINE = {
|
||||||
NAME : NAME,
|
NAME : NAME,
|
||||||
VERSION : VERSION
|
VERSION : VERSION
|
||||||
};
|
};
|
||||||
_UAParser.OS = {
|
UAParser.OS = {
|
||||||
NAME : NAME,
|
NAME : NAME,
|
||||||
VERSION : VERSION
|
VERSION : VERSION
|
||||||
};
|
};
|
||||||
@ -818,41 +821,42 @@
|
|||||||
|
|
||||||
// check js environment
|
// check js environment
|
||||||
if (typeof(exports) !== UNDEF_TYPE) {
|
if (typeof(exports) !== UNDEF_TYPE) {
|
||||||
var UAParser = _UAParser;
|
|
||||||
// nodejs env
|
// nodejs env
|
||||||
if (typeof(module) !== UNDEF_TYPE && module.exports) {
|
if (typeof module !== UNDEF_TYPE && module.exports) {
|
||||||
exports = module.exports = UAParser;
|
exports = module.exports = UAParser;
|
||||||
}
|
}
|
||||||
exports.UAParser = UAParser;
|
exports.UAParser = UAParser;
|
||||||
} else if (typeof(Package) !== UNDEF_TYPE) {
|
|
||||||
// meteor
|
|
||||||
UAParser = _UAParser;
|
|
||||||
} else {
|
} else {
|
||||||
var UAParser = _UAParser;
|
|
||||||
// browser env
|
|
||||||
window.UAParser = UAParser;
|
|
||||||
// requirejs env (optional)
|
// requirejs env (optional)
|
||||||
if (typeof(define) === FUNC_TYPE && define.amd) {
|
if (typeof(define) === FUNC_TYPE && define.amd) {
|
||||||
define(function () {
|
define(function () {
|
||||||
return UAParser;
|
return UAParser;
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
// jQuery/Zepto specific (optional)
|
// browser env
|
||||||
var $ = window.jQuery || window.Zepto;
|
window.UAParser = UAParser;
|
||||||
if (typeof($) !== UNDEF_TYPE) {
|
|
||||||
var parser = new UAParser();
|
|
||||||
$.ua = parser.getResult();
|
|
||||||
$.ua.get = function() {
|
|
||||||
return parser.getUA();
|
|
||||||
};
|
|
||||||
$.ua.set = function (uastring) {
|
|
||||||
parser.setUA(uastring);
|
|
||||||
var result = parser.getResult();
|
|
||||||
for (var prop in result) {
|
|
||||||
$.ua[prop] = result[prop];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// jQuery/Zepto specific (optional)
|
||||||
|
// Note:
|
||||||
|
// In AMD env the global scope should be kept clean, but jQuery is an exception.
|
||||||
|
// jQuery always exports to global scope, unless jQuery.noConflict(true) is used,
|
||||||
|
// and we should catch that.
|
||||||
|
var $ = window.jQuery || window.Zepto;
|
||||||
|
if (typeof $ !== UNDEF_TYPE) {
|
||||||
|
var parser = new UAParser();
|
||||||
|
$.ua = parser.getResult();
|
||||||
|
$.ua.get = function() {
|
||||||
|
return parser.getUA();
|
||||||
|
};
|
||||||
|
$.ua.set = function (uastring) {
|
||||||
|
parser.setUA(uastring);
|
||||||
|
var result = parser.getResult();
|
||||||
|
for (var prop in result) {
|
||||||
|
$.ua[prop] = result[prop];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
})(this);
|
})(this);
|
||||||
|
@ -9,6 +9,16 @@
|
|||||||
"type" : "mobile"
|
"type" : "mobile"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"desc" : "HTC Nexus 9",
|
||||||
|
"ua" : "Mozilla/5.0 (Linux; Android 5.0; Nexus 9 Build/LRX21R) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Mobile Crosswalk/7.36.154.13 Safari/537.36",
|
||||||
|
"expect" :
|
||||||
|
{
|
||||||
|
"vendor" : "HTC",
|
||||||
|
"model" : "Nexus 9",
|
||||||
|
"type" : "tablet"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"desc" : "LG Nexus 4",
|
"desc" : "LG Nexus 4",
|
||||||
"ua" : "Mozilla/5.0 (Linux; Android 4.2.1; Nexus 4 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19",
|
"ua" : "Mozilla/5.0 (Linux; Android 4.2.1; Nexus 4 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"title": "UAParser.js",
|
"title": "UAParser.js",
|
||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "0.7.5",
|
"version": "0.7.6",
|
||||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"user-agent",
|
"user-agent",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user