mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2026-01-03 12:52:54 +03:00
Move properties inside UAItem class into shared prototype
This commit is contained in:
@@ -1191,23 +1191,32 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function UAItem (itemType, ua, rgxMap, uaCH) {
|
function UAItem (itemType, ua, rgxMap, uaCH) {
|
||||||
|
setProps.call(this, [
|
||||||
|
['itemType', itemType],
|
||||||
|
['ua', ua],
|
||||||
|
['uaCH', uaCH],
|
||||||
|
['rgxMap', rgxMap],
|
||||||
|
['data', createIData(this, itemType)]
|
||||||
|
]);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
this.get = function (prop) {
|
UAItem.prototype.get = function (prop) {
|
||||||
if (!prop) return this.data;
|
if (!prop) return this.data;
|
||||||
return this.data.hasOwnProperty(prop) ? this.data[prop] : undefined;
|
return this.data.hasOwnProperty(prop) ? this.data[prop] : undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.set = function (prop, val) {
|
UAItem.prototype.set = function (prop, val) {
|
||||||
this.data[prop] = val;
|
this.data[prop] = val;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setCH = function (ch) {
|
UAItem.prototype.setCH = function (ch) {
|
||||||
this.uaCH = ch;
|
this.uaCH = ch;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.detectFeature = function () {
|
UAItem.prototype.detectFeature = function () {
|
||||||
if (NAVIGATOR && NAVIGATOR.userAgent == this.ua) {
|
if (NAVIGATOR && NAVIGATOR.userAgent == this.ua) {
|
||||||
switch (this.itemType) {
|
switch (this.itemType) {
|
||||||
case BROWSER:
|
case BROWSER:
|
||||||
@@ -1251,7 +1260,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.parseUA = function () {
|
UAItem.prototype.parseUA = function () {
|
||||||
if (this.itemType != RESULT) {
|
if (this.itemType != RESULT) {
|
||||||
rgxMapper.call(this.data, this.ua, this.rgxMap);
|
rgxMapper.call(this.data, this.ua, this.rgxMap);
|
||||||
}
|
}
|
||||||
@@ -1272,7 +1281,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.parseCH = function () {
|
UAItem.prototype.parseCH = function () {
|
||||||
var uaCH = this.uaCH,
|
var uaCH = this.uaCH,
|
||||||
rgxMap = this.rgxMap;
|
rgxMap = this.rgxMap;
|
||||||
|
|
||||||
@@ -1374,17 +1383,6 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
setProps.call(this, [
|
|
||||||
['itemType', itemType],
|
|
||||||
['ua', ua],
|
|
||||||
['uaCH', uaCH],
|
|
||||||
['rgxMap', rgxMap],
|
|
||||||
['data', createIData(this, itemType)]
|
|
||||||
]);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
function UAParser (ua, extensions, headers) {
|
function UAParser (ua, extensions, headers) {
|
||||||
|
|
||||||
if (typeof ua === TYPEOF.OBJECT) {
|
if (typeof ua === TYPEOF.OBJECT) {
|
||||||
|
|||||||
Reference in New Issue
Block a user