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", "title": "UA-Parser.JS",
"name": "ua-parser-js", "name": "ua-parser-js",
"version": "0.4.0", "version": "0.4.1",
"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": [

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 // Lightweight JavaScript-based User-Agent string parser
// https://github.com/faisalman/ua-parser-js // https://github.com/faisalman/ua-parser-js
// //
@ -45,7 +45,11 @@
if (typeof props[k] === 'object' && props[k].length === 2) { if (typeof props[k] === 'object' && props[k].length === 2) {
result[props[k][0]] = props[k][1]; result[props[k][0]] = props[k][1];
} else if (typeof props[k] === 'object' && props[k].length === 3) { } else if (typeof props[k] === 'object' && props[k].length === 3) {
result[props[k][0]] = m ? m.replace(props[k][1], props[k][2]) : undefined; 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 { } else {
result[props[k]] = m ? m : undefined; result[props[k]] = m ? m : undefined;
} }
@ -81,17 +85,15 @@
var maps = { var maps = {
os : { os : {
windows : { windows : {
version : function (match, str1) { version : {
return mapper.string(str1, { 'ME' : '4.90',
'ME' : '4.90', 'NT 3.11' : 'nt3.51',
'NT 3.11' : 'nt3.51', 'NT 4.0' : 'nt4.0',
'NT 4.0' : 'nt4.0', '2000' : 'nt 5.0',
'2000' : 'nt 5.0', 'XP' : ['nt 5.1', 'nt 5.2'],
'XP' : ['nt 5.1', 'nt 5.2'], 'Vista' : 'nt 6.0',
'Vista' : 'nt 6.0', '7' : 'nt 6.1',
'7' : 'nt 6.1', '8' : 'nt 6.2'
'8' : 'nt 6.2'
});
} }
} }
} }
@ -192,9 +194,9 @@
// Windows based // Windows based
/(windows\sphone\sos|windows)\s?([ntce\d\.\s]+\d)/i // Windows /(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 /(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 // Mobile/Embedded OS
/(blackberry).+version\/([\w\.]+)/i, // Blackberry /(blackberry).+version\/([\w\.]+)/i, // Blackberry
@ -223,7 +225,7 @@
], ['name', 'version'],[ ], ['name', 'version'],[
/(ip[honead]+).*os\s*([\w]+)*\slike\smac/i // iOS /(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 /(mac\sos\sx)\s([\w\s\.]+\w)/i, // Mac OS
], ['name', ['version', /_/g, '.']], [ ], ['name', ['version', /_/g, '.']], [