forked from Apollon77/ioBroker.zoneminder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zones.js
45 lines (31 loc) · 895 Bytes
/
zones.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* Created by root on 23.06.17.
*/
function Zones() {
var ZonesList = [];
this.indexOf = function(Zone) {
for (var i = 0; i< ZonesList.length; i++)
if (ZonesList[i].Id == Zone.Id)
return i;
return -1;
}
this.Add = function (Zone) {
return ZonesList.push(Zone);
}
this.AddOrUpdate = function(Zone, onZoneChange) {
if (this.indexOf(Zone) > -1) {
var LocZone = ZonesList[this.indexOf(Zone)];
for (var key in Zone)
if (LocZone[key] != Zone[key])
onZoneChange(key, Zone[key])
ZonesList[this.indexOf(Zone)] = Zone;
}
else {
this.Add(Zone);
if (onZoneChange)
for (var key in Zone)
onZoneChange(key, Zone[key])
}
}
}
module.exports = Zones;