`input-phone-fiche.js` gestion de `relmark`

This commit is contained in:
xdrm-brackets 2016-11-27 16:26:24 +01:00
parent 96e5111d5f
commit f1d1fe00da
2 changed files with 52 additions and 38 deletions

View File

@ -17,6 +17,7 @@ inputPhoneFiche.prototype = {
sexe: '2', sexe: '2',
age: '.', age: '.',
interest: '.', interest: '.',
relmark: '.',
job: '.', job: '.',
famsit: '0', // Choix 1 à 3 famsit: '0', // Choix 1 à 3
studies: '0', studies: '0',
@ -71,6 +72,7 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
sexe: deflated.sexe, sexe: deflated.sexe,
age: deflated.age, age: deflated.age,
interest: deflated.interest, interest: deflated.interest,
relmark: deflated.relmark,
job: deflated.job, job: deflated.job,
famsit: deflated.famsit, famsit: deflated.famsit,
studies: deflated.studies, studies: deflated.studies,
@ -154,6 +156,7 @@ inputPhoneFiche.prototype.add = function(objectData){
objectData.studies = (objectData.studies != null) ? objectData.studies : this.defaultData.studies; objectData.studies = (objectData.studies != null) ? objectData.studies : this.defaultData.studies;
objectData.age = (objectData.age != null) ? objectData.age : this.defaultData.age; objectData.age = (objectData.age != null) ? objectData.age : this.defaultData.age;
objectData.interest = (objectData.interest != null) ? objectData.interest : this.defaultData.interest; objectData.interest = (objectData.interest != null) ? objectData.interest : this.defaultData.interest;
objectData.relmark = (objectData.relmark != null) ? objectData.relmark : this.defaultData.relmark;
// {3} Champs <radio> // // {3} Champs <radio> //
objectData.sexe = (objectData.sexe != null) ? objectData.sexe : this.defaultData.sexe; objectData.sexe = (objectData.sexe != null) ? objectData.sexe : this.defaultData.sexe;
@ -201,6 +204,7 @@ inputPhoneFiche.prototype.add = function(objectData){
if( existingData.studies2 != null ){ if( existingData.studies2 != null ){
objectData.studies = existingData.studies2; objectData.studies = existingData.studies2;
objectData.interest = existingData.interest; objectData.interest = existingData.interest;
objectData.relmark = existingData.relmark;
objectData.job = existingData.job; objectData.job = existingData.job;
objectData.famsit = existingData.famsit; objectData.famsit = existingData.famsit;
objectData.city = existingData.city; objectData.city = existingData.city;
@ -265,63 +269,68 @@ inputPhoneFiche.prototype.add = function(objectData){
if( selectedOption != null ) if( selectedOption != null )
selectedOption.setAttribute('selected', 'selected'); selectedOption.setAttribute('selected', 'selected');
/* {10} On sélectionne la valeur dans le select (manuellement) de la NOTE DE RELATION */
selectedOption = $('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="relmark"]>option[value="'+objectData.relmark+'"]');
if( selectedOption != null )
selectedOption.setAttribute('selected', 'selected');
/* {10} On sélectionna la valeur des boutons <radio> pour le SEXE */
/* {11} On sélectionna la valeur des boutons <radio> pour le SEXE */
var sexeCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'); var sexeCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');
for( var i = 0 ; i < sexeCreated.length ; i++ ) for( var i = 0 ; i < sexeCreated.length ; i++ )
if( sexeCreated[i].value == objectData.sexe ) sexeCreated[i].setAttribute('checked', 'checked'); if( sexeCreated[i].value == objectData.sexe ) sexeCreated[i].setAttribute('checked', 'checked');
else sexeCreated[i].removeAttribute('checked'); else sexeCreated[i].removeAttribute('checked');
/* {11} On sélectionna la valeur des boutons <radio> pour la SITUATION FAMILIALE */ /* {12} On sélectionna la valeur des boutons <radio> pour la SITUATION FAMILIALE */
var famsitCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]'); var famsitCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');
for( var i = 0 ; i < famsitCreated.length ; i++ ) for( var i = 0 ; i < famsitCreated.length ; i++ )
if( famsitCreated[i].value == objectData.famsit ) famsitCreated[i].setAttribute('checked', 'checked'); if( famsitCreated[i].value == objectData.famsit ) famsitCreated[i].setAttribute('checked', 'checked');
else famsitCreated[i].removeAttribute('checked'); else famsitCreated[i].removeAttribute('checked');
/* {12} On sélectionna la valeur des boutons <radio> pour le TYPE DE RELATION */ /* {13} On sélectionna la valeur des boutons <radio> pour le TYPE DE RELATION */
var reltypeCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]'); var reltypeCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');
for( var i = 0 ; i < reltypeCreated.length ; i++ ) for( var i = 0 ; i < reltypeCreated.length ; i++ )
if( reltypeCreated[i].value == objectData.reltype ) reltypeCreated[i].setAttribute('checked', 'checked'); if( reltypeCreated[i].value == objectData.reltype ) reltypeCreated[i].setAttribute('checked', 'checked');
else reltypeCreated[i].removeAttribute('checked'); else reltypeCreated[i].removeAttribute('checked');
/* {13} On sélectionna la valeur des boutons <radio> pour la LOCATION */ /* {14} On sélectionna la valeur des boutons <radio> pour la LOCATION */
var locCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]'); var locCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');
for( var i = 0 ; i < locCreated.length ; i++ ) for( var i = 0 ; i < locCreated.length ; i++ )
if( locCreated[i].value == objectData.loc ) locCreated[i].setAttribute('checked', 'checked'); if( locCreated[i].value == objectData.loc ) locCreated[i].setAttribute('checked', 'checked');
else locCreated[i].removeAttribute('checked'); else locCreated[i].removeAttribute('checked');
/* {14} On sélectionna la valeur des boutons <radio> pour le CONTEXTE DE RENCONTRE */ /* {15} On sélectionna la valeur des boutons <radio> pour le CONTEXTE DE RENCONTRE */
var contextCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="context"]'); var contextCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="context"]');
for( var i = 0 ; i < contextCreated.length ; i++ ) for( var i = 0 ; i < contextCreated.length ; i++ )
if( contextCreated[i].value == objectData.context ) contextCreated[i].setAttribute('checked', 'checked'); if( contextCreated[i].value == objectData.context ) contextCreated[i].setAttribute('checked', 'checked');
else else
/* {15} On sélectionna la valeur des boutons <radio> pour l'UTILISATION DES MEDIAS SOCIAUX */ /* {16} On sélectionna la valeur des boutons <radio> pour l'UTILISATION DES MEDIAS SOCIAUX */
var medsocCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="medsoc"]'); var medsocCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="medsoc"]');
for( var i = 0 ; i < medsocCreated.length ; i++ ) for( var i = 0 ; i < medsocCreated.length ; i++ )
if( medsocCreated[i].value == objectData.medsoc ) medsocCreated[i].setAttribute('checked', 'checked'); if( medsocCreated[i].value == objectData.medsoc ) medsocCreated[i].setAttribute('checked', 'checked');
else medsocCreated[i].removeAttribute('checked'); else medsocCreated[i].removeAttribute('checked');
/* {16} On sélectionna la valeur des boutons <radio> pour les FREQUENCES */ /* {17} On sélectionna la valeur des boutons <radio> pour les FREQUENCES */
var freqCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="freq"]'); var freqCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');
for( var i = 0 ; i < freqCreated.length ; i++ ) for( var i = 0 ; i < freqCreated.length ; i++ )
if( objectData.freq.indexOf(freqCreated[i].value) > -1 ) freqCreated[i].setAttribute('checked', 'checked'); if( objectData.freq.indexOf(freqCreated[i].value) > -1 ) freqCreated[i].setAttribute('checked', 'checked');
else freqCreated[i].removeAttribute('checked'); else freqCreated[i].removeAttribute('checked');
/* {17} On sélectionna la valeur des boutons <radio> pour les FREQUENCES IRL */ /* {18} On sélectionna la valeur des boutons <radio> pour les FREQUENCES IRL */
var irlfreqCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="irlfreq"]'); var irlfreqCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="irlfreq"]');
for( var i = 0 ; i < irlfreqCreated.length ; i++ ) for( var i = 0 ; i < irlfreqCreated.length ; i++ )
if( objectData.irlfreq.indexOf(irlfreqCreated[i].value) > -1 ) irlfreqCreated[i].setAttribute('checked', 'checked'); if( objectData.irlfreq.indexOf(irlfreqCreated[i].value) > -1 ) irlfreqCreated[i].setAttribute('checked', 'checked');
else irlfreqCreated[i].removeAttribute('checked'); else irlfreqCreated[i].removeAttribute('checked');
/* {18} On sélectionna la valeur des boutons <radio> pour les CONNECTIONS */ /* {19} On sélectionna la valeur des boutons <radio> pour les CONNECTIONS */
var connectCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="connect"]'); var connectCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');
for( var i = 0 ; i < connectCreated.length ; i++ ) for( var i = 0 ; i < connectCreated.length ; i++ )
if( objectData.connect.indexOf(connectCreated[i].value) > -1 ) connectCreated[i].setAttribute('checked', 'checked'); if( objectData.connect.indexOf(connectCreated[i].value) > -1 ) connectCreated[i].setAttribute('checked', 'checked');
@ -673,58 +682,61 @@ inputPhoneFiche.prototype.check = function(ficheData){
// 8. Le <select> pour l'INTEREST n'est pas indéfini // 8. Le <select> pour l'INTEREST n'est pas indéfini
if( ficheData.interest == '.' ) if( ficheData.interest == '.' )
return false; return false;
// 9. Le <select> pour la NOTE DE RELATION n'est pas indéfini
if( ficheData.relmark == '.' )
return false;
/* {3} Vérification des <input> radio */ /* {3} Vérification des <input> radio */
// 9. Le SEXE a un et un seul choix // 10. Le SEXE a un et un seul choix
if( ficheData.sexe == '' ) if( ficheData.sexe == '' )
return false; return false;
// 10. La SITUATION FAMILIALE a un et un seul choix // 11. La SITUATION FAMILIALE a un et un seul choix
if( ficheData.famsit == '' ) if( ficheData.famsit == '' )
return false; return false;
// 11. Le TYPE DE RELATION a un et un seul choix // 12. Le TYPE DE RELATION a un et un seul choix
if( ficheData.reltype == '' ) if( ficheData.reltype == '' )
return false; return false;
// 12. La DISTANCE DE DOMICILE (location) a un et un seul choix // 13. La DISTANCE DE DOMICILE (location) a un et un seul choix
if( ficheData.loc == '' ) if( ficheData.loc == '' )
return false; return false;
// 13. Le CONTEXTE DE RENCONTRE a un et un seul choix // 14. Le CONTEXTE DE RENCONTRE a un et un seul choix
if( ficheData.context == '' ) if( ficheData.context == '' )
return false; return false;
// 14. L'UTILISATION DES MEDIAS SOCIAUX a un et un seul choix // 15. L'UTILISATION DES MEDIAS SOCIAUX a un et un seul choix
if( ficheData.medsoc == '' ) if( ficheData.medsoc == '' )
return false; return false;
// 15. Les FRÉQUENCES ont un et un seul choix (par question de fréquence) // 16. Les FRÉQUENCES ont un et un seul choix (par question de fréquence)
for( var i = 0 ; i < ficheData.freq.length ; i++ ) for( var i = 0 ; i < ficheData.freq.length ; i++ )
if( ficheData.freq[i] == '' ) if( ficheData.freq[i] == '' )
return false; return false;
// 16. Les FRÉQUENCES IRL ont un et un seul choix (par question de fréquence) // 17. Les FRÉQUENCES IRL ont un et un seul choix (par question de fréquence)
for( var i = 0 ; i < ficheData.irlfreq.length ; i++ ) for( var i = 0 ; i < ficheData.irlfreq.length ; i++ )
if( ficheData.irlfreq[i] == '' ) if( ficheData.irlfreq[i] == '' )
return false; return false;
// 17. Les CONNECTION ont un et un seul choix (par question de connection) // 18. Les CONNECTION ont un et un seul choix (par question de connection)
for( var i = 0 ; i < ficheData.connect.length ; i++ ) for( var i = 0 ; i < ficheData.connect.length ; i++ )
if( ficheData.connect[i] == '' ) if( ficheData.connect[i] == '' )
return false; return false;
/* {4} <input> dépendant d'un choix d'un <input> radio */ /* {4} <input> dépendant d'un choix d'un <input> radio */
// 18. TYPE DE RELATION si autre est coché (indice 8), reltypeSpecial doit avoir au moins 2 caractère // 19. TYPE DE RELATION si autre est coché (indice 8), reltypeSpecial doit avoir au moins 2 caractère
if( ficheData.reltype == '10' && ficheData.reltypeSpecial.length < 2 ) if( ficheData.reltype == '10' && ficheData.reltypeSpecial.length < 2 )
return false; return false;
// 19. CONTEXTE DE RELATION si est coché indice 11, contactSpecial[0] doit avoir au moins 2 caractères // 20. CONTEXTE DE RELATION si est coché indice 11, contactSpecial[0] doit avoir au moins 2 caractères
if( ficheData.context == '11' && ficheData.contextSpecial[0].length < 2 ) if( ficheData.context == '11' && ficheData.contextSpecial[0].length < 2 )
return false; return false;
// 20. CONTEXTE DE RELATION si est coché indice 12, contextSpecial[1] doit avoir au moins 2 caractères // 21. CONTEXTE DE RELATION si est coché indice 12, contextSpecial[1] doit avoir au moins 2 caractères
if( ficheData.context == '12' && ficheData.contextSpecial[1].length < 2 ) if( ficheData.context == '12' && ficheData.contextSpecial[1].length < 2 )
return false; return false;
// 21. CONTEXTE DE RELATION si est coché indice 13, contextSpecial[2] doit avoir au moins 2 caractères // 22. CONTEXTE DE RELATION si est coché indice 13, contextSpecial[2] doit avoir au moins 2 caractères
if( ficheData.context == '13' && ficheData.contextSpecial[2].length < 2 ) if( ficheData.context == '13' && ficheData.contextSpecial[2].length < 2 )
return false; return false;
// 22. Si tout s'est bien passé, on retourne TRUE // 23. Si tout s'est bien passé, on retourne TRUE
return true; return true;
}; };

View File

@ -1,19 +1,20 @@
function inputPhoneFiche(a,b){this.container=a;this.nav_container=b;this.top_size=10} function inputPhoneFiche(a,b){this.container=a;this.nav_container=b;this.top_size=10}
inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{sexe:"2",age:".",interest:".",job:".",famsit:"0",studies:"0",reltype:"0",reltypeSpecial:"",city:"",quartier:"",cp:"",loc:"0",duration:["",""],context:"0",contextSpecial:["","",""],freq:["3","8","13","18","23"],irlfreq:["3","8","13","18","23"],connect:"1 3 5 7 9 11".split(" "),connectSpecial:["",""],medsoc:"0",timestamp:0,valid:!1}}; inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{sexe:"2",age:".",interest:".",relmark:".",job:".",famsit:"0",studies:"0",reltype:"0",reltypeSpecial:"",city:"",quartier:"",cp:"",loc:"0",duration:["",""],context:"0",contextSpecial:["","",""],freq:["3","8","13","18","23"],irlfreq:["3","8","13","18","23"],connect:"1 3 5 7 9 11".split(" "),connectSpecial:["",""],medsoc:"0",timestamp:0,valid:!1}};
inputPhoneFiche.prototype.fieldsToStorage=function(){console.group("[phone.fiche] fields to storage");var a,b,c,d,e,h=$$('[data-sublink="phone"] article.relation-panel .fiche-relation');a=0;for(b=h.length;a<b;a++)if(c=new FormDeflater(h[a],["input","select"],["data-name"]),d=c.deflate(),c=lsi.get("p_fiches",d.uid))d={sexe:d.sexe,age:d.age,interest:d.interest,job:d.job,famsit:d.famsit,studies:d.studies,reltype:d.reltype,reltypeSpecial:d.reltypeSpecial,city:d.city,quartier:d.quartier,cp:d.cp,loc:d.loc, inputPhoneFiche.prototype.fieldsToStorage=function(){console.group("[phone.fiche] fields to storage");var a,b,c,d,e,h=$$('[data-sublink="phone"] article.relation-panel .fiche-relation');a=0;for(b=h.length;a<b;a++)if(c=new FormDeflater(h[a],["input","select"],["data-name"]),d=c.deflate(),c=lsi.get("p_fiches",d.uid))d={sexe:d.sexe,age:d.age,interest:d.interest,relmark:d.relmark,job:d.job,famsit:d.famsit,studies:d.studies,reltype:d.reltype,reltypeSpecial:d.reltypeSpecial,city:d.city,quartier:d.quartier,
duration:d.duration,context:d.context,medsoc:d.medsoc,contextSpecial:d.contextSpecial,freq:d.freq,irlfreq:d.irlfreq,connect:d.connect,connectSpecial:d.connectSpecial,uid:parseInt(d.uid),contact:parseInt(d.contact)},e=crc32(JSON.stringify(d)),c.hasOwnProperty("hash")&&e==c.hash||(d.hash=e,d.valid=this.check(d),d.timestamp=Date.now(),console.warn("> FICHE UPDATE ("+(d.timestamp-input_ts)+")"),lsi.set("p_fiches",d.uid,d));console.groupEnd()}; cp:d.cp,loc:d.loc,duration:d.duration,context:d.context,medsoc:d.medsoc,contextSpecial:d.contextSpecial,freq:d.freq,irlfreq:d.irlfreq,connect:d.connect,connectSpecial:d.connectSpecial,uid:parseInt(d.uid),contact:parseInt(d.contact)},e=crc32(JSON.stringify(d)),c.hasOwnProperty("hash")&&e==c.hash||(d.hash=e,d.valid=this.check(d),d.timestamp=Date.now(),console.warn("> FICHE UPDATE ("+(d.timestamp-input_ts)+")"),lsi.set("p_fiches",d.uid,d));console.groupEnd()};
inputPhoneFiche.prototype.add=function(a){if(null==a.uid||isNaN(a.uid)||null==a.contact||isNaN(a.contact))return!1;a.city=null!=a.city?a.city:this.defaultData.city;a.quartier=null!=a.quartier?a.quartier:this.defaultData.quartier;a.cp=null!=a.cp?a.cp:this.defaultData.cp;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; inputPhoneFiche.prototype.add=function(a){if(null==a.uid||isNaN(a.uid)||null==a.contact||isNaN(a.contact))return!1;a.city=null!=a.city?a.city:this.defaultData.city;a.quartier=null!=a.quartier?a.quartier:this.defaultData.quartier;a.cp=null!=a.cp?a.cp:this.defaultData.cp;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];a.connectSpecial[1]=null!=a.connectSpecial[1]?a.connectSpecial[1]:this.defaultData.connectSpecial[1]; 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.age=null!=a.age?a.age:this.defaultData.age;a.interest=null!=a.interest?a.interest:this.defaultData.interest;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.medsoc=null!= a.job=null!=a.job?a.job:this.defaultData.job;a.studies=null!=a.studies?a.studies:this.defaultData.studies;a.age=null!=a.age?a.age:this.defaultData.age;a.interest=null!=a.interest?a.interest:this.defaultData.interest;a.relmark=null!=a.relmark?a.relmark:this.defaultData.relmark;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.medsoc?a.medsoc:this.defaultData.medsoc;a.freq=null!=a.freq?a.freq:this.defaultData.freq;a.irlfreq=null!=a.irlfreq?a.irlfreq:this.defaultData.irlfreq;a.connect=null!=a.connect?a.connect:this.defaultData.connect;var b=lsi.get("p_contacts",a.contact);if(!1===b)return!1;var c="";isNaN(b.existing)||(c=lsi.get("p_friends",b.existing),b.username=c.name,a.age=c.age,a.sexe=c.sexe,a.loc=c.dist,isNaN(c.reltype)?(a.reltype=10,a.reltypeSpecial=c.reltype):(a.reltype=c.reltype,a.reltypeSpecial=""),null!=c.studies2? a.context?a.context:this.defaultData.context;a.medsoc=null!=a.medsoc?a.medsoc:this.defaultData.medsoc;a.freq=null!=a.freq?a.freq:this.defaultData.freq;a.irlfreq=null!=a.irlfreq?a.irlfreq:this.defaultData.irlfreq;a.connect=null!=a.connect?a.connect:this.defaultData.connect;var b=lsi.get("p_contacts",a.contact);if(!1===b)return!1;var c="";isNaN(b.existing)||(c=lsi.get("p_friends",b.existing),b.username=c.name,a.age=c.age,a.sexe=c.sexe,a.loc=c.dist,isNaN(c.reltype)?(a.reltype=10,a.reltypeSpecial=c.reltype):
(a.studies=c.studies2,a.interest=c.interest,a.job=c.job,a.famsit=c.famsit,a.city=c.city,a.cp=c.cp,a.quartier=c.quartier,a.duration[0]=c.duration[0],a.duration[1]=c.duration[1],a.context=c.context,a.medsoc=c.medsoc,a.contextSpecial=c.contextExtra,a.connect=c.connect,a.connectSpecial=c.connectExtra,a.freq=c.freq,a.irlfreq=c.irlfreq,c="Contact import\u00e9: non modifiable!"):c="Contact import\u00e9 (incomplet): modifiable partiellement!");this.container.innerHTML+=pFicheBuilder.build({importedfiche:c, (a.reltype=c.reltype,a.reltypeSpecial=""),null!=c.studies2?(a.studies=c.studies2,a.interest=c.interest,a.relmark=c.relmark,a.job=c.job,a.famsit=c.famsit,a.city=c.city,a.cp=c.cp,a.quartier=c.quartier,a.duration[0]=c.duration[0],a.duration[1]=c.duration[1],a.context=c.context,a.medsoc=c.medsoc,a.contextSpecial=c.contextExtra,a.connect=c.connect,a.connectSpecial=c.connectExtra,a.freq=c.freq,a.irlfreq=c.irlfreq,c="Contact import\u00e9: non modifiable!"):c="Contact import\u00e9 (incomplet): modifiable partiellement!");
name:b.username,countcall:b.countcall,countsms:b.countsms,uid:a.uid,contact:a.contact,city:a.city,quartier:a.quartier,cp:a.cp,duration0:a.duration[0],duration1:a.duration[1],reltypespecial:a.reltypeSpecial,contextspecial0:a.contextSpecial[0],contextspecial1:a.contextSpecial[1],contextspecial2:a.contextSpecial[2],connectspecial0:a.connectSpecial[0],connectspecial1:a.connectSpecial[1]});b=$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+ this.container.innerHTML+=pFicheBuilder.build({importedfiche:c,name:b.username,countcall:b.countcall,countsms:b.countsms,uid:a.uid,contact:a.contact,city:a.city,quartier:a.quartier,cp:a.cp,duration0:a.duration[0],duration1:a.duration[1],reltypespecial:a.reltypeSpecial,contextspecial0:a.contextSpecial[0],contextspecial1:a.contextSpecial[1],contextspecial2:a.contextSpecial[2],connectspecial0:a.connectSpecial[0],connectspecial1:a.connectSpecial[1]});b=$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+
a.job+'"]');null!=b&&b.setAttribute("selected","selected");b=$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=b&&b.setAttribute("selected","selected");b=$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+a.age+'"]');null!=b&&b.setAttribute("selected","selected");b=$('[data-sublink="phone"] article.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");b=$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=b&&b.setAttribute("selected","selected");b=$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+a.age+'"]');null!=b&&b.setAttribute("selected",
a.uid+'"] ~ h5>span>select[data-name="interest"]>option[value="'+a.interest+'"]');null!=b&&b.setAttribute("selected","selected");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');for(b=0;b<c.length;b++)c[b].value==a.sexe?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]'); "selected");b=$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="interest"]>option[value="'+a.interest+'"]');null!=b&&b.setAttribute("selected","selected");b=$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="relmark"]>option[value="'+a.relmark+'"]');null!=b&&b.setAttribute("selected","selected");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+
for(b=0;b<c.length;b++)c[b].value==a.famsit?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(b=0;b<c.length;b++)c[b].value==a.reltype?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]'); a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');for(b=0;b<c.length;b++)c[b].value==a.sexe?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');for(b=0;b<c.length;b++)c[b].value==a.famsit?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+
for(b=0;b<c.length;b++)c[b].value==a.loc?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(b=0;b<c.length;b++)if(c[b].value==a.context)c[b].setAttribute("checked","checked");else var d=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="medsoc"]');for(b=0;b< a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(b=0;b<c.length;b++)c[b].value==a.reltype?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length;b++)c[b].value==a.loc?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+
d.length;b++)d[b].value==a.medsoc?d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked");d=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');for(b=0;b<d.length;b++)-1<a.freq.indexOf(d[b].value)?d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked");d=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="irlfreq"]'); a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(b=0;b<c.length;b++)if(c[b].value==a.context)c[b].setAttribute("checked","checked");else var d=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="medsoc"]');for(b=0;b<d.length;b++)d[b].value==a.medsoc?d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked");d=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');
for(b=0;b<d.length;b++)-1<a.irlfreq.indexOf(d[b].value)?d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked");d=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');for(b=0;b<d.length;b++)-1<a.connect.indexOf(d[b].value)?d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked")}; for(b=0;b<d.length;b++)-1<a.freq.indexOf(d[b].value)?d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked");d=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="irlfreq"]');for(b=0;b<d.length;b++)-1<a.irlfreq.indexOf(d[b].value)?d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked");d=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');
for(b=0;b<d.length;b++)-1<a.connect.indexOf(d[b].value)?d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked")};
inputPhoneFiche.prototype.storageToFields=function(){console.group("[phone.fiche] storage to fields");var a,b=lsi["export"]("p_fiches");this.container.innerHTML="";for(var c in b)a=cloneObject(b[c]),delete a.hash,delete a.timestamp,delete a.valid,b[c].hash=crc32(JSON.stringify(a)),lsi.set("p_fiches",b[c].uid,b[c]),b[c].uid==this.selected&&this.add(b[c]);this.updateNavBar();console.groupEnd()}; inputPhoneFiche.prototype.storageToFields=function(){console.group("[phone.fiche] storage to fields");var a,b=lsi["export"]("p_fiches");this.container.innerHTML="";for(var c in b)a=cloneObject(b[c]),delete a.hash,delete a.timestamp,delete a.valid,b[c].hash=crc32(JSON.stringify(a)),lsi.set("p_fiches",b[c].uid,b[c]),b[c].uid==this.selected&&this.add(b[c]);this.updateNavBar();console.groupEnd()};
inputPhoneFiche.prototype.sync=function(){console.group("[phone.fiche] synchronisation");lsi["export"]("p_contacts");var a,b,c,d;d=lsi.keys("p_contacts").length<2*this.top_size?lsi.keys("p_contacts").length:2*this.top_size;for(b=0;b<d;b++)a=lsi.get("p_fiches",b),!a&&(a=this.defaultData),a.uid=b,a.contact=b,lsi.set("p_fiches",b,a);var e,h,g;d={};var l={};a=lsi["export"]("p_fiches");b=lsi["export"]("p_mini-fiches");for(var k in a)if(e=lsi.get("p_contacts",a[k].contact),!(0<e.username.length&&void 0!= inputPhoneFiche.prototype.sync=function(){console.group("[phone.fiche] synchronisation");lsi["export"]("p_contacts");var a,b,c,d;d=lsi.keys("p_contacts").length<2*this.top_size?lsi.keys("p_contacts").length:2*this.top_size;for(b=0;b<d;b++)a=lsi.get("p_fiches",b),!a&&(a=this.defaultData),a.uid=b,a.contact=b,lsi.set("p_fiches",b,a);var e,h,g;d={};var l={};a=lsi["export"]("p_fiches");b=lsi["export"]("p_mini-fiches");for(var k in a)if(e=lsi.get("p_contacts",a[k].contact),!(0<e.username.length&&void 0!=
d[e.username]||0==e.username.length&&void 0!=l[e.existing])&&(0<e.username.length?d[e.username]=0:l[e.existing]=0,e)){var f=[["fiche",a[k]]];for(c in a)h=lsi.get("p_contacts",a[c].contact),c!=k&&h&&(g=0<h.username.length&&e.username===h.username,h=!isNaN(h.existing)&&e.existing===h.existing,(g||h)&&f.push(["fiche",a[c]]));for(c in b)h=lsi.get("p_contacts",b[c].contact),g=0<h.username.length&&e.username===h.username,h=!isNaN(h.existing)&&e.existing===h.existing,(g||h)&&f.push(["mini",b[c]]);if(1!== d[e.username]||0==e.username.length&&void 0!=l[e.existing])&&(0<e.username.length?d[e.username]=0:l[e.existing]=0,e)){var f=[["fiche",a[k]]];for(c in a)h=lsi.get("p_contacts",a[c].contact),c!=k&&h&&(g=0<h.username.length&&e.username===h.username,h=!isNaN(h.existing)&&e.existing===h.existing,(g||h)&&f.push(["fiche",a[c]]));for(c in b)h=lsi.get("p_contacts",b[c].contact),g=0<h.username.length&&e.username===h.username,h=!isNaN(h.existing)&&e.existing===h.existing,(g||h)&&f.push(["mini",b[c]]);if(1!==
@ -22,5 +23,6 @@ e.reltype=f[g][1].reltype,e.reltypeSpecial=f[g][1].reltypeSpecial,"."==f[g][1].l
inputPhoneFiche.prototype.nav=function(a){if(!(a instanceof Element&&a.getData("n"))||isNaN(a.getData("n"))||"p_nav-fiche"!=a.parentNode.id)return!1;for(var b=$$('[data-sublink="phone"] #p_nav-fiche > span.active'),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))}; inputPhoneFiche.prototype.nav=function(a){if(!(a instanceof Element&&a.getData("n"))||isNaN(a.getData("n"))||"p_nav-fiche"!=a.parentNode.id)return!1;for(var b=$$('[data-sublink="phone"] #p_nav-fiche > span.active'),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("p_fiches");this.nav_container.innerHTML="";for(var b=Object.keys(a),c=0;c<b.length;c++){var d=parseInt(b[c]);0==d&&(this.nav_container.innerHTML+="<span>APPELS</span>");20>d&&c<b.length-1&&20<=b[c+1]?this.nav_container.innerHTML+='<span data-n="'+d+'" class="lc">'+(d%20+1)+"</span>&nbsp;&nbsp;":(20==d&&(this.nav_container.innerHTML+='<br><span class="fc">&nbsp;&nbsp; SMS &nbsp;&nbsp;</span>'),this.nav_container.innerHTML+='<span data-n="'+ inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("p_fiches");this.nav_container.innerHTML="";for(var b=Object.keys(a),c=0;c<b.length;c++){var d=parseInt(b[c]);0==d&&(this.nav_container.innerHTML+="<span>APPELS</span>");20>d&&c<b.length-1&&20<=b[c+1]?this.nav_container.innerHTML+='<span data-n="'+d+'" class="lc">'+(d%20+1)+"</span>&nbsp;&nbsp;":(20==d&&(this.nav_container.innerHTML+='<br><span class="fc">&nbsp;&nbsp; SMS &nbsp;&nbsp;</span>'),this.nav_container.innerHTML+='<span data-n="'+
d+'">'+(d%20+1)+"</span>")}for(var e in a)b=$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[e].uid+'"]'),null!=b&&(!0===a[e].valid?b.addClass("done"):b.remClass("done"));this.nav($('[data-sublink="phone"] #p_nav-fiche [data-n="'+this.selected+'"]'))}; d+'">'+(d%20+1)+"</span>")}for(var e in a)b=$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[e].uid+'"]'),null!=b&&(!0===a[e].valid?b.addClass("done"):b.remClass("done"));this.nav($('[data-sublink="phone"] #p_nav-fiche [data-n="'+this.selected+'"]'))};
inputPhoneFiche.prototype.check=function(a){if(2>a.city.length||isNaN(parseInt(a.duration[0]))&&0<a.duration[0].length||isNaN(parseInt(a.duration[1]))&&0<a.duration[1].length||0==a.duration[0].length+a.duration[1].length||"."==a.job||"."==a.studies||"."==a.age||"."==a.interest||""==a.sexe||""==a.famsit||""==a.reltype||""==a.loc||""==a.context||""==a.medsoc)return!1;for(var b=0;b<a.freq.length;b++)if(""==a.freq[b])return!1;for(b=0;b<a.irlfreq.length;b++)if(""==a.irlfreq[b])return!1;for(b=0;b<a.connect.length;b++)if(""== inputPhoneFiche.prototype.check=function(a){if(2>a.city.length||isNaN(parseInt(a.duration[0]))&&0<a.duration[0].length||isNaN(parseInt(a.duration[1]))&&0<a.duration[1].length||0==a.duration[0].length+a.duration[1].length||"."==a.job||"."==a.studies||"."==a.age||"."==a.interest||"."==a.relmark||""==a.sexe||""==a.famsit||""==a.reltype||""==a.loc||""==a.context||""==a.medsoc)return!1;for(var b=0;b<a.freq.length;b++)if(""==a.freq[b])return!1;for(b=0;b<a.irlfreq.length;b++)if(""==a.irlfreq[b])return!1;
a.connect[b])return!1;return"10"==a.reltype&&2>a.reltypeSpecial.length||"11"==a.context&&2>a.contextSpecial[0].length||"12"==a.context&&2>a.contextSpecial[1].length||"13"==a.context&&2>a.contextSpecial[2].length?!1:!0};inputPhoneFiche.prototype.attach=function(a){console.group("[phone.fiche] attaching events");lsi.createDataset("p_fiches");this.storageToFields();this.handler=a;this.nav_container.addEventListener("click",function(a){this.nav(a.target);this.handler(a.target)}.bind(this),!1);console.groupEnd()}; for(b=0;b<a.connect.length;b++)if(""==a.connect[b])return!1;return"10"==a.reltype&&2>a.reltypeSpecial.length||"11"==a.context&&2>a.contextSpecial[0].length||"12"==a.context&&2>a.contextSpecial[1].length||"13"==a.context&&2>a.contextSpecial[2].length?!1:!0};
inputPhoneFiche.prototype.attach=function(a){console.group("[phone.fiche] attaching events");lsi.createDataset("p_fiches");this.storageToFields();this.handler=a;this.nav_container.addEventListener("click",function(a){this.nav(a.target);this.handler(a.target)}.bind(this),!1);console.groupEnd()};