Encode/Decode on import/export group from/to sync server

This commit is contained in:
Benjamin Renard 2014-01-12 23:04:03 +01:00
parent 1c0c2629ae
commit c461810462

View file

@ -113,7 +113,7 @@ function Group(name,data) {
contributions.push(this.contributions[idx].export());
}
return {
'name': this.name,
'name': encodeURIComponent(this.name),
'contributors': contributors,
'contributions': contributions
};
@ -223,8 +223,8 @@ function Group(name,data) {
if (jQuery.type(data.contributors) == 'array') {
for (idx in data.contributors) {
this.contributors.push(new Contributor(
data.contributors[idx].name,
data.contributors[idx].email,
decodeURIComponent(data.contributors[idx].name),
decodeURIComponent(data.contributors[idx].email),
idx
));
}
@ -234,7 +234,7 @@ function Group(name,data) {
this.contributions.push(new Contribution(
this.contributorByName(data.contributions[idx].contributor),
data.contributions[idx].cost,
data.contributions[idx].title,
decodeURIComponent(data.contributions[idx].title),
data.contributions[idx].date,
idx,
data.contributions[idx].lastChange
@ -254,8 +254,8 @@ function Contributor(name,email,id) {
this.id=id;
this.export=function() {
return {
'name': this.name,
'email': this.email
'name': encodeURIComponent(this.name),
'email': encodeURIComponent(this.email)
};
}
}
@ -269,9 +269,9 @@ function Contribution(contributor,cost,title,date,id,lastChange) {
this.lastChange=lastChange || new Date().getTime();
this.export=function() {
return {
'contributor': this.contributor.name,
'contributor': encodeURIComponent(this.contributor.name),
'cost': this.cost,
'title': this.title,
'title': encodeURIComponent(this.title),
'date': this.date,
'lastChange': this.lastChange,
};