Maps object should contains only data

This commit is contained in:
Faisal Salman 2012-09-17 23:37:41 +07:00
parent 41b3e247a4
commit bf9c8de5c4
2 changed files with 19 additions and 17 deletions

View File

@ -1,7 +1,7 @@
{
"title": "UA-Parser.JS",
"name": "ua-parser-js",
"version": "0.4.0",
"version": "0.4.1",
"author": "Faisal Salman <fyzlman@gmail.com> (http://faisalman.com)",
"description": "Lightweight JavaScript-based user-agent string parser",
"keywords": [

View File

@ -1,4 +1,4 @@
// UA-Parser.JS v0.4.0
// UA-Parser.JS v0.4.1
// Lightweight JavaScript-based User-Agent string parser
// https://github.com/faisalman/ua-parser-js
//
@ -45,7 +45,11 @@
if (typeof props[k] === 'object' && props[k].length === 2) {
result[props[k][0]] = props[k][1];
} else if (typeof props[k] === 'object' && props[k].length === 3) {
if (typeof props[k][1] === 'function') {
result[props[k][0]] = m ? props[k][1].call(this, m, props[k][2]) : undefined;
} else {
result[props[k][0]] = m ? m.replace(props[k][1], props[k][2]) : undefined;
}
} else {
result[props[k]] = m ? m : undefined;
}
@ -81,8 +85,7 @@
var maps = {
os : {
windows : {
version : function (match, str1) {
return mapper.string(str1, {
version : {
'ME' : '4.90',
'NT 3.11' : 'nt3.51',
'NT 4.0' : 'nt4.0',
@ -91,7 +94,6 @@
'Vista' : 'nt 6.0',
'7' : 'nt 6.1',
'8' : 'nt 6.2'
});
}
}
}
@ -192,9 +194,9 @@
// Windows based
/(windows\sphone\sos|windows)\s?([ntce\d\.\s]+\d)/i // Windows
], ['name', ['version', /(.+)/gi, maps.os.windows.version]], [
], ['name', ['version', mapper.string, maps.os.windows.version]], [
/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i
], [['name', 'Windows'], ['version', /(.+)/gi, maps.os.windows.version]], [
], [['name', 'Windows'], ['version', mapper.string, maps.os.windows.version]], [
// Mobile/Embedded OS
/(blackberry).+version\/([\w\.]+)/i, // Blackberry
@ -223,7 +225,7 @@
], ['name', 'version'],[
/(ip[honead]+).*os\s*([\w]+)*\slike\smac/i // iOS
], [['name', /.+/g, 'iOS'], ['version', /_/g, '.']], [
], [['name', 'iOS'], ['version', /_/g, '.']], [
/(mac\sos\sx)\s([\w\s\.]+\w)/i, // Mac OS
], ['name', ['version', /_/g, '.']], [