Gestion automatique du json pour les modules.
This commit is contained in:
parent
d130da42c8
commit
994e48da2e
|
@ -189,12 +189,12 @@
|
||||||
|
|
||||||
"phone": {
|
"phone": {
|
||||||
"description": "Enregistre les données d'une enquête téléphonique.",
|
"description": "Enregistre les données d'une enquête téléphonique.",
|
||||||
"permissions": ["admin"],
|
"permissions": [],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"subject": { "description": "Données sur le sujet de l'enquête.", "type": "array" },
|
"subject": { "description": "Données sur le sujet de l'enquête.", "type": "json" },
|
||||||
"contacts": { "description": "Données des contacts de l'enquête.", "type": "array<array>" },
|
"contacts": { "description": "Données des contacts de l'enquête.", "type": "json" },
|
||||||
"mini": { "description": "Mini fiches relations sur les contacts de l'enquête.", "type": "array<array>" },
|
"mini": { "description": "Mini fiches relations sur les contacts de l'enquête.", "type": "json" },
|
||||||
"fiches": { "description": "Fiches relation sur les plus proches contacts de l'enquête.", "type": "array<array>" }
|
"fiches": { "description": "Fiches relation sur les plus proches contacts de l'enquête.", "type": "json" }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
function inputPhoneContact(a,b){this.container=a;this.nav_container=b}inputPhoneContact.prototype={container:this.container,nav_container:this.nav_container,selected:1,handler:null};
|
function inputPhoneContact(a,b){this.container=a;this.nav_container=b}inputPhoneContact.prototype={container:this.container,nav_container:this.nav_container,selected:1,handler:null};
|
||||||
inputPhoneContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$("article.contact-panel .new-contact"),b=0;b<a.length;b++){var c=a[b].parentNode.children.indexOf(a[b]),d=(new FormDeflater(a[b],["input"],["data-name"])).deflate(),e=0<d.number.value.length;if(e=e&&0<d.username.value.length+d.firstname.value.length+d.lastname.value.length)d={uid:c,number:d.number.value,username:d.username.value,firstname:d.firstname.value,lastname:d.lastname.value},d.hash=
|
inputPhoneContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$("article.contact-panel .new-contact"),b=0;b<a.length;b++){var c=a[b].parentNode.children.indexOf(a[b]),d=(new FormDeflater(a[b],["input"],["data-name"])).deflate(),e=0<d.number.value.length;if(e=e&&0<d.username.value.length+d.firstname.value.length+d.lastname.value.length)d={uid:c,number:d.number.value,username:d.username.value,firstname:d.firstname.value,lastname:d.lastname.value},d.hash=
|
||||||
crc32(JSON.stringify(d)),lsi.set("contacts","form"+c,d)}};
|
crc32(JSON.stringify(d)),lsi.set("contacts",c,d)}};
|
||||||
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");a.number=null!=a.number?a.number:"";a.username=null!=a.username?a.username:"";a.firstname=null!=a.firstname?a.firstname:"";a.lastname=null!=a.lastname?a.lastname:"";this.container.innerHTML+=contactBuilder.build(a);a=$$("article.contact-panel .new-contact");for(var b=this,c=0;c<a.length;c++)a[c].removeEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1),a[c].addEventListener("click",function(a){b.nav(a.target);
|
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");a.number=null!=a.number?a.number:"";a.username=null!=a.username?a.username:"";a.firstname=null!=a.firstname?a.firstname:"";a.lastname=null!=a.lastname?a.lastname:"";this.container.innerHTML+=contactBuilder.build(a);a=$$("article.contact-panel .new-contact");for(var b=this,c=0;c<a.length;c++)a[c].removeEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1),a[c].addEventListener("click",function(a){b.nav(a.target);
|
||||||
b.handler(a.target)},!1)};inputPhoneContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi.keys("contacts");this.container.innerHTML="";for(var b=10*(this.selected-1)+10,c=10*(this.selected-1);c<b&&c<a.length;c++)this.add(lsi.get("contacts",a[c]));b>=a.length&&this.add({number:"",firstname:"",lastname:"",username:""});this.updateNavBar()};
|
b.handler(a.target)},!1)};inputPhoneContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi.keys("contacts");this.container.innerHTML="";for(var b=10*(this.selected-1)+10,c=10*(this.selected-1);c<b&&c<a.length;c++)this.add(lsi.get("contacts",a[c]));b>=a.length&&this.add({number:"",firstname:"",lastname:"",username:""});this.updateNavBar()};
|
||||||
inputPhoneContact.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML)||"nav-contact"!=a.parentNode.id)return!1;for(var b=$$("#nav-contact > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.innerHTML)};
|
inputPhoneContact.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML)||"nav-contact"!=a.parentNode.id)return!1;for(var b=$$("#nav-contact > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.innerHTML)};
|
||||||
|
|
|
@ -54,7 +54,7 @@ inputPhoneContact.prototype.fieldsToStorage = function(){
|
||||||
obj.hash = crc32( JSON.stringify(obj) );
|
obj.hash = crc32( JSON.stringify(obj) );
|
||||||
|
|
||||||
// {7} On enregistre les données dans le 'localStorage' //
|
// {7} On enregistre les données dans le 'localStorage' //
|
||||||
lsi.set('contacts', 'form'+indexInParent, obj);
|
lsi.set('contacts', indexInParent, obj);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ function inputPhoneFiche(a,b){this.container=a;this.nav_container=b}
|
||||||
inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{firstname:"",lastname:"",username:"",sexe:[{status:!0},{status:!1}],age:"",job:".",famsit:[{status:!0},{status:!1},{status:!1}],studies:".",reltype:[{status:!0},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1}],reltypeSpecial:"",city:"",loc:[{status:!0},{status:!1},{status:!1},{status:!1}],duration:["",""],context:[{status:!0},{status:!1},
|
inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{firstname:"",lastname:"",username:"",sexe:[{status:!0},{status:!1}],age:"",job:".",famsit:[{status:!0},{status:!1},{status:!1}],studies:".",reltype:[{status:!0},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1}],reltypeSpecial:"",city:"",loc:[{status:!0},{status:!1},{status:!1},{status:!1}],duration:["",""],context:[{status:!0},{status:!1},
|
||||||
{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1}],contextSpecial:["","",""],freq:[[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}]],connect:[[{status:!1},{status:!0}],[{status:!1},{status:!0}],[{status:!1},
|
{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1}],contextSpecial:["","",""],freq:[[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}]],connect:[[{status:!1},{status:!0}],[{status:!1},{status:!0}],[{status:!1},
|
||||||
{status:!0}],[{status:!1},{status:!0}],[{status:!1},{status:!0}],[{status:!1},{status:!0}]],connectSpecial:["",""]}};
|
{status:!0}],[{status:!1},{status:!0}],[{status:!1},{status:!0}],[{status:!1},{status:!0}]],connectSpecial:["",""]}};
|
||||||
inputPhoneFiche.prototype.fieldsToStorage=function(){console.log("FICHE: FIELDS TO STORAGE");for(var a=$$("article.relation-panel .fiche-relation"),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),d=lsi.get("fiches","form"+c.uid.value);!1===d&&(d.username="inconnu",d.firstname="inconnu",d.lastname="inconnu");c={uid:c.uid.value,firstname:d.firstname,lastname:d.lastname,username:d.username,sexe:c.sexe,age:c.age.value,job:c.job.value,famsit:c.famsit,studies:c.studies.value,
|
inputPhoneFiche.prototype.fieldsToStorage=function(){console.log("FICHE: FIELDS TO STORAGE");for(var a=$$("article.relation-panel .fiche-relation"),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),d=lsi.get("fiches",c.uid.value);!1===d&&(d.username="inconnu",d.firstname="inconnu",d.lastname="inconnu");c={uid:c.uid.value,firstname:d.firstname,lastname:d.lastname,username:d.username,sexe:c.sexe,age:c.age.value,job:c.job.value,famsit:c.famsit,studies:c.studies.value,
|
||||||
reltype:c.reltype,reltypeSpecial:c.reltypeSpecial.value,city:c.city.value,loc:c.loc,duration:[c.duration[0].value,c.duration[1].value],context:c.context,contextSpecial:[c.contextSpecial[0].value,c.contextSpecial[1].value,c.contextSpecial[2].value],freq:[c.freq0,c.freq1,c.freq2,c.freq3,c.freq4],connect:[c.connect0,c.connect1,c.connect2,c.connect3,c.connect4,c.connect5],connectSpecial:[c.connectSpecial[0].value,c.connectSpecial[1].value]};c.valid=this.check(c);lsi.set("fiches","form"+c.uid,c)}};
|
reltype:c.reltype,reltypeSpecial:c.reltypeSpecial.value,city:c.city.value,loc:c.loc,duration:[c.duration[0].value,c.duration[1].value],context:c.context,contextSpecial:[c.contextSpecial[0].value,c.contextSpecial[1].value,c.contextSpecial[2].value],freq:[c.freq0,c.freq1,c.freq2,c.freq3,c.freq4],connect:[c.connect0,c.connect1,c.connect2,c.connect3,c.connect4,c.connect5],connectSpecial:[c.connectSpecial[0].value,c.connectSpecial[1].value]};c.valid=this.check(c);lsi.set("fiches",c.uid,c)}};
|
||||||
inputPhoneFiche.prototype.add=function(a){console.log("FICHE: ADD");if(null==a.uid)return!1;a.firstname=null!=a.firstname?a.firstname:this.defaultData.firstname;a.lastname=null!=a.lastname?a.lastname:this.defaultData.lastname;a.username=null!=a.username?a.username:this.defaultData.username;a.age=null!=a.age?a.age:this.defaultData.age;a.city=null!=a.city?a.city:this.defaultData.city;a.duration[0]=null!=a.duration[0]?a.duration[0]:this.defaultData.duration[0];a.duration[1]=null!=a.duration[1]?a.duration[1]:
|
inputPhoneFiche.prototype.add=function(a){console.log("FICHE: ADD");if(null==a.uid)return!1;a.firstname=null!=a.firstname?a.firstname:this.defaultData.firstname;a.lastname=null!=a.lastname?a.lastname:this.defaultData.lastname;a.username=null!=a.username?a.username:this.defaultData.username;a.age=null!=a.age?a.age:this.defaultData.age;a.city=null!=a.city?a.city:this.defaultData.city;a.duration[0]=null!=a.duration[0]?a.duration[0]:this.defaultData.duration[0];a.duration[1]=null!=a.duration[1]?a.duration[1]:
|
||||||
this.defaultData.duration[1];a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;a.contextSpecial[0]=null!=a.contextSpecial[0]?a.contextSpecial[0]:this.defaultData.contextSpecial[0];a.contextSpecial[1]=null!=a.contextSpecial[1]?a.contextSpecial[1]:this.defaultData.contextSpecial[1];a.contextSpecial[2]=null!=a.contextSpecial[2]?a.contextSpecial[2]:this.defaultData.contextSpecial[2];a.connectSpecial[0]=null!=a.connectSpecial[0]?a.connectSpecial[0]:this.defaultData.connectSpecial[0];
|
this.defaultData.duration[1];a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;a.contextSpecial[0]=null!=a.contextSpecial[0]?a.contextSpecial[0]:this.defaultData.contextSpecial[0];a.contextSpecial[1]=null!=a.contextSpecial[1]?a.contextSpecial[1]:this.defaultData.contextSpecial[1];a.contextSpecial[2]=null!=a.contextSpecial[2]?a.contextSpecial[2]:this.defaultData.contextSpecial[2];a.connectSpecial[0]=null!=a.connectSpecial[0]?a.connectSpecial[0]:this.defaultData.connectSpecial[0];
|
||||||
a.connectSpecial[1]=null!=a.connectSpecial[1]?a.connectSpecial[1]:this.defaultData.connectSpecial[1];a.job=null!=a.job?a.job:this.defaultData.job;a.studies=null!=a.studies?a.studies:this.defaultData.studies;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.famsit=null!=a.famsit?a.famsit:this.defaultData.famsit;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.loc=null!=a.loc?a.loc:this.defaultData.loc;a.context=null!=a.context?a.context:this.defaultData.context;a.freq=null!=a.freq?a.freq:
|
a.connectSpecial[1]=null!=a.connectSpecial[1]?a.connectSpecial[1]:this.defaultData.connectSpecial[1];a.job=null!=a.job?a.job:this.defaultData.job;a.studies=null!=a.studies?a.studies:this.defaultData.studies;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.famsit=null!=a.famsit?a.famsit:this.defaultData.famsit;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.loc=null!=a.loc?a.loc:this.defaultData.loc;a.context=null!=a.context?a.context:this.defaultData.context;a.freq=null!=a.freq?a.freq:
|
||||||
|
|
|
@ -69,7 +69,7 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
|
||||||
|
|
||||||
|
|
||||||
// {4} On récupère les données du LSI si elles existent //
|
// {4} On récupère les données du LSI si elles existent //
|
||||||
var existingData = lsi.get('fiches', 'form'+deflated.uid.value);
|
var existingData = lsi.get('fiches', deflated.uid.value);
|
||||||
|
|
||||||
// Si n'existe pas, on initialise
|
// Si n'existe pas, on initialise
|
||||||
if( existingData === false ){
|
if( existingData === false ){
|
||||||
|
@ -130,7 +130,7 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
|
||||||
obj.valid = this.check(obj);
|
obj.valid = this.check(obj);
|
||||||
|
|
||||||
// {6} On enregistre les données dans le 'localStorage' //
|
// {6} On enregistre les données dans le 'localStorage' //
|
||||||
lsi.set('fiches', 'form'+obj.uid, obj);
|
lsi.set('fiches', obj.uid, obj);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
function inputPhoneMini(a,b){this.container=a;this.nav_container=b}inputPhoneMini.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{firstname:"",lastname:"",username:"",sexe:[{status:!0},{status:!1}],age:"",job:".",loc:[{status:!0},{status:!1},{status:!1},{status:!1}]}};
|
function inputPhoneMini(a,b){this.container=a;this.nav_container=b}inputPhoneMini.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{firstname:"",lastname:"",username:"",sexe:[{status:!0},{status:!1}],age:"",job:".",loc:[{status:!0},{status:!1},{status:!1},{status:!1}]}};
|
||||||
inputPhoneMini.prototype.fieldsToStorage=function(){console.log("MINI FICHE: FIELDS TO STORAGE");for(var a=$$("article.mini-relation-panel .mini-fiche-relation"),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),d=lsi.get("mini-fiches","form"+c.uid.value);!1===d&&(d.username="inconnu",d.firstname="inconnu",d.lastname="inconnu");c={uid:c.uid.value,firstname:d.firstname,lastname:d.lastname,username:d.username,sexe:c.sexe,age:c.age.value,job:c.job.value,loc:c.loc};
|
inputPhoneMini.prototype.fieldsToStorage=function(){console.log("MINI FICHE: FIELDS TO STORAGE");for(var a=$$("article.mini-relation-panel .mini-fiche-relation"),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),d=lsi.get("mini-fiches",c.uid.value);!1===d&&(d.username="inconnu",d.firstname="inconnu",d.lastname="inconnu");c={uid:c.uid.value,firstname:d.firstname,lastname:d.lastname,username:d.username,sexe:c.sexe,age:c.age.value,job:c.job.value,loc:c.loc};
|
||||||
c.valid=this.check(c);lsi.set("mini-fiches","form"+c.uid,c)}};
|
c.valid=this.check(c);lsi.set("mini-fiches",c.uid,c)}};
|
||||||
inputPhoneMini.prototype.add=function(a){console.log("MINI FICHE: ADD");if(null==a||null==a.uid)return!1;a.firstname=null!=a.firstname?a.firstname:this.defaultData.firstname;a.lastname=null!=a.lastname?a.lastname:this.defaultData.lastname;a.username=null!=a.username?a.username:this.defaultData.username;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.job=null!=a.job?a.job:this.defaultData.job;a.loc=null!=a.loc?a.loc:this.defaultData.loc;this.container.innerHTML+=
|
inputPhoneMini.prototype.add=function(a){console.log("MINI FICHE: ADD");if(null==a||null==a.uid)return!1;a.firstname=null!=a.firstname?a.firstname:this.defaultData.firstname;a.lastname=null!=a.lastname?a.lastname:this.defaultData.lastname;a.username=null!=a.username?a.username:this.defaultData.username;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.job=null!=a.job?a.job:this.defaultData.job;a.loc=null!=a.loc?a.loc:this.defaultData.loc;this.container.innerHTML+=
|
||||||
miniFicheBuilder.build({firstname:a.firstname,lastname:a.lastname,username:a.username,uid:a.uid,age:a.age,job:a.job});var b=$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+a.job+'"]');null!=b&&b.setAttribute("selected","selected");for(var c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length&&b<a.sexe.length;b++)a.sexe[b].status?c[b].setAttribute("checked",
|
miniFicheBuilder.build({firstname:a.firstname,lastname:a.lastname,username:a.username,uid:a.uid,age:a.age,job:a.job});var b=$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+a.job+'"]');null!=b&&b.setAttribute("selected","selected");for(var c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length&&b<a.sexe.length;b++)a.sexe[b].status?c[b].setAttribute("checked",
|
||||||
"checked"):c[b].removeAttribute("checked");c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length&&b<a.loc.length;b++)a.loc[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi["export"]("mini-fiches");this.container.innerHTML="";this.add(a["form"+this.selected]);this.updateNavBar()};
|
"checked"):c[b].removeAttribute("checked");c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length&&b<a.loc.length;b++)a.loc[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi["export"]("mini-fiches");this.container.innerHTML="";this.add(a[this.selected]);this.updateNavBar()};
|
||||||
inputPhoneMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");var a=lsi["export"]("contacts"),b;for(b in a){var c=lsi.get("mini-fiches",b);null==c&&(c=this.defaultData,c.valid=!1);c.uid=a[b].uid;c.firstname=a[b].firstname;c.lastname=a[b].lastname;c.username=a[b].username;lsi.set("mini-fiches",b,c)}};
|
inputPhoneMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");var a=lsi["export"]("contacts"),b;for(b in a){var c=lsi.get("mini-fiches",b);null==c&&(c=this.defaultData,c.valid=!1);c.uid=a[b].uid;c.firstname=a[b].firstname;c.lastname=a[b].lastname;c.username=a[b].username;lsi.set("mini-fiches",b,c)}};
|
||||||
inputPhoneMini.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML)||"nav-mini"!=a.parentNode.id)return!1;for(var b=$$("#nav-mini > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.innerHTML)-1};
|
inputPhoneMini.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML)||"nav-mini"!=a.parentNode.id)return!1;for(var b=$$("#nav-mini > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.innerHTML)-1};
|
||||||
inputPhoneMini.prototype.updateNavBar=function(){var a=lsi["export"]("mini-fiches"),b=Object.keys(a).length;if(this.nav_container.children.length!=b){this.nav_container.innerHTML="";for(var c=0;c<b;c++)this.nav_container.innerHTML+="<span></span>"}for(var d in a)b=this.nav_container.children[a[d].uid],b.innerHTML=a[d].uid+1,!0===a[d].valid?b.addClass("done"):b.remClass("done");this.nav(this.nav_container.children[this.selected])};
|
inputPhoneMini.prototype.updateNavBar=function(){var a=lsi["export"]("mini-fiches"),b=Object.keys(a).length;if(this.nav_container.children.length!=b){this.nav_container.innerHTML="";for(var c=0;c<b;c++)this.nav_container.innerHTML+="<span></span>"}for(var d in a)b=this.nav_container.children[a[d].uid],b.innerHTML=a[d].uid+1,!0===a[d].valid?b.addClass("done"):b.remClass("done");this.nav(this.nav_container.children[this.selected])};
|
||||||
|
|
|
@ -43,7 +43,7 @@ inputPhoneMini.prototype.fieldsToStorage = function(){
|
||||||
|
|
||||||
|
|
||||||
// {4} On récupère les données du LSI si elles existent //
|
// {4} On récupère les données du LSI si elles existent //
|
||||||
var existingData = lsi.get('mini-fiches', 'form'+deflated.uid.value);
|
var existingData = lsi.get('mini-fiches', deflated.uid.value);
|
||||||
|
|
||||||
// Si n'existe pas, on initialise
|
// Si n'existe pas, on initialise
|
||||||
if( existingData === false ){
|
if( existingData === false ){
|
||||||
|
@ -70,7 +70,7 @@ inputPhoneMini.prototype.fieldsToStorage = function(){
|
||||||
|
|
||||||
|
|
||||||
/* (9) On enregistre les données dans le 'localStorage' */
|
/* (9) On enregistre les données dans le 'localStorage' */
|
||||||
lsi.set('mini-fiches', 'form'+obj.uid, obj);
|
lsi.set('mini-fiches', obj.uid, obj);
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -158,7 +158,7 @@ inputPhoneMini.prototype.storageToFields = function(){
|
||||||
this.container.innerHTML = '';
|
this.container.innerHTML = '';
|
||||||
|
|
||||||
// {2} On affiche la MINI fiche sélectionnée //
|
// {2} On affiche la MINI fiche sélectionnée //
|
||||||
this.add(miniData['form'+this.selected]);
|
this.add(miniData[this.selected]);
|
||||||
|
|
||||||
// {3} On met à jour la navigation //
|
// {3} On met à jour la navigation //
|
||||||
this.updateNavBar();
|
this.updateNavBar();
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
function APIClass(b){this.target=b}
|
function APIClass(b){this.target=b}
|
||||||
APIClass.prototype={xhr:[],send:function(b,c,f){b.hasOwnProperty("path")||c({ModuleError:4});for(var a=0;a<this.xhr.length;a++)4==this.xhr[a].readyState&&(this.xhr=this.xhr.slice(0,a-1).concat(this.xhr.slice(a,this.xhr.length-1)));this.xhr.push(null);a=this.xhr.length-1;this.xhr[a]=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHttpRequest");console.log(b);var d=this;this.xhr[a].onreadystatechange=function(){if(4==d.xhr[a].readyState)if(-1<[0,200].indexOf(d.xhr[a].status))try{c(JSON.parse(d.xhr[a].responseText))}catch(b){c({ModuleError:1})}else c({ModuleError:3})};
|
APIClass.prototype={xhr:[],send:function(b,d,g){b.hasOwnProperty("path")||d({ModuleError:4});for(var a=0;a<this.xhr.length;a++)4==this.xhr[a].readyState&&(this.xhr=this.xhr.slice(0,a-1).concat(this.xhr.slice(a,this.xhr.length-1)));this.xhr.push(null);a=this.xhr.length-1;this.xhr[a]=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHttpRequest");console.log(b);var e=this;this.xhr[a].onreadystatechange=function(){if(4==e.xhr[a].readyState)if(console.log("http://host/api/ => "+e.xhr[a].responseText),
|
||||||
var g=new FormData,e;for(e in b)g.append(e,b[e]);this.xhr[a].open("POST",this.target,!0);null!=f&&this.xhr[a].setRequestHeader("Authorization","Digest "+f);this.xhr[a].send(g)}};
|
-1<[0,200].indexOf(e.xhr[a].status))try{d(JSON.parse(e.xhr[a].responseText))}catch(b){d({ModuleError:1})}else d({ModuleError:3})};var f=new FormData,c;for(c in b)"path"!=c?f.append(c,JSON.stringify(b[c])):f.append(c,b[c]);this.xhr[a].open("POST",this.target,!0);null!=g&&this.xhr[a].setRequestHeader("Authorization","Digest "+g);this.xhr[a].send(f)}};
|
||||||
|
|
|
@ -55,7 +55,7 @@ APIClass.prototype = {
|
||||||
if( ptrAPI.xhr[i].readyState == 4 ){ // si la requête est terminée
|
if( ptrAPI.xhr[i].readyState == 4 ){ // si la requête est terminée
|
||||||
|
|
||||||
/* DEBUG : affiche la réponse BRUTE de http://host/api/ */
|
/* DEBUG : affiche la réponse BRUTE de http://host/api/ */
|
||||||
// console.log('http://host/api/ => '+ptrAPI.xhr[i].responseText);
|
console.log('http://host/api/ => '+ptrAPI.xhr[i].responseText);
|
||||||
// console.log( JSON.parse(ptrAPI.xhr[i].responseText) );
|
// console.log( JSON.parse(ptrAPI.xhr[i].responseText) );
|
||||||
|
|
||||||
/* si success de requête */
|
/* si success de requête */
|
||||||
|
@ -75,8 +75,8 @@ APIClass.prototype = {
|
||||||
|
|
||||||
// On ajoute tous les attributs en POST
|
// On ajoute tous les attributs en POST
|
||||||
for( var key in pRequest )
|
for( var key in pRequest )
|
||||||
form.append(key, pRequest[key]);
|
if( key != 'path' ) form.append(key, JSON.stringify(pRequest[key]));
|
||||||
|
else form.append(key, pRequest[key]);
|
||||||
|
|
||||||
|
|
||||||
this.xhr[i].open('POST', this.target, true);
|
this.xhr[i].open('POST', this.target, true);
|
||||||
|
|
|
@ -256,6 +256,16 @@
|
||||||
return $checker && is_array($value) && count($value) > 0;
|
return $checker && is_array($value) && count($value) > 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Objet non vide
|
||||||
|
case 'object':
|
||||||
|
return $checker && is_object($value) && count((array) $value) > 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Chaine JSON (on vérifie via le parser)
|
||||||
|
case 'json':
|
||||||
|
return $checker && is_string($value) && json_decode($value, true) !== NULL;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -366,9 +366,14 @@
|
||||||
|
|
||||||
|
|
||||||
/* (6) Si le paramètre est renseigné */
|
/* (6) Si le paramètre est renseigné */
|
||||||
}else
|
}else{
|
||||||
// Si la verification est fausse, on retourne faux
|
// Si la verification est fausse, on retourne faux
|
||||||
if( !Database::check($paramsdata['type'], $params[$name]) ) return false;
|
if( !Database::check($paramsdata['type'], $params[$name]) ) return false;
|
||||||
|
|
||||||
|
// Si c'est du JSON, on le décode
|
||||||
|
if( $paramsdata['type'] == 'json' )
|
||||||
|
$params[$name] = json_decode( $params[$name], true );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* [3] Gestion du retour, si tout s'est bien passe
|
/* [3] Gestion du retour, si tout s'est bien passe
|
||||||
|
|
|
@ -13,7 +13,10 @@
|
||||||
|
|
||||||
/* TRAITE LES DONNÉES D'UN FORMULAIRE DE TYPE TÉLÉPHONIQUE
|
/* TRAITE LES DONNÉES D'UN FORMULAIRE DE TYPE TÉLÉPHONIQUE
|
||||||
*
|
*
|
||||||
* @data<Array> Tableau contenant les données du formulaire
|
* @subject<Array> Tableau contenant les données du sujet
|
||||||
|
* @contacts<Array> Tableau contenant les données des contacts
|
||||||
|
* @mini<Array> Tableau contenant les données des mini fiches relation
|
||||||
|
* @fiches<Array> Tableau contenant les données des fiches relation
|
||||||
*
|
*
|
||||||
* @return subject_id<int> Retourne l'id sujet de l'enquête
|
* @return subject_id<int> Retourne l'id sujet de l'enquête
|
||||||
*
|
*
|
||||||
|
@ -21,7 +24,9 @@
|
||||||
public static function phone($params){
|
public static function phone($params){
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
var_dump($params);
|
|
||||||
|
return array('ModulError' => 100);
|
||||||
|
|
||||||
|
|
||||||
/* [1] On crée le sujet de l'enquête
|
/* [1] On crée le sujet de l'enquête
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
|
|
@ -4,6 +4,6 @@ d;else if(b){console.log("> switch firstname+lastname -> username");b=a.parentNo
|
||||||
function checkRadioValue(a){for(var c=0,b=0;b<a.length;b++)!0===a[b].status&&c++;return 1!=c?!1:!0}
|
function checkRadioValue(a){for(var c=0,b=0;b<a.length;b++)!0===a[b].status&&c++;return 1!=c?!1:!0}
|
||||||
include("/js/includes/input-phone-subject.js",function(){include("/js/includes/input-phone-contact.js",function(){include("/js/includes/input-phone-mini.js",function(){include("/js/includes/input-phone-fiche.js",function(){subjectManager=new inputPhoneSubject($('article.subject-panel [data-name="number"]'),$('article.subject-panel [data-name="username"]'),$('article.subject-panel [data-name="firstname"]'),$('article.subject-panel [data-name="lastname"]'),$('article.subject-panel [data-name="submit"]'));
|
include("/js/includes/input-phone-subject.js",function(){include("/js/includes/input-phone-contact.js",function(){include("/js/includes/input-phone-mini.js",function(){include("/js/includes/input-phone-fiche.js",function(){subjectManager=new inputPhoneSubject($('article.subject-panel [data-name="number"]'),$('article.subject-panel [data-name="username"]'),$('article.subject-panel [data-name="firstname"]'),$('article.subject-panel [data-name="lastname"]'),$('article.subject-panel [data-name="submit"]'));
|
||||||
subjectManager.attach();contactManager=new inputPhoneContact($("article.contact-panel"),$("#nav-contact"));contactManager.attach(dynamicUpdate);miniManager=new inputPhoneMini($("article.mini-relation-panel"),$("#nav-mini"));miniManager.attach(dynamicUpdate);ficheManager=new inputPhoneFiche($("article.relation-panel"),$("#nav-fiche"));ficheManager.attach(dynamicUpdate);importCallLog.addEventListener("change",function(a){api.send({path:"upload/call_log",file:importCallLog.files[0]},function(a){console.log(a);
|
subjectManager.attach();contactManager=new inputPhoneContact($("article.contact-panel"),$("#nav-contact"));contactManager.attach(dynamicUpdate);miniManager=new inputPhoneMini($("article.mini-relation-panel"),$("#nav-mini"));miniManager.attach(dynamicUpdate);ficheManager=new inputPhoneFiche($("article.relation-panel"),$("#nav-fiche"));ficheManager.attach(dynamicUpdate);importCallLog.addEventListener("change",function(a){api.send({path:"upload/call_log",file:importCallLog.files[0]},function(a){console.log(a);
|
||||||
0==a.ModuleError&&(importCallLog.addClass("active"),a={path:"call_log/unserialize",phone_number:$("#subject_phone_number").value},api.send(a,function(a){console.log(a);if(0==a.ModuleError){for(var d=0;d<a.directory.length;d++){var c=(null===a.directory[d].name?"":a.directory[d].name).split(" ");lsi.set("contacts","form"+d,{uid:d,number:a.directory[d].number,username:1==c.length?c[0]:"",firstname:1<c.length?c[0]:"",lastname:1<c.length?c.splice(1).join(" "):""})}contactManager.storageToFields();dynamicUpdate(!0)}}))})},
|
0==a.ModuleError&&(importCallLog.addClass("active"),a={path:"call_log/unserialize",phone_number:$("#subject_phone_number").value},api.send(a,function(a){console.log(a);if(0==a.ModuleError){for(var d=0;d<a.directory.length;d++){var c=(null===a.directory[d].name?"":a.directory[d].name).split(" ");lsi.set("contacts",d,{uid:d,number:a.directory[d].number,username:1==c.length?c[0]:"",firstname:1<c.length?c[0]:"",lastname:1<c.length?c.splice(1).join(" "):""})}contactManager.storageToFields();dynamicUpdate(!0)}}))})},
|
||||||
!1);clearAllButton.addEventListener("click",function(a){localStorage.clear();reload()},!1);submitAllButton.addEventListener("click",function(a){console.log("> GATHERING ALL DATA");subjectManager.fieldsToStorage();contactManager.fieldsToStorage();miniManager.fieldsToStorage();ficheManager.fieldsToStorage();console.log({});a={path:"input/phone",subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiche:lsi["export"]("fiches")};api.send(a,function(a){console.log(a)},
|
!1);clearAllButton.addEventListener("click",function(a){localStorage.clear();reload()},!1);submitAllButton.addEventListener("click",function(a){console.log("> GATHERING ALL DATA");subjectManager.fieldsToStorage();contactManager.fieldsToStorage();miniManager.fieldsToStorage();ficheManager.fieldsToStorage();a={path:"input/phone",subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches")};api.send(a,function(a){console.log(a)},
|
||||||
!1)},!1)})})})});
|
!1)},!1)})})})});
|
||||||
|
|
|
@ -250,7 +250,7 @@ include('/js/includes/input-phone-fiche.js', function(){
|
||||||
var name = dataResponse.directory[i].name===null ? '' : dataResponse.directory[i].name;
|
var name = dataResponse.directory[i].name===null ? '' : dataResponse.directory[i].name;
|
||||||
var splitted = name.split(' ');
|
var splitted = name.split(' ');
|
||||||
|
|
||||||
lsi.set('contacts', 'form'+i, {
|
lsi.set('contacts', i, {
|
||||||
uid: i,
|
uid: i,
|
||||||
number: dataResponse.directory[i].number,
|
number: dataResponse.directory[i].number,
|
||||||
username: splitted.length == 1 ? splitted[0] : '', // Si un seul mot -> pseudo
|
username: splitted.length == 1 ? splitted[0] : '', // Si un seul mot -> pseudo
|
||||||
|
@ -289,22 +289,17 @@ include('/js/includes/input-phone-fiche.js', function(){
|
||||||
miniManager.fieldsToStorage();
|
miniManager.fieldsToStorage();
|
||||||
ficheManager.fieldsToStorage();
|
ficheManager.fieldsToStorage();
|
||||||
|
|
||||||
/* (2) On construit un objet qui contiendra toutes les données */
|
/* (2) On prépare la requête avec toutes les données */
|
||||||
var data = {
|
|
||||||
};
|
|
||||||
console.log( data );
|
|
||||||
|
|
||||||
/* (3) On prépare la requête avec toutes les données*/
|
|
||||||
var request = {
|
var request = {
|
||||||
path: 'input/phone',
|
path: 'input/phone',
|
||||||
|
|
||||||
subject: lsi.export('subject')[0],
|
subject: lsi.export('subject')[0],
|
||||||
contacts: lsi.export('contacts'),
|
contacts: lsi.export('contacts'),
|
||||||
mini: lsi.export('mini-fiches'),
|
mini: lsi.export('mini-fiches'),
|
||||||
fiche: lsi.export('fiches')
|
fiches: lsi.export('fiches')
|
||||||
};
|
};
|
||||||
|
|
||||||
/* (4) On envoie la requête et traite la réponse */
|
/* (3) On envoie la requête et traite la réponse */
|
||||||
api.send(request, function(response){
|
api.send(request, function(response){
|
||||||
console.log(response);
|
console.log(response);
|
||||||
}, false);
|
}, false);
|
||||||
|
|
Loading…
Reference in New Issue