blob: 30f1e0fdfdbf3402c47daf62eee9c95cedc9b961 (
plain)
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
46
47
48
49
50
51
52
53
|
app.factory('Contact', function(ContactService)
{
return function Contact(jCard) {
angular.extend(this, {
jCard: [],
name: function(value) {
var name = this.getProperty('n');
if (angular.isDefined(value)) {
// setter
this.setPropertyValue(name, value);
} else {
// getter
return this.getPropertyValue(name);
}
},
getProperty: function(name) {
var contact = this;
if(!angular.isDefined(contact.jCard.addressData[1])) {
return undefined;
}
var properties = contact.jCard.addressData[1];
for(var i in properties) {
if(properties[i][0] === name)
return properties[i];
}
return undefined;
},
getPropertyValue: function(property) {
if(property[3] instanceof Array) {
return property[3].join(' ');
} else {
return property[3];
}
},
setPropertyValue: function(property, propertyValue) {
property[3] = propertyValue;
this.update();
},
update: function() {
ContactService.update(this.jCard);
}
});
angular.extend(this.jCard, jCard);
};
});
|