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