Gestion de l'impossibilité de dupliquer des contacts (en fonction de 'username' ou 'existing') [input/phone.contact]

This commit is contained in:
xdrm-brackets 2016-10-09 17:44:06 +02:00
parent 85738e1626
commit ed2a102e6d
10 changed files with 399 additions and 611 deletions

View File

@ -15,15 +15,74 @@ inputPhoneContact.prototype = {
}; };
/* [2.1] Fiche CALL range
=========================================================*/
inputPhoneContact.prototype.callRange = function(uid){ return uid >= 0 && uid < 20; };
/* [2] Vérification des données d'un contact /* [2.2] Fiche SMS range
=========================================================*/
inputPhoneContact.prototype.smsRange = function(uid){ return uid >= 20 && uid < 40; };
/* [2.3] Si contact identique
=========================================================*/
inputPhoneContact.prototype.sameContact = function(uid, username, existing, range){
var contact = null,
limits = null;
/* (1) Gestion de la tranche
---------------------------------------------------------*/
if( range === 'call' ) limits = { min: 0, max: 19 };
else if( range === 'sms' ) limits = { min: 29, max: 39 };
else if( range === 'mini' ) limits = { min: 40, max: Infinity };
else
return false;
/* (2) Gestion de la vérification
---------------------------------------------------------*/
for( var a = limits.min, b = limits.max ; a < b ; a++ ){
/* (1) On récupère le contact */
contact = lsi.get('p_contacts', a);
console.log(uid, 'to', a, contact);
// si n'existe pas, on quitte
if( contact === null ) break;
/* (2) si c'est le contact actuel, on passe au suivant */
if( parseInt(contact.uid) === parseInt(uid) )
continue;
/* (3) On vérifie si le contact est identique (si défini par `username`) */
if( contact.username.length > 0 && username === contact.username )
return true;
/* (4) On vérifie par référence */
else if( username.length === 0 && existing === contact.existing )
return true;
}
return false;
};
/* [2.4] Vérification des données d'un contact
=========================================================*/ =========================================================*/
inputPhoneContact.prototype.check = function(deflated){ inputPhoneContact.prototype.check = function(deflated){
/* On retourne la validité du formulaire */ /* On vérifie la validité du formulaire */
return !isNaN(deflated.existing) || deflated.username.length > 0; var isValid = !isNaN(deflated.existing) || deflated.username.length > 0;
if( !isValid ) return false;
/* On vérifie l'unicité du contact */
var range = this.callRange(deflated.uid) ? 'call' : this.smsRange(deflated.uid) ? 'sms' : 'mini';
/* (1) Si contact "identique" dans la même tranche
---------------------------------------------------------*/
if( this.sameContact(deflated.uid, deflated.username, deflated.existing, range) ){
Notification.error('Contact dupliqué', 'Le contact de nom '+deflated.username+' est déja utilisé');
return false;
} }
return true;
};
/* [3] Gestion de l'enregistrement des formulaires de contact /* [3] Gestion de l'enregistrement des formulaires de contact
=========================================================*/ =========================================================*/

View File

@ -1,11 +1,6 @@
var inputPhoneMatrice=function(a){this.container=a};inputPhoneMatrice.prototype={container:this.container}; var inputPhoneMatrice=function(a){this.container=a};inputPhoneMatrice.prototype={container:this.container};
inputPhoneMatrice.prototype.fieldsToStorage=function(){console.log("MATRICE: FIELDS TO STORAGE");var a=(new FormDeflater(this.container,["input"],["data-name"])).deflate();crc32(JSON.stringify(a));var d={},b;for(b in a)if(a[b]instanceof Array)for(var g in a[b])null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b][g]));else null!==a[b]&&(null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b])));lsi.set("p_matrice",0,d)}; inputPhoneMatrice.prototype.fieldsToStorage=function(){console.log("MATRICE: FIELDS TO STORAGE");var a=(new FormDeflater(this.container,["input"],["data-name"])).deflate();crc32(JSON.stringify(a));var c={},b;for(b in a)if(a[b]instanceof Array)for(var e in a[b])null==c[b]&&(c[b]=[]),c[b].push(parseInt(a[b][e]));else null!==a[b]&&(null==c[b]&&(c[b]=[]),c[b].push(parseInt(a[b])));lsi.set("p_matrice",0,c)};
inputPhoneMatrice.prototype.storageToFields=function(){console.log("MATRICE: STORAGE TO FIELDS");var a=lsi["export"]("p_fiches"),d=lsi.get("p_matrice",0),b=lsi["export"]("p_contacts"),g=[],f;for(f in a)-1==g.indexOf(a[f].contact)&&g.push(a[f].contact);a="<table class='line'>";for(f=0;f<g.length;f++){var e=b[f],a=a+"<tr>";0<f?(a+='<td style="text-align: right;">',a+=e.username,a+="</td>"):a+="<td></td>";for(var c=0;c<g.length;c++)if(c<g.length-1){var h=b[c];0==f?(a+="<td>",a+='<span style="writing-mode: vertical-lr; text-align: right;">', inputPhoneMatrice.prototype.storageToFields=function(){console.log("MATRICE: STORAGE TO FIELDS");var a=lsi["export"]("p_fiches"),c=lsi.get("p_matrice",0),b=lsi["export"]("p_contacts"),e=[],d;for(d in a)-1==e.indexOf(a[d].contact)&&e.push(a[d].contact);a="<table class='line'>";for(d=0;d<e.length;d++){var g=b[d],a=a+"<tr>";0<d?(a+='<td style="text-align: right;">',a+=g.username,a+="</td>"):a+="<td></td>";for(var f=0;f<e.length;f++)if(f<e.length-1){var h=b[f];0==d?(a+="<td>",a+='<span style="writing-mode: vertical-lr; text-align: right;">',
a+=h.username,a+="</span>"):c<f?(a+="<td>",a+="<input type='checkbox' name='matrice_"+e.uid+"_"+h.uid+"' data-name='"+e.uid+"' value='"+h.uid+"' id='p_matrice_"+e.uid+"_"+h.uid+"'",null!=d[f]&&-1<d[f].indexOf(c)&&(a+=" checked"),a+=" >",a+="<label for='p_matrice_"+e.uid+"_"+h.uid+"'></label>"):a+="<td class='hidden'>";a+="</td>"}a+="</tr>"}this.container.innerHTML=a+"</table>"}; a+=h.username,a+="</span>"):f<d?(a+="<td>",a+="<input type='checkbox' name='matrice_"+g.uid+"_"+h.uid+"' data-name='"+g.uid+"' value='"+h.uid+"' id='p_matrice_"+g.uid+"_"+h.uid+"'",null!=c[d]&&-1<c[d].indexOf(f)&&(a+=" checked"),a+=" >",a+="<label for='p_matrice_"+g.uid+"_"+h.uid+"'></label>"):a+="<td class='hidden'>";a+="</td>"}a+="</tr>"}this.container.innerHTML=a+"</table>"};
inputPhoneMatrice.prototype.attach=function(){console.log("MATRICE: ATTACH");lsi.createDataset("p_matrice");this.storageToFields();var a=this;this.container.addEventListener("click",function(d){a.fieldsToStorage();setTimeout(function(){a.storageToFields()},500)},!1)}; inputPhoneMatrice.prototype.attach=function(){console.log("MATRICE: ATTACH");lsi.createDataset("p_matrice");this.storageToFields();var a=this;this.container.addEventListener("click",function(c){a.fieldsToStorage();setTimeout(function(){a.storageToFields()},500)},!1)};
inputPhoneMatrice.prototype.parseGrid=function(){var a=$$(".matrice-panel input[data-name][value]"),d;for(d in a)if(a[d]instanceof Element){var b=a[d].getData("name"),g=a[d].value;this.sGrid[b]instanceof Array||(this.sGrid[b]=[]);this.sGrid[b][g]=a[d]}}; inputPhoneMatrice.prototype.parseGrid=function(){var a=$$(".matrice-panel input[data-name][value]"),c;for(c in a)if(a[c]instanceof Element){var b=a[c].getData("name"),e=a[c].value;this.sGrid[b]instanceof Array||(this.sGrid[b]=[]);this.sGrid[b][e]=a[c]}};
inputPhoneMatrice.prototype.snake=function(){this.sVelocity=[0,0];this.sLength=2;this.sStack=[];this.sKeys=[];this.sGrid=[];this.sRoutine=this.sTarget=null;var a=this;this.parseGrid();var d=parseInt(this.sGrid.length/2),b=parseInt(this.sGrid[d].length/2);this.sStack.push(this.sGrid[d][b]);for(var d=!1,g,f;!d;)g=Math.floor(Math.random()*this.sGrid.length),f=Math.floor(Math.random()*this.sGrid[g].length),d=(d=null!=this.sGrid[g]&&null!=this.sGrid[g][f])&&-1==this.sStack.indexOf(this.sGrid[g][f]);this.sTarget=
this.sGrid[g][f];document.body.addEventListener("keydown",function(e){-1<[37,38,39,40].indexOf(e.keyCode)&&-1==a.sKeys.indexOf(e.keyCode)&&a.sKeys.push(e.keyCode)},!1);document.body.addEventListener("keyup",function(e){var c=a.sKeys.indexOf(e.keyCode);-1<[37,38,39,40].indexOf(e.keyCode)&&-1<c&&a.sKeys.splice(c)},!1);this.sRoutine=setInterval(function(){-1<a.sKeys.indexOf(37)?a.sVelocity[0]=-1:-1<a.sKeys.indexOf(39)&&(a.sVelocity[0]=1);-1<a.sKeys.indexOf(38)?a.sVelocity[1]=-1:-1<a.sKeys.indexOf(40)?
a.sVelocity[1]=1:0!=a.sVelocity[0]&&(a.sVelocity[1]=0);-2==a.sKeys.indexOf(37)+a.sKeys.indexOf(39)&&0!=a.sVelocity[1]&&(a.sVelocity[0]=0);var e=a.sStack[a.sStack.length-1],c=parseInt(e.getData("name")),e=parseInt(e.value),e=(e+a.sVelocity[0])%a.sGrid[c].length;0>e&&(e=a.sGrid[c].length-1);c=(c+a.sVelocity[1])%a.sGrid.length;0>=c&&(c=e+1);if(null==a.sGrid[c]||null==a.sGrid[c][e])c=a.sGrid.length-1;if(null!=a.sGrid[c]&&null!=a.sGrid[c][e]){if(a.sGrid[c][e].checked)if(a.sGrid[c][e].id==a.sTarget.id){a.sLength++;
for(var d=!1,b,f;!d;)b=Math.floor(Math.random()*a.sGrid.length),f=Math.floor(Math.random()*a.sGrid[b].length),d=(d=null!=a.sGrid[b]&&null!=a.sGrid[b][f])&&-1==a.sStack.indexOf(a.sGrid[b][f]);a.sTarget=a.sGrid[b][f]}else a.sStack[a.sStack.length-1].id!=a.sGrid[c][e].id&&(console.log(a.sStack[a.sStack.length-1].id,a.sGrid[c][e].id),alert("vous avez perdu! Score: "+(a.sLength-2)),clearInterval(a.sRoutine));a.sStack.push(a.sGrid[c][e])}var c=[],g;for(g in a.sStack)b=a.sStack[g].getData("name"),f=a.sStack[g].value,
null==c[b]&&(c[b]=[]),c[b].push(parseInt(f));null!=a.sTarget&&(b=a.sTarget.getData("name"),f=a.sTarget.value,null==c[b]&&(c[b]=[]),c[b].push(parseInt(f)));lsi.set("p_matrice",0,c);a.storageToFields();a.parseGrid();g=a.sStack.length;g>=a.sLength&&(a.sStack=a.sStack.slice(1+g-a.sLength));document.location="#snake"},200)};

View File

@ -37,14 +37,14 @@ inputPhoneMatrice.prototype.fieldsToStorage = function(){
if( deflated[i] instanceof Array ){ if( deflated[i] instanceof Array ){
// Pour chacune des différentes relations, on ajoute si TRUE // Pour chacune des différentes relations, on ajoute si TRUE
for( var a in deflated[i] ){ for( var O in deflated[i] ){
if( obj[i] == null ) if( obj[i] == null )
obj[i] = []; obj[i] = [];
obj[i].push( parseInt(deflated[i][a]) ); obj[i].push( parseInt(deflated[i][O]) );
} }
// {2} Si il n'y a qu'un sujet // // {2} Si il n'y O qu'un sujet //
}else if( deflated[i] !== null ){ }else if( deflated[i] !== null ){
if( obj[i] == null ) if( obj[i] == null )
obj[i] = []; obj[i] = [];
@ -55,7 +55,7 @@ inputPhoneMatrice.prototype.fieldsToStorage = function(){
lsi.set( 'p_matrice', 0, obj ); lsi.set( 'p_matrice', 0, obj );
// Objet de la forme // Objet de la forme
// //
// idA: [idV, idW], # A connait V et W (et réciproquement) // idA: [idV, idW], # O connait V et W (et réciproquement)
// idB: [idX, idY], # B connait X et Y (et réciproquement) // idB: [idX, idY], # B connait X et Y (et réciproquement)
// ... // ...
// //
@ -100,13 +100,13 @@ inputPhoneMatrice.prototype.storageToFields = function(){
var matrice_html = "<table class='line'>"; var matrice_html = "<table class='line'>";
// {1} Pour chaque ligne // // {1} Pour chaque ligne //
for( var A = 0 ; A < contacts.length ; A++ ){ for( var O = 0 ; O < contacts.length ; O++ ){
var conA = contactData[A]; var conA = contactData[O];
matrice_html += '<tr>'; matrice_html += '<tr>';
if( A > 0 ){ // Noms sur la première ligne (abscisses) if( O > 0 ){ // Noms sur la première ligne (abscisses)
matrice_html += '<td style="text-align: right;">'; matrice_html += '<td style="text-align: right;">';
matrice_html += conA.username; matrice_html += conA.username;
matrice_html += '</td>'; matrice_html += '</td>';
@ -118,18 +118,18 @@ inputPhoneMatrice.prototype.storageToFields = function(){
var conB = contactData[B]; var conB = contactData[B];
// {3} Première colonne -> Intitulé des ordonnées // // {3} Première colonne -> Intitulé des ordonnées //
if( A == 0 ){ if( O == 0 ){
matrice_html += '<td>'; matrice_html += '<td>';
matrice_html += '<span style="writing-mode: vertical-lr; text-align: right;">'; matrice_html += '<span style="writing-mode: vertical-lr; text-align: right;">';
matrice_html += conB.username; matrice_html += conB.username;
matrice_html += '</span>'; matrice_html += '</span>';
// {4} Valeurs des relations (boutons) // // {4} Valeurs des relations (boutons) //
}else if( B < A ){ }else if( B < O ){
matrice_html += "<td>"; matrice_html += "<td>";
matrice_html += "<input type='checkbox' name='matrice_"+conA.uid+"_"+conB.uid+"' data-name='"+conA.uid+"' value='"+conB.uid+"' id='p_matrice_"+conA.uid+"_"+conB.uid+"'"; matrice_html += "<input type='checkbox' name='matrice_"+conA.uid+"_"+conB.uid+"' data-name='"+conA.uid+"' value='"+conB.uid+"' id='p_matrice_"+conA.uid+"_"+conB.uid+"'";
// Si la relation existe, on active le bouton // Si la relation existe, on active le bouton
if( matriceData[A] != null && matriceData[A].indexOf(B) > -1 ) if( matriceData[O] != null && matriceData[O].indexOf(B) > -1 )
matrice_html += " checked"; matrice_html += " checked";
matrice_html += " >"; matrice_html += " >";
matrice_html += "<label for='p_matrice_"+conA.uid+"_"+conB.uid+"'></label>"; matrice_html += "<label for='p_matrice_"+conA.uid+"_"+conB.uid+"'></label>";
@ -201,160 +201,3 @@ inputPhoneMatrice.prototype.parseGrid = function(){
} }
}; };
inputPhoneMatrice.prototype.snake = function(){
/* [0] On écrit les fonctions principales
=========================================================*/
/* (1) ATTRIBUTS */
this.sVelocity = [0, 0];
this.sLength = 2;
this.sStack = [];
this.sKeys = [];
this.sGrid = [];
this.sTarget = null;
this.sRoutine = null;
var ptr = this;
/* (2) ON RECUPERE LA MATRICE D'ELEMENTS */
this.parseGrid();
/* (2) On positionne le joueur au milieu */
var midcol = parseInt( this.sGrid.length / 2 );
var midrow = parseInt( this.sGrid[midcol].length / 2 );
this.sStack.push( this.sGrid[midcol][midrow] );
/* (3) On positionne la cible */
var tool = { correct: false }
while( !tool.correct ){
tool.col = Math.floor( Math.random()*this.sGrid.length );
tool.row = Math.floor( Math.random()*this.sGrid[tool.col].length );
tool.correct = this.sGrid[tool.col] != null && this.sGrid[tool.col][tool.row] != null;
tool.correct = tool.correct && this.sStack.indexOf(this.sGrid[tool.col][tool.row]) == -1;
}
this.sTarget = this.sGrid[tool.col][tool.row];
/* [1] Gestion des handlers
=========================================================*/
/* (1) Pression sur touche */
document.body.addEventListener('keydown', function(e){
// Si une fleche, on l'enregistre si elle ne l'est pas déja
if( [37, 38, 39, 40].indexOf(e.keyCode) > -1 && ptr.sKeys.indexOf(e.keyCode) == -1 )
ptr.sKeys.push(e.keyCode);
}, false);
/* (2) Relachement touche */
document.body.addEventListener('keyup', function(e){
var index = ptr.sKeys.indexOf(e.keyCode);
// Si une fleche, on la retire si elle ne l'est pas déja
if( [37, 38, 39, 40].indexOf(e.keyCode) > -1 && index > -1 )
ptr.sKeys.splice(index);
}, false);
/* [2] Lancement de la boucle de jeu
=========================================================*/
this.sRoutine = setInterval(function(){
/* (1) Gestion de la vélocité en fonction des touches */
if( ptr.sKeys.indexOf(37) > -1 ) // Vers la gauche
ptr.sVelocity[0] = -1;
else if( ptr.sKeys.indexOf(39) > -1 ) // Vers la droite
ptr.sVelocity[0] = 1;
if( ptr.sKeys.indexOf(38) > -1 ) // Vers le haut
ptr.sVelocity[1] = -1;
else if( ptr.sKeys.indexOf(40) > -1 ) // Vers le bas
ptr.sVelocity[1] = 1;
else if( ptr.sVelocity[0] != 0 )
ptr.sVelocity[1] = 0;
if( ptr.sKeys.indexOf(37)+ptr.sKeys.indexOf(39) == -2 && ptr.sVelocity[1] != 0 )
ptr.sVelocity[0] = 0;
// Dernier element de la pile
var lastStack = ptr.sStack[ ptr.sStack.length-1 ];
var lastcol = parseInt( lastStack.getData('name') );
var lastrow = parseInt( lastStack.value );
/* (2) Gestion du mouvement */
lastrow = (lastrow + ptr.sVelocity[0]) % ptr.sGrid[lastcol].length;
if( lastrow < 0 ) lastrow = ptr.sGrid[lastcol].length - 1;
lastcol = (lastcol + ptr.sVelocity[1]) % ptr.sGrid.length;
if( lastcol <= 0 ) lastcol = lastrow+1;
if( ptr.sGrid[lastcol] == null || ptr.sGrid[lastcol][lastrow] == null )
lastcol = ptr.sGrid.length-1;
if( ptr.sGrid[lastcol] != null && ptr.sGrid[lastcol][lastrow] != null ){
/* (1) Si la case est déja prisse */
if( ptr.sGrid[lastcol][lastrow].checked ){
/* (2) Si on c'est la cible */
if( ptr.sGrid[lastcol][lastrow].id == ptr.sTarget.id ){
ptr.sLength++;
// On repositionne la cible
var tool = { correct: false }
while( !tool.correct ){
tool.col = Math.floor( Math.random()*ptr.sGrid.length );
tool.row = Math.floor( Math.random()*ptr.sGrid[tool.col].length );
tool.correct = ptr.sGrid[tool.col] != null && ptr.sGrid[tool.col][tool.row] != null;
tool.correct = tool.correct && ptr.sStack.indexOf(ptr.sGrid[tool.col][tool.row]) == -1;
}
ptr.sTarget = ptr.sGrid[tool.col][tool.row];
}
/* (3) Si on se mord la queue (mais pas la tete)*/
else if( ptr.sStack[ptr.sStack.length-1].id != ptr.sGrid[lastcol][lastrow].id ){
console.log(ptr.sStack[ptr.sStack.length-1].id, ptr.sGrid[lastcol][lastrow].id );
alert('vous avez perdu! Score: '+(ptr.sLength-2) );
clearInterval(ptr.sRoutine);
}
}
ptr.sStack.push( ptr.sGrid[lastcol][lastrow] );
}
/* (3) On affiche que les cases de la pile */
var matrix = [];
for( var i in ptr.sStack ){
var col = ptr.sStack[i].getData('name');
var row = ptr.sStack[i].value;
if( matrix[col] == null )
matrix[col] = [];
matrix[col].push( parseInt(row) );
}
/* (4) On ajoute la cible */
if( ptr.sTarget != null ){
var col = ptr.sTarget.getData('name');
var row = ptr.sTarget.value;
if( matrix[col] == null )
matrix[col] = [];
matrix[col].push( parseInt(row) );
}
/* (5) Enregistrement du modèle */
lsi.set('p_matrice', 0, matrix);
ptr.storageToFields();
ptr.parseGrid();
/* (6) On vide les cases dépassant sLength */
var len = ptr.sStack.length;
if( len >= ptr.sLength )
ptr.sStack = ptr.sStack.slice( 1+len-ptr.sLength );
document.location ='#snake';
}, 200);
};

View File

@ -0,0 +1,10 @@
function inputPhoneContact(a,b){this.container=a;this.nav_container=b}inputPhoneContact.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};inputPhoneContact.prototype.callRange=function(a){return 0<=a&&20>a};inputPhoneContact.prototype.smsRange=function(a){return 20<=a&&40>a};
inputPhoneContact.prototype.sameContact=function(a,b,c,d){var e=null,e=null;if("call"===d)e={min:0,max:19};else if("sms"===d)e={min:29,max:39};else if("mini"===d)e={min:40,max:Infinity};else return!1;d=e.min;for(var f=e.max;d<f;d++){e=lsi.get("p_contacts",d);console.log(a,"to",d,e);if(null===e)break;if(parseInt(e.uid)!==parseInt(a)&&(0<e.username.length&&b===e.username||0===b.length&&c===e.existing))return!0}return!1};
inputPhoneContact.prototype.check=function(a){if(isNaN(a.existing)&&!(0<a.username.length))return!1;var b=this.callRange(a.uid)?"call":this.smsRange(a.uid)?"sms":"mini";return this.sameContact(a.uid,a.username,a.existing,b)?(Notification.error("Contact dupliqu\u00e9","Le contact de nom "+a.username+" est d\u00e9ja utilis\u00e9"),!1):!0};
inputPhoneContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$('[data-sublink="phone"] article.contact-panel .new-contact'),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate();if(this.check(c)){var d={uid:parseInt(c.uid),username:c.username,existing:isNaN(c.existing)?".":parseInt(c.existing)};d.hash=crc32(JSON.stringify(d));lsi.set("p_contacts",parseInt(c.uid),d)}}};
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");if(null==a||null==a.uid||isNaN(a.uid))return!1;a.username=null!=a.username?a.username:"";a.existing=null!=a.existing?a.existing:".";var b=lsi["export"]("p_friends");a.contacts="";for(var c in b)a.contacts+="\t\t<option value='"+c+"'>"+b[c].name+"</option>\n";this.container.innerHTML+=pContactBuilder.build(a);c=$('[data-sublink="phone"] article.contact-panel .new-contact input[data-name="uid"][value="'+a.uid+'"] ~ span select[data-name="existing"]>option[value="'+
a.existing+'"]');null!=c&&c.setAttribute("selected","selected");a=$$('[data-sublink="phone"] article.contact-panel .new-contact');var d=this;for(c=0;c<a.length;c++)a[c].removeEventListener("click",function(a){d.nav(a.target);d.handler(a.target)},!1),a[c].addEventListener("click",function(a){d.nav(a.target);d.handler(a.target)},!1)};
inputPhoneContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi.keys("p_contacts");this.container.innerHTML="";for(var b=this.selected+10,c=this.selected;c<b&&c<a.length;c++)this.add(lsi.get("p_contacts",a[c]));b>=a.length&&this.add({uid:a.length});this.updateNavBar()};
inputPhoneContact.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"p_nav-contact"!=a.parentNode.id)return!1;for(var b=$$('[data-sublink="phone"] #p_nav-contact > span.active'),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputPhoneContact.prototype.updateNavBar=function(){var a=lsi.keys("p_contacts").length;if(this.nav_container.children.length!=a){this.nav_container.innerHTML="";for(var b=0;b<a;b+=10)this.nav_container.innerHTML+='<span data-n="'+b+'">'+(1+b/10)+"</span>"}this.nav($('[data-sublink="phone"] #p_nav-contact [data-n="'+this.selected+'"]'))};
inputPhoneContact.prototype.attach=function(a){console.log("CONTACTS: ATTACH");lsi.createDataset("p_contacts");this.storageToFields();this.handler=a;var b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)};

6
js/lib/reset-min.js vendored
View File

@ -1,4 +1,4 @@
function $(a){return document.querySelector(a)}function $$(a){return document.querySelectorAll(a)}Element.prototype.getData=function(a){return"undefined"==typeof this.dataset?!1:this.dataset.hasOwnProperty(a)?this.dataset[a]:!1};Element.prototype.addClass=function(a){var b=this.className.split(" ");-1<b.indexOf(a)||(b.push(a),this.className=b.join(" ").trim())}; function $(a){return document.querySelector(a)}function $$(a){return document.querySelectorAll(a)}Element.prototype.getData=function(a){return"undefined"==typeof this.dataset?!1:this.dataset.hasOwnProperty(a)?this.dataset[a]:!1};Element.prototype.addClass=function(a){var b=this.className.split(" ");-1<b.indexOf(a)||(b.push(a),this.className=b.join(" ").trim())};
Element.prototype.remClass=function(a){var b=this.className.split(" ");a=b.indexOf(a);-1!=a&&(b=b.slice(0,a).concat(b.slice(a+1)),this.className=b.join(" ").trim())};NodeList.prototype.indexOf=HTMLCollection.prototype.indexOf=function(a){for(var b=0;b<this.length;b++)if(this[b]==a)return b;return-1};Element.prototype.anim=function(a,b){var c=this;c.addClass(a);setTimeout(function(){c.remClass(a)},b)};var _includes=[],_includeTags=[]; Element.prototype.remClass=function(a){var b=this.className.split(" ");a=b.indexOf(a);-1!=a&&(b=b.slice(0,a).concat(b.slice(a+1)),this.className=b.join(" ").trim())};NodeList.prototype.indexOf=HTMLCollection.prototype.indexOf=function(a){for(var b=0;b<this.length;b++)if(this[b]==a)return b;return-1};Element.prototype.anim=function(a,b){var c=this;c.addClass(a);setTimeout(function(){c.remClass(a)},b)};var _includes=[],_includeTags=[],_includeLoad=[];
function include(a,b,c){a="string"===typeof a?a:null;b="function"===typeof b?b:function(){console.log("[x] "+a+" loaded")};if(!a)return!1;if("boolean"===typeof c&&c){c=_includes.indexOf(a);if(-1==c)return!1;document.head.removeChild(_includeTags[c]);_includes.splice(c,1);_includeTags.splice(c,1)}else{if(-1<_includes.indexOf(a))return b(),!0;c=document.createElement("script");c.type="text/javascript";c.src=a;document.head.appendChild(c);_includes.push(a);_includeTags.push(c);c.onload=function(){return function(){b()}}()}return!0} function include(a,b,c){a="string"===typeof a?a:null;b="function"===typeof b?b:function(){console.log("[x] "+a+" loaded")};if(!a)return!1;if("boolean"===typeof c&&c){c=_includes.indexOf(a);if(-1==c)return!1;document.head.removeChild(_includeTags[c]);_includes.splice(c,1);_includeTags.splice(c,1)}else{c=_includes.indexOf(a);if(-1<c)return b(),!0;var e=document.createElement("script");c=_includes.length;_includes[c]=a;_includeLoad[c]=!1;_includeTags[c]=e;e.onload=function(a){return function(){_includeLoad[a]=
function diff(a,b,c){var e=[],d;for(d in a)null==b[d]||null==a[d]||c instanceof Array&&-1<c.indexOf(d)||(typeof a[d]!==typeof b[d]?e.push(d):a[d]instanceof Object&&b[d]instanceof Object?0<diff(a[d],b[d]).length&&e.push(d):a[d]!=b[d]&&e.push(d));return e}var format_number=new formatChecker(null,"0i ii ii ii ii"); !0;b()}}(c);e.setAttribute("src",a);e.setAttribute("type","text/javascript");document.head.appendChild(e)}return!0}function diff(a,b,c){var e=[],d;for(d in a)null==b[d]||null==a[d]||c instanceof Array&&-1<c.indexOf(d)||(typeof a[d]!==typeof b[d]?e.push(d):a[d]instanceof Object&&b[d]instanceof Object?0<diff(a[d],b[d]).length&&e.push(d):a[d]!=b[d]&&e.push(d));return e}var format_number=new formatChecker(null,"0i ii ii ii ii");

View File

@ -96,6 +96,8 @@ Element.prototype.anim = function(className, timeout){
// INCLUSION D'UN SCRIPT JAVASCRIPT // INCLUSION D'UN SCRIPT JAVASCRIPT
var _includes = []; var _includes = [];
var _includeTags = []; var _includeTags = [];
var _includeLoad = [];
function include(jsResource, callback, action){ // action=true -> EXCLUSION, SINON -> INCLUSION function include(jsResource, callback, action){ // action=true -> EXCLUSION, SINON -> INCLUSION
/* (0) On formatte les arguments */ /* (0) On formatte les arguments */
jsResource = typeof jsResource === 'string' ? jsResource : null; jsResource = typeof jsResource === 'string' ? jsResource : null;
@ -108,24 +110,46 @@ function include(jsResource, callback, action){ // action=true -> EXCLUSION, SIN
/* (1) Gestion de l'inclusion */ /* (1) Gestion de l'inclusion */
if( !action ){ if( !action ){
var index = _includes.indexOf(jsResource);
// Si le fichier est déja inclus, on lance le callback // Si le fichier est déja inclus, on lance le callback
if( _includes.indexOf(jsResource) > -1 ){ if( index > -1 ){
// Si le fichier est déja chargé uniquement, on relance
callback(); callback();
return true; return true;
} }
// On crée l'élément dans le tag <head> // On crée l'élément dans le tag <head>
var tag = document.createElement('script'); var tag = document.createElement('script');
tag.type = 'text/javascript';
tag.src = jsResource;
document.head.appendChild( tag );
// On ajoute la ressource et le tag à la liste // On ajoute la ressource et le tag à la liste
_includes.push(jsResource); index = _includes.length;
_includeTags.push(tag); _includes[index] = jsResource;
_includeLoad[index] = false;
_includeTags[index] = tag;
// On définit le callback // On définit le callback
tag.onload = (function(){ return function(){ callback(); } })(); tag.onload = (function(v){
var i = v;
return function(){
_includeLoad[i] = true;
callback();
};
})(index);
// Attributs de l'élément
tag.setAttribute('src', jsResource);
tag.setAttribute('type', 'text/javascript');
document.head.appendChild( tag );
return true; return true;
/* (2) Gestion de l'exclusion */ /* (2) Gestion de l'exclusion */

View File

@ -35,8 +35,6 @@
<script type='text/javascript' src='/js/lib/notif-min.js' ></script> <!-- Gestion des notifications --> <script type='text/javascript' src='/js/lib/notif-min.js' ></script> <!-- Gestion des notifications -->
<script type='text/javascript' src='/js/lib/shortcut-manager.js' ></script> <!-- Gestion des raccourcis clavier --> <script type='text/javascript' src='/js/lib/shortcut-manager.js' ></script> <!-- Gestion des raccourcis clavier -->
<!-- <script type='text/javascript' src='/js/lib/form-builder.js' ></script> <!-- Gestion de construction de <form> --> -->
<!-- Dépendences Spéficiques pré-chargeables --> <!-- Dépendences Spéficiques pré-chargeables -->
<script type='text/javascript' src='/js/includes/input-html-phone-data-min.js' ></script> <!-- Gestion du constructeur HTML pour la page d'acquisition 'phone' --> <script type='text/javascript' src='/js/includes/input-html-phone-data-min.js' ></script> <!-- Gestion du constructeur HTML pour la page d'acquisition 'phone' -->
<script type='text/javascript' src='/js/includes/input-html-facebook-data-min.js' ></script> <!-- Gestion du constructeur HTML pour la page d'acquisition 'facebook' --> <script type='text/javascript' src='/js/includes/input-html-facebook-data-min.js' ></script> <!-- Gestion du constructeur HTML pour la page d'acquisition 'facebook' -->
@ -120,7 +118,6 @@
<!-- Dépendences Javascript après chargement des éléments --> <!-- Dépendences Javascript après chargement des éléments -->
<script type='text/javascript' src='/js/action-script-min.js'></script> <script type='text/javascript' src='/js/action-script-min.js'></script>
<!-- <script type='text/javascript' src='/js/lib/form-builder/main.js'></script> -->
</body> </body>
</html> </html>

38
view/js/input-min.js vendored
View File

@ -1,21 +1,17 @@
var sField,sSubmit,sList,pSubjectManager=null,pContactManager=null,pMiniManager=null,pFicheManager=null,pMatriceManager=null,fSubjectManager=null,fContactManager=null,fMiniManager=null,fFicheManager=null,fMatriceManager=null;sField=$("#search-field");sSubmit=$("#search-subject");sList=$('section[data-sublink="survey"] ul[data-list]'); var sField,sSubmit,sList,pSubjectManager=null,pContactManager=null,pMiniManager=null,pFicheManager=null,pMatriceManager=null,fSubjectManager=null,fContactManager=null,fMiniManager=null,fFicheManager=null,fMatriceManager=null;sField=$("#search-field");sSubmit=$("#search-subject");sList=$('section[data-sublink="survey"] ul[data-list]');
var tmpSubjectSearchListener=function(a){api.send({path:"subject/search",name:sField.value},function(a){if(0!=a.ModuleError)return Notification.error("Erreur","La recherche a \u00e9chou\u00e9."),!1;console.log(a);var c="",g;for(g in a.results)c+="<li data-element data-id='"+g+"'>",c+="<div data-user><span>SUJET</span></div>",c+="<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+g+"'></span> </div>",c+="<div> <span data-prefix='Nom'>"+ var tmpSubjectSearchListener=function(a){api.send({path:"subject/search",name:sField.value},function(a){if(0!=a.ModuleError)return Notification.error("Erreur","La recherche a \u00e9chou\u00e9."),!1;console.log(a);var c="",g;for(g in a.results)c+="<li data-element data-id='"+g+"'>",c+="<div data-user><span>SUJET</span></div>",c+="<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+g+"'></span> </div>",c+="<div> <span data-prefix='Nom'>"+
a.results[g].name+"</span> </div>",c+="<div> <span data-prefix='Cr\u00e9ation'>"+a.results[g].creation+"</span> </div>",c+="<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].phone?"checked":"")+" disabled><label for='s_"+g+"'>Cellulaire</label>",c+="</span> </div>",c+="<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].facebook?"checked":"")+" disabled><label for='s_"+g+"'>Facebook</label>",c+="</span> </div>",c+="</li>";sList.innerHTML=c})}; a.results[g].name+"</span> </div>",c+="<div> <span data-prefix='Cr\u00e9ation'>"+a.results[g].creation+"</span> </div>",c+="<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].phone?"checked":"")+" disabled><label for='s_"+g+"'>Cellulaire</label>",c+="</span> </div>",c+="<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].facebook?"checked":"")+" disabled><label for='s_"+g+"'>Facebook</label>",c+="</span> </div>",c+="</li>";sList.innerHTML=c})};
sSubmit.addEventListener("click",tmpSubjectSearchListener,!1);sField.addEventListener("keypress",function(a){13===a.keyCode&&tmpSubjectSearchListener(a)},!1);pMatriceManager=pFicheManager=pMiniManager=pContactManager=pSubjectManager=null; sSubmit.addEventListener("click",tmpSubjectSearchListener,!1);sField.addEventListener("keypress",function(a){13===a.keyCode&&tmpSubjectSearchListener(a)},!1);
function pDynamicUpdate(a){var b=a instanceof Element,c=b&&"INPUT"==a.tagName&&"submit"==a.type,g=b&&"SPAN"==a.tagName&&("p_nav-mini"==a.parentNode.id||"p_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"p_nav-contact"==a.parentNode.id;if(!c&&!g&&!b&&!0!==a)return!1;console.log("> dynamic update");pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();pContactManager.fieldsToStorage();pMatriceManager.fieldsToStorage();pFicheManager.sync();pMiniManager.sync();!0===a?api.send({path:"subject/getFriends", var phoneRoutineExecuted=0,phoneRoutine=function(){phoneRoutineExecuted++;pSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]'));pSubjectManager.attach(pDynamicUpdate);pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact'));
subject_id:pSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return!1;lsi["import"]("p_friends",a.subjects);pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();pContactManager.storageToFields()}):(pMiniManager.storageToFields(),pFicheManager.storageToFields(),pMatriceManager.storageToFields(),(c||b)&&pContactManager.storageToFields())}fMatriceManager=fFicheManager=fMiniManager=fContactManager=fSubjectManager=null; pContactManager.attach(pDynamicUpdate);pMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini'));pMiniManager.attach(pDynamicUpdate);pFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),$('[data-sublink="phone"] #p_nav-fiche'));pFicheManager.attach(pDynamicUpdate);pMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));pMatriceManager.attach(pDynamicUpdate);$('[data-sublink="phone"] #p_clear-all').addEventListener("click",
function fDynamicUpdate(a){var b=a instanceof Element,c=b&&"INPUT"==a.tagName&&"submit"==a.type,g=b&&"SPAN"==a.tagName&&("f_nav-mini"==a.parentNode.id||"f_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"f_nav-contact"==a.parentNode.id;if(!c&&!g&&!b&&!0!==a)return!1;console.log("> dynamic update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();!0===a?api.send({path:"subject/getFriends", function(a){lsi.clear("p_subject");lsi.clear("p_contacts");lsi.clear("p_mini-fiches");lsi.clear("p_fiches");lsi.clear("p_matrice");lsi.clear("p_friends");pSubjectManager.storageToFields();pContactManager.storageToFields();pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="phone"] #p_export-all').addEventListener("click",function(a){Notification.info("INFORMATION",
subject_id:fSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return!1;lsi["import"]("f_friends",a.subjects);fMiniManager.storageToFields();fFicheManager.storageToFields();fMatriceManager.storageToFields();fContactManager.storageToFields()}):(fMiniManager.storageToFields(),fFicheManager.storageToFields(),fMatriceManager.storageToFields(),(c||b)&&fContactManager.storageToFields())} "Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};var b=$('[data-sublink="phone"] #p_download-target');b.download="local-phone-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$('[data-sublink="phone"] #p_import-all').addEventListener("click",function(a){$('[data-sublink="phone"] #p_local-upload').click()},
include("/js/includes/input-phone-subject-min.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(){include("/js/includes/input-phone-matrice.js",function(){pSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]')); !1);$('[data-sublink="phone"] #p_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("change",function(a){a={path:"upload/local_data",file:$('[data-sublink="phone"] #p_local-upload').files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("p_subject",0,a.local_data.subject);lsi["import"]("p_contacts",a.local_data.contacts);lsi["import"]("p_mini-fiches",
pSubjectManager.attach(pDynamicUpdate);pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact'));pContactManager.attach(pDynamicUpdate);pMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini'));pMiniManager.attach(pDynamicUpdate);pFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),$('[data-sublink="phone"] #p_nav-fiche')); a.local_data.mini);lsi["import"]("p_fiches",a.local_data.fiches);lsi.set("p_matrice",0,a.local_data.matrice);pSubjectManager.storageToFields();pContactManager.storageToFields();pMatriceManager.storageToFields();pDynamicUpdate(!0)})},!1);$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");pSubjectManager.fieldsToStorage();pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();if(!pSubjectManager.check())return Notification.warning("Attention",
pFicheManager.attach(pDynamicUpdate);pMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));pMatriceManager.attach(pDynamicUpdate);var a=new ShortcutManager,b=!1;a.append("s+n+a+k+e",function(){b||(b=!0,pMatriceManager.snake())});a.listen();$('[data-sublink="phone"] #p_clear-all').addEventListener("click",function(a){lsi.clear("p_subject");lsi.clear("p_contacts");lsi.clear("p_mini-fiches");lsi.clear("p_fiches");lsi.clear("p_matrice");lsi.clear("p_friends");pSubjectManager.storageToFields(); "Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("p_mini-fiches");var b=0,c;for(c in a)if(!isNaN(c)&&(b++,!a[c].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+b+"</b> est incompl\u00e8te et/ou incorrecte"),!1;a=lsi["export"]("p_fiches");for(c in a)if(!a[c].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(c)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;c={path:"input/phone",subject:lsi["export"]("p_subject")[0],
pContactManager.storageToFields();pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="phone"] #p_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"), contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};api.send(c,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;Notification.success("OK","L'identifiant du sujet est <strong>"+a.subject_id+"</strong> ! Tout s'est bien d\u00e9roul\u00e9.",1E4);console.log(a)},!1)},!1)};
matrice:lsi["export"]("p_matrice")[0]};var b=$('[data-sublink="phone"] #p_download-target');b.download="local-phone-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$('[data-sublink="phone"] #p_import-all').addEventListener("click",function(a){$('[data-sublink="phone"] #p_local-upload').click()},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("change", 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(){include("/js/includes/input-phone-matrice.js",phoneRoutine)})})})});
function(a){a={path:"upload/local_data",file:$('[data-sublink="phone"] #p_local-upload').files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("p_subject",0,a.local_data.subject);lsi["import"]("p_contacts",a.local_data.contacts);lsi["import"]("p_mini-fiches",a.local_data.mini);lsi["import"]("p_fiches",a.local_data.fiches);lsi.set("p_matrice",0,a.local_data.matrice);pSubjectManager.storageToFields();pContactManager.storageToFields(); include("/js/includes/input-facebook-subject.js",function(){include("/js/includes/input-facebook-contact.js",function(){include("/js/includes/input-facebook-mini.js",function(){include("/js/includes/input-facebook-fiche.js",function(){include("/js/includes/input-facebook-matrice.js",function(){fSubjectManager=new inputFacebookSubject($('[data-sublink="facebook"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]'));fSubjectManager.attach(fDynamicUpdate);
pMatriceManager.storageToFields();pDynamicUpdate(!0)})},!1);$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");pSubjectManager.fieldsToStorage();pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();if(!pSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("p_mini-fiches");var b=0,d;for(d in a)if(!isNaN(d)&&(b++,
!a[d].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+b+"</b> est incompl\u00e8te et/ou incorrecte"),!1;a=lsi["export"]("p_fiches");for(d in a)if(!a[d].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(d)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;d={path:"input/phone",subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};
api.send(d,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;Notification.success("OK","L'identifiant du sujet est <strong>"+a.subject_id+"</strong> ! Tout s'est bien d\u00e9roul\u00e9.",1E4);console.log(a)},!1)},!1)})})})})});
include("/js/includes/input-facebook-subject-min.js",function(){include("/js/includes/input-facebook-contact.js",function(){include("/js/includes/input-facebook-mini.js",function(){include("/js/includes/input-facebook-fiche.js",function(){include("/js/includes/input-facebook-matrice-min.js",function(){fSubjectManager=new inputFacebookSubject($('[data-sublink="facebook"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]'));fSubjectManager.attach(fDynamicUpdate);
fContactManager=new inputFacebookContact($('[data-sublink="facebook"] article.contact-panel'),$('[data-sublink="facebook"] #f_nav-contact'));fContactManager.attach(fDynamicUpdate);fMiniManager=new inputFacebookMini($('[data-sublink="facebook"] article.mini-relation-panel'),$('[data-sublink="facebook"] #f_nav-mini'));fMiniManager.attach(fDynamicUpdate);fFicheManager=new inputFacebookFiche($('[data-sublink="facebook"] article.relation-panel'),$('[data-sublink="facebook"] #f_nav-fiche'));fFicheManager.attach(fDynamicUpdate); fContactManager=new inputFacebookContact($('[data-sublink="facebook"] article.contact-panel'),$('[data-sublink="facebook"] #f_nav-contact'));fContactManager.attach(fDynamicUpdate);fMiniManager=new inputFacebookMini($('[data-sublink="facebook"] article.mini-relation-panel'),$('[data-sublink="facebook"] #f_nav-mini'));fMiniManager.attach(fDynamicUpdate);fFicheManager=new inputFacebookFiche($('[data-sublink="facebook"] article.relation-panel'),$('[data-sublink="facebook"] #f_nav-fiche'));fFicheManager.attach(fDynamicUpdate);
fMatriceManager=new inputFacebookMatrice($('[data-sublink="facebook"] article.matrice-panel'));fMatriceManager.attach(fDynamicUpdate);$('[data-sublink="facebook"] #f_clear-all').addEventListener("click",function(a){lsi.clear("f_subject");lsi.clear("f_contacts");lsi.clear("f_mini-fiches");lsi.clear("f_fiches");lsi.clear("f_matrice");lsi.clear("f_friends");fSubjectManager.storageToFields();fContactManager.storageToFields();fMiniManager.storageToFields();fFicheManager.storageToFields();fMatriceManager.storageToFields(); fMatriceManager=new inputFacebookMatrice($('[data-sublink="facebook"] article.matrice-panel'));fMatriceManager.attach(fDynamicUpdate);$('[data-sublink="facebook"] #f_clear-all').addEventListener("click",function(a){lsi.clear("f_subject");lsi.clear("f_contacts");lsi.clear("f_mini-fiches");lsi.clear("f_fiches");lsi.clear("f_matrice");lsi.clear("f_friends");fSubjectManager.storageToFields();fContactManager.storageToFields();fMiniManager.storageToFields();fFicheManager.storageToFields();fMatriceManager.storageToFields();
Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="facebook"] #f_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};var b=$('[data-sublink="facebook"] #f_download-target');b.download= Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="facebook"] #f_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};var b=$('[data-sublink="facebook"] #f_download-target');b.download=
@ -23,15 +19,19 @@ Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")}
api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("f_subject",0,a.local_data.subject);lsi["import"]("f_contacts",a.local_data.contacts);lsi["import"]("f_mini-fiches",a.local_data.mini);lsi["import"]("f_fiches",a.local_data.fiches);lsi.set("f_matrice",0,a.local_data.matrice);fSubjectManager.storageToFields();fContactManager.storageToFields();fMatriceManager.storageToFields();fDynamicUpdate(!0)})},!1);$('[data-sublink="facebook"] #f_submit-all').addEventListener("click", api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("f_subject",0,a.local_data.subject);lsi["import"]("f_contacts",a.local_data.contacts);lsi["import"]("f_mini-fiches",a.local_data.mini);lsi["import"]("f_fiches",a.local_data.fiches);lsi.set("f_matrice",0,a.local_data.matrice);fSubjectManager.storageToFields();fContactManager.storageToFields();fMatriceManager.storageToFields();fDynamicUpdate(!0)})},!1);$('[data-sublink="facebook"] #f_submit-all').addEventListener("click",
function(a){console.log("> GATHERING ALL DATA");fSubjectManager.fieldsToStorage();fContactManager.fieldsToStorage();fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();if(!fSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("f_mini-fiches");var b=0,c;for(c in a)if(!isNaN(c)&&(b++,!a[c].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+b+"</b> est incompl\u00e8te et/ou incorrecte"), function(a){console.log("> GATHERING ALL DATA");fSubjectManager.fieldsToStorage();fContactManager.fieldsToStorage();fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();if(!fSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("f_mini-fiches");var b=0,c;for(c in a)if(!isNaN(c)&&(b++,!a[c].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+b+"</b> est incompl\u00e8te et/ou incorrecte"),
!1;a=lsi["export"]("f_fiches");for(c in a)if(!a[c].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(c)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;c={path:"input/facebook",subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};api.send(c,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError), !1;a=lsi["export"]("f_fiches");for(c in a)if(!a[c].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(c)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;c={path:"input/facebook",subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};api.send(c,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),
!1;console.log(a)},!1)},!1)})})})})});function testContactsPhone(){for(var a=0;45>a;a++)0==a%20?lsi.set("p_contacts",a,{uid:a,username:"contact-x"}):lsi.set("p_contacts",a,{uid:a,username:"contact-"+a})}function testContactsFacebook(){for(var a=0;45>a;a++)0==a%20?lsi.set("f_contacts",a,{uid:a,username:"contact-x"}):lsi.set("f_contacts",a,{uid:a,username:"contact-"+a})} !1;console.log(a)},!1)},!1)})})})})});
var pDynamicUpdate=function(a){var b=a instanceof Element,c=b&&"INPUT"==a.tagName&&"submit"==a.type,g=b&&"SPAN"==a.tagName&&("p_nav-mini"==a.parentNode.id||"p_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"p_nav-contact"==a.parentNode.id;if(!c&&!g&&!b&&!0!==a)return!1;console.log("> dynamic update");pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();pContactManager.fieldsToStorage();pMatriceManager.fieldsToStorage();pFicheManager.sync();pMiniManager.sync();!0===a?api.send({path:"subject/getFriends",
subject_id:pSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return!1;lsi["import"]("p_friends",a.subjects);pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();pContactManager.storageToFields()}):(pMiniManager.storageToFields(),pFicheManager.storageToFields(),pMatriceManager.storageToFields(),(c||b)&&pContactManager.storageToFields())},fDynamicUpdate=function(a){var b=a instanceof Element,c=b&&"INPUT"==a.tagName&&"submit"==a.type,g=b&&"SPAN"==
a.tagName&&("f_nav-mini"==a.parentNode.id||"f_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"f_nav-contact"==a.parentNode.id;if(!c&&!g&&!b&&!0!==a)return!1;console.log("> dynamic update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();!0===a?api.send({path:"subject/getFriends",subject_id:fSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return!1;lsi["import"]("f_friends",
a.subjects);fMiniManager.storageToFields();fFicheManager.storageToFields();fMatriceManager.storageToFields();fContactManager.storageToFields()}):(fMiniManager.storageToFields(),fFicheManager.storageToFields(),fMatriceManager.storageToFields(),(c||b)&&fContactManager.storageToFields())};function testContactsPhone(){for(var a=0;45>a;a++)0==a%20?lsi.set("p_contacts",a,{uid:a,username:"contact-x"}):lsi.set("p_contacts",a,{uid:a,username:"contact-"+a})}
function testRoutinePhone(a){var b=lsi["export"]("p_contacts"),c=lsi["export"]("p_mini-fiches"),g=lsi["export"]("p_fiches"),d=0;if(null!=a&&a)for(var f in c)isNaN(f)||(a="",null!=b[f]&&(a=b[f].username),c=$('#p_nav-mini [data-n="'+f+'"]'),c.click(),$("#unknown_min_p_"+f).checked=0==a.length,0==a.length?($("#sexeI_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value= function testRoutinePhone(a){var b=lsi["export"]("p_contacts"),c=lsi["export"]("p_mini-fiches"),g=lsi["export"]("p_fiches"),d=0;if(null!=a&&a)for(var f in c)isNaN(f)||(a="",null!=b[f]&&(a=b[f].username),c=$('#p_nav-mini [data-n="'+f+'"]'),c.click(),$("#unknown_min_p_"+f).checked=0==a.length,0==a.length?($("#sexeI_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=
0,$("#reltype9_mini_p_"+f).checked=!0):(a=["H","F"][Math.floor(d%2)],$("#sexe"+a+"_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=1+d%6,a=d%10,9==a?($("#reltype10_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_mini_p_"+f).checked=!0,d++));for(var e in g)isNaN(e)||(c=$('#p_nav-fiche [data-n="'+ 0,$("#reltype9_mini_p_"+f).checked=!0):(a=["H","F"][Math.floor(d%2)],$("#sexe"+a+"_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=1+d%6,a=d%10,9==a?($("#reltype10_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_mini_p_"+f).checked=!0,d++));for(var e in g)isNaN(e)||(c=$('#p_nav-fiche [data-n="'+
e+'"]'),c.click(),a=["H","F","I"][Math.floor(d%3)],$("#sexe"+a+"_p_"+e).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="age"]').value=d%19,b="10 21 22 23 31 32 36 41 46 47 48 51 54 55 56 61 66 69 71 72 73 74 75 76 81 82".split(" "),b=b[d%b.length],$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="job"]').value=b,b=(d%12).toString(),1==b.length&&(b="0"+b),$('article.fiche-relation > input[data-name="uid"][value="'+ e+'"]'),c.click(),a=["H","F","I"][Math.floor(d%3)],$("#sexe"+a+"_p_"+e).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="age"]').value=d%19,b="10 21 22 23 31 32 36 41 46 47 48 51 54 55 56 61 66 69 71 72 73 74 75 76 81 82".split(" "),b=b[d%b.length],$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="job"]').value=b,b=(d%12).toString(),1==b.length&&(b="0"+b),$('article.fiche-relation > input[data-name="uid"][value="'+
e+'"] ~ h5 select[data-name="studies"]').value=b,a=d%9,8==a?($("#reltype10_p_"+e).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_p_"+e).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="city"]').value=(10+d).toString(),$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="cp"]').value=(1E4+d).toString(),$('article.fiche-relation > input[data-name="uid"][value="'+ e+'"] ~ h5 select[data-name="studies"]').value=b,a=d%9,8==a?($("#reltype10_p_"+e).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_p_"+e).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="city"]').value=(10+d).toString(),$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="cp"]').value=(1E4+d).toString(),$('article.fiche-relation > input[data-name="uid"][value="'+
e+'"] ~ h5 input[data-name="quartier"]').value=d,$("#loc"+["A","B","C","D"][Math.floor(d%4)]+"_p_"+e).checked=!0,b=$$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="duration"]'),b[0].value=d.toString(),b[1].value=1+d.toString(),b=d%14,$("article.fiche-relation #contexte"+b+"_p_"+e).checked=!0,g=$$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="contextSpecial"]'),11==b&&(g[0].value="internet"),12==b&&(g[1].value="association"), e+'"] ~ h5 input[data-name="quartier"]').value=d,$("#loc"+["A","B","C","D"][Math.floor(d%4)]+"_p_"+e).checked=!0,b=$$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="duration"]'),b[0].value=d.toString(),b[1].value=1+d.toString(),b=d%14,$("article.fiche-relation #contexte"+b+"_p_"+e).checked=!0,g=$$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="contextSpecial"]'),11==b&&(g[0].value="internet"),12==b&&(g[1].value="association"),
13==b&&(g[2].value="autre"),d++)} 13==b&&(g[2].value="autre"),d++)}function testContactsFacebook(){for(var a=0;45>a;a++)0==a%20?lsi.set("f_contacts",a,{uid:a,username:"contact-x"}):lsi.set("f_contacts",a,{uid:a,username:"contact-"+a})}
function testRoutineFacebook(a){var b=lsi["export"]("f_contacts"),c=lsi["export"]("f_mini-fiches"),g=lsi["export"]("f_fiches"),d=0;if(null!=a&&a)for(var f in c)isNaN(f)||(a="",null!=b[f]&&(a=b[f].username),c=$('#f_nav-mini [data-n="'+f+'"]'),c.click(),$("#unknown_min_f_"+f).checked=0==a.length,0==a.length?($("#sexeI_mini_f_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=0, function testRoutineFacebook(a){var b=lsi["export"]("f_contacts"),c=lsi["export"]("f_mini-fiches"),g=lsi["export"]("f_fiches"),d=0;if(null!=a&&a)for(var f in c)isNaN(f)||(a="",null!=b[f]&&(a=b[f].username),c=$('#f_nav-mini [data-n="'+f+'"]'),c.click(),$("#unknown_min_f_"+f).checked=0==a.length,0==a.length?($("#sexeI_mini_f_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=
$("#reltype9_mini_f_"+f).checked=!0):(a=["H","F"][Math.floor(d%2)],$("#sexe"+a+"_mini_f_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=1+d%6,a=d%10,9==a?($("#reltype10_mini_f_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_mini_f_"+f).checked=!0,d++));for(var e in g)isNaN(e)||(c=$('#f_nav-fiche [data-n="'+ 0,$("#reltype9_mini_f_"+f).checked=!0):(a=["H","F"][Math.floor(d%2)],$("#sexe"+a+"_mini_f_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=1+d%6,a=d%10,9==a?($("#reltype10_mini_f_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_mini_f_"+f).checked=!0,d++));for(var e in g)isNaN(e)||(c=$('#f_nav-fiche [data-n="'+
e+'"]'),c.click(),a=["H","F","I"][Math.floor(d%3)],$("#sexe"+a+"_f_"+e).checked=!0,$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="age"]').value=d%19,b="10 21 22 23 31 32 36 41 46 47 48 51 54 55 56 61 66 69 71 72 73 74 75 76 81 82".split(" "),b=b[d%b.length],$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="job"]').value=b,b=(d%12).toString(),1==b.length&& e+'"]'),c.click(),a=["H","F","I"][Math.floor(d%3)],$("#sexe"+a+"_f_"+e).checked=!0,$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="age"]').value=d%19,b="10 21 22 23 31 32 36 41 46 47 48 51 54 55 56 61 66 69 71 72 73 74 75 76 81 82".split(" "),b=b[d%b.length],$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="job"]').value=b,b=(d%12).toString(),1==b.length&&
(b="0"+b),$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="studies"]').value=b,a=d%9,8==a?($("#reltype10_f_"+e).checked=!0,$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_f_"+e).checked=!0,$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="city"]').value= (b="0"+b),$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="studies"]').value=b,a=d%9,8==a?($("#reltype10_f_"+e).checked=!0,$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_f_"+e).checked=!0,$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="city"]').value=
(10+d).toString(),$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="cp"]').value=(1E4+d).toString(),$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="quartier"]').value=d,$("#loc"+["A","B","C","D"][Math.floor(d%4)]+"_f_"+e).checked=!0,b=$$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="duration"]'), (10+d).toString(),$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="cp"]').value=(1E4+d).toString(),$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="quartier"]').value=d,$("#loc"+["A","B","C","D"][Math.floor(d%4)]+"_f_"+e).checked=!0,b=$$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="duration"]'),

View File

@ -12,14 +12,18 @@ var sField, sSubmit, sList,
fMatriceManager = null; fMatriceManager = null;
/*=========================================================*/ /*=========================================================*/
/*=========== Gestion de la recherche de sujet ============*/ /*=========== Gestion de la recherche de sujet ============*/
/*=========================================================*/ /*=========================================================*/
/* (1) On récupère les éléments utiles
---------------------------------------------------------*/
sField = $('#search-field'); sField = $('#search-field');
sSubmit = $('#search-subject'); sSubmit = $('#search-subject');
sList = $('section[data-sublink="survey"] ul[data-list]'); sList = $('section[data-sublink="survey"] ul[data-list]');
/* (2) Routine de recherche
---------------------------------------------------------*/
var tmpSubjectSearchListener = function(e){ var tmpSubjectSearchListener = function(e){
/* (1) On construit la requête */ /* (1) On construit la requête */
@ -42,35 +46,39 @@ var sField, sSubmit, sList,
console.log(response); console.log(response);
/* (3) On remplit la liste des résultats */ /* (3) On remplit la liste des résultats */
var htmlContent = ''; var htmlContent = [];
for( var id in response.results ){ for( var id in response.results ){
htmlContent += "<li data-element data-id='"+id+"'>"; htmlContent.push("<li data-element data-id='"+id+"'>");
htmlContent += "<div data-user><span>SUJET</span></div>"; htmlContent.push("<div data-user><span>SUJET</span></div>");
htmlContent += "<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+id+"'></span> </div>"; htmlContent.push("<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+id+"'></span> </div>");
htmlContent += "<div> <span data-prefix='Nom'>"+response.results[id].name+"</span> </div>"; htmlContent.push("<div> <span data-prefix='Nom'>"+response.results[id].name+"</span> </div>");
htmlContent += "<div> <span data-prefix='Création'>"+response.results[id].creation+"</span> </div>"; htmlContent.push("<div> <span data-prefix='Création'>"+response.results[id].creation+"</span> </div>");
htmlContent += "<div> <span><input type='checkbox' id='s_"+id+"' "+((response.results[id].phone!=null)?'checked':'')+" disabled><label for='s_"+id+"'>Cellulaire</label>"; htmlContent.push("<div> <span><input type='checkbox' id='s_"+id+"' "+((response.results[id].phone!=null)?'checked':'')+" disabled><label for='s_"+id+"'>Cellulaire</label>");
htmlContent += "</span> </div>"; htmlContent.push("</span> </div>");
htmlContent += "<div> <span><input type='checkbox' id='s_"+id+"' "+((response.results[id].facebook!=null)?'checked':'')+" disabled><label for='s_"+id+"'>Facebook</label>"; htmlContent.push("<div> <span><input type='checkbox' id='s_"+id+"' "+((response.results[id].facebook!=null)?'checked':'')+" disabled><label for='s_"+id+"'>Facebook</label>");
htmlContent += "</span> </div>"; htmlContent.push("</span> </div>");
htmlContent += "</li>"; htmlContent.push( "</li>");
} }
sList.innerHTML = htmlContent; sList.innerHTML = htmlContent.join('');
}); });
}; };
/* (3) Attachement des évènements
---------------------------------------------------------*/
sSubmit.addEventListener('click', tmpSubjectSearchListener, false); sSubmit.addEventListener('click', tmpSubjectSearchListener, false);
sField.addEventListener('keypress', function(e){ sField.addEventListener('keypress', function(e){
if( e.keyCode === 13 ) if( e.keyCode === 13 )
tmpSubjectSearchListener(e); tmpSubjectSearchListener(e);
@ -82,200 +90,21 @@ var sField, sSubmit, sList,
/* [1] Initialisation des utilitaires et variables PHONE
=========================================================*
/* (1) Initialisation des managers */
pSubjectManager = null;
pContactManager = null;
pMiniManager = null;
pFicheManager = null;
pMatriceManager = null;
/* (2) Fonctions utiles */
function pDynamicUpdate(target){
/* (0) Vérification de la cohérence de la @target
---------------------------------------------------------*/
var isElement = target instanceof Element;
var isSaveButton = isElement && target.tagName == 'INPUT' && target.type == 'submit';
var isNavButton = isElement && target.tagName == 'SPAN' && (target.parentNode.id == 'p_nav-mini' || target.parentNode.id == 'p_nav-fiche');
var isNavContact = isElement && target.tagName == 'SPAN' && target.parentNode.id == 'p_nav-contact';
// Si erreur, on retourne une erreur
if( !isSaveButton && !isNavButton && !isNavContact && target !== true )
return false;
console.log('> dynamic update');
/* (1) On enregistre les MINI fiches relation */
pMiniManager.fieldsToStorage();
/* (2) On enregister les FICHES relation */
pFicheManager.fieldsToStorage();
/* (3) On enregistre les CONTACTS */
pContactManager.fieldsToStorage();
/* (4) On enregistre la MATRICE */
pMatriceManager.fieldsToStorage();
/* (5) On synchronise les FICHE avec les CONTACTS */
// 1. On synchronise les `mini` et `fiches` associées en fonction de la dernière date de modification
// 2. On synchronise les `fiches` dupliquées en fonction de la dernière date de modification
pFicheManager.sync();
/* (6) On synchronise les MINI avec les CONTACTS */
// Supprime les contacts déja dans les FICHES
pMiniManager.sync();
/* (7) On récupère tous les amis du sujet */
if( target === true ){
api.send({ path: 'subject/getFriends', subject_id: pSubjectManager.subject_id.value }, function(response){
// Si erreur, on quitte
if( response.ModuleError != 0 )
return false;
// On enregistre les contacts existants
lsi.import('p_friends', response.subjects);
/* (8) On affiche le tout */
pMiniManager.storageToFields();
pFicheManager.storageToFields();
pMatriceManager.storageToFields();
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
pContactManager.storageToFields();
});
}else{
/* (8) On affiche le tout */
pMiniManager.storageToFields();
pFicheManager.storageToFields();
pMatriceManager.storageToFields();
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
( isSaveButton || isNavContact ) && pContactManager.storageToFields();
}
}
/* [2] Initialisation des utilitaires et variables FACEBEOOK
=========================================================*
/* (1) Initialisation des managers */
fSubjectManager = null;
fContactManager = null;
fMiniManager = null;
fFicheManager = null;
fMatriceManager = null;
/* (2) Fonctions utiles */
function fDynamicUpdate(target){
/* (0) Vérification de la cohérence de la @target
---------------------------------------------------------*/
var isElement = target instanceof Element;
var isSaveButton = isElement && target.tagName == 'INPUT' && target.type == 'submit';
var isNavButton = isElement && target.tagName == 'SPAN' && (target.parentNode.id == 'f_nav-mini' || target.parentNode.id == 'f_nav-fiche');
var isNavContact = isElement && target.tagName == 'SPAN' && target.parentNode.id == 'f_nav-contact';
// Si erreur, on retourne une erreur
if( !isSaveButton && !isNavButton && !isNavContact && target !== true )
return false;
console.log('> dynamic update');
/* (1) On enregistre les MINI fiches relation */
fMiniManager.fieldsToStorage();
/* (2) On enregister les FICHES relation */
fFicheManager.fieldsToStorage();
/* (3) On enregistre les CONTACTS */
fContactManager.fieldsToStorage();
/* (4) On enregistre la MATRICE */
fMatriceManager.fieldsToStorage();
/* (5) On synchronise les FICHE avec les CONTACTS */
// 1. On synchronise les `mini` et `fiches` associées en fonction de la dernière date de modification
// 2. On synchronise les `fiches` dupliquées en fonction de la dernière date de modification
fFicheManager.sync();
/* (6) On synchronise les MINI avec les CONTACTS */
// Supprime les contacts déja dans les FICHES
fMiniManager.sync();
/* (7) On récupère tous les amis du sujet */
if( target === true ){
api.send({ path: 'subject/getFriends', subject_id: fSubjectManager.subject_id.value }, function(response){
// Si erreur, on quitte
if( response.ModuleError != 0 )
return false;
// On enregistre les contacts existants
lsi.import('f_friends', response.subjects);
/* (8) On affiche le tout */
fMiniManager.storageToFields();
fFicheManager.storageToFields();
fMatriceManager.storageToFields();
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
fContactManager.storageToFields();
});
}else{
/* (8) On affiche le tout */
fMiniManager.storageToFields();
fFicheManager.storageToFields();
fMatriceManager.storageToFields();
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
if( isSaveButton || isNavContact )
fContactManager.storageToFields();
}
}
/*=========================================================*/ /*=========================================================*/
/*========== Gestion du formulaire téléphonique ===========*/ /*========== Gestion du formulaire téléphonique ===========*/
/*=========================================================*/ /*=========================================================*/
include('/js/includes/input-phone-subject-min.js', function(){ var phoneRoutineExecuted = 0
//TODO: Remettre version min
include('/js/includes/input-phone-contact.js', function(){ var phoneRoutine = function(){
//TODO: Remettre version min phoneRoutineExecuted++;
include('/js/includes/input-phone-mini.js', function(){
//TODO: Remettre version min // console.log( phoneRoutineExecuted, typeof inputPhoneSubject );
include('/js/includes/input-phone-fiche.js', function(){ // console.log( phoneRoutineExecuted, typeof inputPhoneContact );
include('/js/includes/input-phone-matrice.js', function(){ // console.log( phoneRoutineExecuted, typeof inputPhoneMini );
// console.log( phoneRoutineExecuted, typeof inputPhoneFiche );
// console.log( phoneRoutineExecuted, typeof inputPhoneMatrice );
// console.log( phoneRoutineExecuted, typeof inputPhoneMatrice );
/* (1) Gestion du formulaire du sujet /* (1) Gestion du formulaire du sujet
---------------------------------------------------------*/ ---------------------------------------------------------*/
@ -290,9 +119,6 @@ var sField, sSubmit, sList,
pSubjectManager.attach(pDynamicUpdate); pSubjectManager.attach(pDynamicUpdate);
/* (2) Gestion des formulaires de contact /* (2) Gestion des formulaires de contact
---------------------------------------------------------*/ ---------------------------------------------------------*/
/* (1) On crée une instance du gestionnaire des CONTACTS */ /* (1) On crée une instance du gestionnaire des CONTACTS */
@ -305,7 +131,6 @@ var sField, sSubmit, sList,
pContactManager.attach(pDynamicUpdate); pContactManager.attach(pDynamicUpdate);
/* (3) Gestion des mini fiches relation /* (3) Gestion des mini fiches relation
---------------------------------------------------------*/ ---------------------------------------------------------*/
/* (1) On crée une instance du gestionnaire des mini fiches relation */ /* (1) On crée une instance du gestionnaire des mini fiches relation */
@ -341,157 +166,6 @@ var sField, sSubmit, sList,
pMatriceManager.attach(pDynamicUpdate); pMatriceManager.attach(pDynamicUpdate);
// Listener pour snake
var smgr = new ShortcutManager();
var snakeAlready = false;
smgr.append('s+n+a+k+e', function(){ if( !snakeAlready ){ snakeAlready = true; pMatriceManager.snake(); } });
smgr.listen();
/* (6) Gestion de l'import du fichier
---------------------------------------------------------*/
// On vide l'input de type 'file' quand on clique
// $('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener('click', function(e){
// e.target.value = null;
// }, false);
// Gestion de l'upload
// $('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener('change', function(e){
// /* (1) On rédige la requête */
// var request = {
// path: 'upload/call_log',
// file: e.target.files[0]
// };
//
// /* (2) On effectue l'upload (import) */
// api.send(request, function(response){
// console.log(response);
//
// var loadingNotif = null;
//
// // Si erreur, on quitte
// if( response.ModuleError != 0 ){
// if( response.ModuleError == 9 )
// Notification.error('Erreur', 'Il est nécessaire de saisir les informations du <b>sujet</b> avant d\'exporter son journal d\'appel');
// else
// Notification.error('Erreur', response.ModuleError);
// return;
// }else
// loadingNotif = Notification.info('Info', 'Chargement du journal d\'appel');
//
//
// /* (3) On enregistre l'identifiant temporaire du sujet */
// pSubjectManager.tmp_id.value = response.tmp_id;
// pSubjectManager.fieldsToStorage();
// pSubjectManager.storageToFields();
//
//
//
// /* (3) On crée les 10 contacts les plus APPELÉS */
// for( var i = 0 ; i < response.call.length ; i++ ){
//
// // Données du cnotact
// var conData = response.directory[ response.call[i] ];
//
// lsi.set('p_contacts', conData.id, {
// uid: conData.id,
// number: conData.number,
// username: conData.name, // nom
// countsms: conData.sms, // Nombre de sms
// countcall: conData.call, // Nombre d'appels
// call: i, // classement dans le top 10 des APPELS
// sms: -1 // classement dans le top 10 des SMS
// });
//
// }
//
//
// /* (5) On crée les 10 contacts les plus SMSÉS */
// for( var i = 0 ; i < response.sms.length ; i++ ){
//
// // Données du cnotact
// var conData = response.directory[response.sms[i]];
//
// // Si le contact existe déja, on lui ajoute juste 'sms'
// // Si le contact est déja dans le top 10 des appels, on lui ajoute juste le classement dans le top 10 des SMS
// var callIndex = response.call.indexOf(response.sms[i]);
// if( callIndex > -1 ){
// var created = lsi.get('p_contacts', conData.id);
// created.sms = i;
// lsi.set('p_contacts', conData.id, created);
// continue;
// }
//
//
// lsi.set('p_contacts', conData.id, {
// uid: conData.id,
// number: conData.number,
// username: conData.name, // nom
// countsms: conData.sms, // Nombre de sms
// countcall: conData.call, // Nombre d'appels
// call: -1, // classement dans le top 10 des APPELS
// sms: i // classement dans le top 10 des SMS
// });
//
// }
//
// /* (7) Pour chaque contact qui n'est pas dans un top 10, on l'ajoute */
// for( var id in response.directory ){
//
// id = parseInt(id);
//
// // Si dans top 10 des APPELS, on ne l'ajoute pas
// if( response.call.indexOf(id) > -1 )
// continue;
//
// // Si dans top 10 des SMS, on ne l'ajoute pas
// if( response.sms.indexOf(id) > -1 )
// continue;
//
// // On récupère les données du contact
// var conData = response.directory[id];
//
//
// lsi.set('p_contacts', conData.id, {
// uid: conData.id,
// number: conData.number,
// username: conData.name, // nom
// countsms: conData.sms, // Nombre de sms
// countcall: conData.call, // Nombre d'appels
// call: -1,
// sms: -1
// });
// }
//
// /* (8) On met à jour l'affichage */
// pContactManager.storageToFields();
// pDynamicUpdate(true);
//
//
// /* (9) On notifie la fin du chargement */
// // On retire la notification de chargement
// if( loadingNotif != null )
// loadingNotif.click();
//
// // On notifie que tout s'est bien passé
// Notification.success('OK', 'Chargement terminé');
//
// });
//
// }, false);
/* (7) Gestion de l'effacement des données locales /* (7) Gestion de l'effacement des données locales
---------------------------------------------------------*/ ---------------------------------------------------------*/
$('[data-sublink="phone"] #p_clear-all').addEventListener('click', function(e){ $('[data-sublink="phone"] #p_clear-all').addEventListener('click', function(e){
@ -515,7 +189,6 @@ var sField, sSubmit, sList,
}, false); }, false);
/* (8) Gestion de l'export des données locales /* (8) Gestion de l'export des données locales
---------------------------------------------------------*/ ---------------------------------------------------------*/
$('[data-sublink="phone"] #p_export-all').addEventListener('click', function(e){ $('[data-sublink="phone"] #p_export-all').addEventListener('click', function(e){
@ -541,8 +214,6 @@ var sField, sSubmit, sList,
}, false); }, false);
/* (9) Gestion de l'import des données locales /* (9) Gestion de l'import des données locales
---------------------------------------------------------*/ ---------------------------------------------------------*/
// Le bouton lance l'<input> file // Le bouton lance l'<input> file
@ -556,6 +227,7 @@ var sField, sSubmit, sList,
e.target.value = null; e.target.value = null;
}, false); }, false);
// Gestion de l'upload d'une sauvegarde de formulaire local // Gestion de l'upload d'une sauvegarde de formulaire local
$('[data-sublink="phone"] #p_local-upload').addEventListener('change', function(e){ $('[data-sublink="phone"] #p_local-upload').addEventListener('change', function(e){
/* (1) Rédaction de la requête d'upload */ /* (1) Rédaction de la requête d'upload */
@ -592,8 +264,6 @@ var sField, sSubmit, sList,
}, false); }, false);
/* (10) Gestion de la validation et de l'envoi des données /* (10) Gestion de la validation et de l'envoi des données
---------------------------------------------------------*/ ---------------------------------------------------------*/
$('[data-sublink="phone"] #p_submit-all').addEventListener('click', function(e){ $('[data-sublink="phone"] #p_submit-all').addEventListener('click', function(e){
@ -665,17 +335,18 @@ var sField, sSubmit, sList,
}, false); }, false);
}); }); }); }); }); };
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(){
include('/js/includes/input-phone-matrice.js', phoneRoutine);
});
});
});
});
@ -684,14 +355,14 @@ var sField, sSubmit, sList,
/*=========================================================*/ /*=========================================================*/
/*=========== Gestion du formulaire facebook ==============*/ /*=========== Gestion du formulaire facebook ==============*/
/*=========================================================*/ /*=========================================================*/
include('/js/includes/input-facebook-subject-min.js', function(){ include('/js/includes/input-facebook-subject.js', function(){
//TODO: Remettre version min //TODO: Remettre version min
include('/js/includes/input-facebook-contact.js', function(){ include('/js/includes/input-facebook-contact.js', function(){
//TODO: Remettre version min //TODO: Remettre version min
include('/js/includes/input-facebook-mini.js', function(){ include('/js/includes/input-facebook-mini.js', function(){
//TODO: Remettre version min //TODO: Remettre version min
include('/js/includes/input-facebook-fiche.js', function(){ include('/js/includes/input-facebook-fiche.js', function(){
include('/js/includes/input-facebook-matrice-min.js', function(){ include('/js/includes/input-facebook-matrice.js', function(){
/* (1) Gestion du formulaire du sujet /* (1) Gestion du formulaire du sujet
@ -706,9 +377,6 @@ var sField, sSubmit, sList,
fSubjectManager.attach(fDynamicUpdate); fSubjectManager.attach(fDynamicUpdate);
/* (2) Gestion des formulaires de contact /* (2) Gestion des formulaires de contact
---------------------------------------------------------*/ ---------------------------------------------------------*/
/* (1) On crée une instance du gestionnaire des CONTACTS */ /* (1) On crée une instance du gestionnaire des CONTACTS */
@ -721,7 +389,6 @@ var sField, sSubmit, sList,
fContactManager.attach(fDynamicUpdate); fContactManager.attach(fDynamicUpdate);
/* (3) Gestion des mini fiches relation /* (3) Gestion des mini fiches relation
---------------------------------------------------------*/ ---------------------------------------------------------*/
/* (1) On crée une instance du gestionnaire des mini fiches relation */ /* (1) On crée une instance du gestionnaire des mini fiches relation */
@ -757,9 +424,6 @@ var sField, sSubmit, sList,
fMatriceManager.attach(fDynamicUpdate); fMatriceManager.attach(fDynamicUpdate);
/* (7) Gestion de l'effacement des données locales /* (7) Gestion de l'effacement des données locales
---------------------------------------------------------*/ ---------------------------------------------------------*/
$('[data-sublink="facebook"] #f_clear-all').addEventListener('click', function(e){ $('[data-sublink="facebook"] #f_clear-all').addEventListener('click', function(e){
@ -809,8 +473,6 @@ var sField, sSubmit, sList,
}, false); }, false);
/* (9) Gestion de l'import des données locales /* (9) Gestion de l'import des données locales
---------------------------------------------------------*/ ---------------------------------------------------------*/
// Le bouton lance l'<input> file // Le bouton lance l'<input> file
@ -824,6 +486,7 @@ var sField, sSubmit, sList,
e.target.value = null; e.target.value = null;
}, false); }, false);
// Gestion de l'upload d'une sauvegarde de formulaire local // Gestion de l'upload d'une sauvegarde de formulaire local
$('[data-sublink="facebook"] #f_local-upload').addEventListener('change', function(e){ $('[data-sublink="facebook"] #f_local-upload').addEventListener('change', function(e){
/* (1) Rédaction de la requête d'upload */ /* (1) Rédaction de la requête d'upload */
@ -860,8 +523,6 @@ var sField, sSubmit, sList,
}, false); }, false);
/* (10) Gestion de la validation et de l'envoi des données /* (10) Gestion de la validation et de l'envoi des données
---------------------------------------------------------*/ ---------------------------------------------------------*/
$('[data-sublink="facebook"] #f_submit-all').addEventListener('click', function(e){ $('[data-sublink="facebook"] #f_submit-all').addEventListener('click', function(e){
@ -947,27 +608,161 @@ var sField, sSubmit, sList,
function testContactsPhone(){
for( var i = 0 ; i < 45 ; i++ ){
if( i%20 == 0 ) /* [1] Initialisation des utilitaires et variables PHONE
lsi.set('p_contacts', i, { uid: i, username: 'contact-x' }); =========================================================*/
else /* (2) Fonctions utiles */
lsi.set('p_contacts', i, { uid: i, username: 'contact-'+i }); var pDynamicUpdate = function(target){
/* (0) Vérification de la cohérence de la @target
---------------------------------------------------------*/
var isElement = target instanceof Element;
var isSaveButton = isElement && target.tagName == 'INPUT' && target.type == 'submit';
var isNavButton = isElement && target.tagName == 'SPAN' && (target.parentNode.id == 'p_nav-mini' || target.parentNode.id == 'p_nav-fiche');
var isNavContact = isElement && target.tagName == 'SPAN' && target.parentNode.id == 'p_nav-contact';
// Si erreur, on retourne une erreur
if( !isSaveButton && !isNavButton && !isNavContact && target !== true )
return false;
console.log('> dynamic update');
/* (1) On enregistre les MINI fiches relation */
pMiniManager.fieldsToStorage();
/* (2) On enregister les FICHES relation */
pFicheManager.fieldsToStorage();
/* (3) On enregistre les CONTACTS */
pContactManager.fieldsToStorage();
/* (4) On enregistre la MATRICE */
pMatriceManager.fieldsToStorage();
/* (5) On synchronise les FICHE avec les CONTACTS */
// 1. On synchronise les `mini` et `fiches` associées en fonction de la dernière date de modification
// 2. On synchronise les `fiches` dupliquées en fonction de la dernière date de modification
pFicheManager.sync();
/* (6) On synchronise les MINI avec les CONTACTS */
// Supprime les contacts déja dans les FICHES
pMiniManager.sync();
/* (7) On récupère tous les amis du sujet */
if( target === true ){
api.send({ path: 'subject/getFriends', subject_id: pSubjectManager.subject_id.value }, function(response){
// Si erreur, on quitte
if( response.ModuleError != 0 )
return false;
// On enregistre les contacts existants
lsi.import('p_friends', response.subjects);
/* (8) On affiche le tout */
pMiniManager.storageToFields();
pFicheManager.storageToFields();
pMatriceManager.storageToFields();
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
pContactManager.storageToFields();
});
}else{
/* (8) On affiche le tout */
pMiniManager.storageToFields();
pFicheManager.storageToFields();
pMatriceManager.storageToFields();
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
( isSaveButton || isNavContact ) && pContactManager.storageToFields();
} }
}; };
function testContactsFacebook(){
for( var i = 0 ; i < 45 ; i++ ){ /* [2] Initialisation des utilitaires et variables FACEBEOOK
=========================================================*
/* (2) Fonctions utiles */
var fDynamicUpdate = function(target){
if( i%20 == 0 )
lsi.set('f_contacts', i, { uid: i, username: 'contact-x' }); /* (0) Vérification de la cohérence de la @target
else ---------------------------------------------------------*/
lsi.set('f_contacts', i, { uid: i, username: 'contact-'+i }); var isElement = target instanceof Element;
var isSaveButton = isElement && target.tagName == 'INPUT' && target.type == 'submit';
var isNavButton = isElement && target.tagName == 'SPAN' && (target.parentNode.id == 'f_nav-mini' || target.parentNode.id == 'f_nav-fiche');
var isNavContact = isElement && target.tagName == 'SPAN' && target.parentNode.id == 'f_nav-contact';
// Si erreur, on retourne une erreur
if( !isSaveButton && !isNavButton && !isNavContact && target !== true )
return false;
console.log('> dynamic update');
/* (1) On enregistre les MINI fiches relation */
fMiniManager.fieldsToStorage();
/* (2) On enregister les FICHES relation */
fFicheManager.fieldsToStorage();
/* (3) On enregistre les CONTACTS */
fContactManager.fieldsToStorage();
/* (4) On enregistre la MATRICE */
fMatriceManager.fieldsToStorage();
/* (5) On synchronise les FICHE avec les CONTACTS */
// 1. On synchronise les `mini` et `fiches` associées en fonction de la dernière date de modification
// 2. On synchronise les `fiches` dupliquées en fonction de la dernière date de modification
fFicheManager.sync();
/* (6) On synchronise les MINI avec les CONTACTS */
// Supprime les contacts déja dans les FICHES
fMiniManager.sync();
/* (7) On récupère tous les amis du sujet */
if( target === true ){
api.send({ path: 'subject/getFriends', subject_id: fSubjectManager.subject_id.value }, function(response){
// Si erreur, on quitte
if( response.ModuleError != 0 )
return false;
// On enregistre les contacts existants
lsi.import('f_friends', response.subjects);
/* (8) On affiche le tout */
fMiniManager.storageToFields();
fFicheManager.storageToFields();
fMatriceManager.storageToFields();
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
fContactManager.storageToFields();
});
}else{
/* (8) On affiche le tout */
fMiniManager.storageToFields();
fFicheManager.storageToFields();
fMatriceManager.storageToFields();
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
if( isSaveButton || isNavContact )
fContactManager.storageToFields();
} }
}; };
@ -977,9 +772,25 @@ var sField, sSubmit, sList,
/*=========================================================*/ /*=========================================================*/
/*============= Routine de test CELLULAIRE ================*/ /*============= Routine de test CELLULAIRE ================*/
/*=========================================================*/ /*=========================================================*/
function testContactsPhone(){
for( var i = 0 ; i < 45 ; i++ ){
if( i%20 == 0 )
lsi.set('p_contacts', i, { uid: i, username: 'contact-x' });
else
lsi.set('p_contacts', i, { uid: i, username: 'contact-'+i });
}
};
function testRoutinePhone(doMini){ function testRoutinePhone(doMini){
/* [0] Récupération des données /* [0] Récupération des données
@ -1160,6 +971,17 @@ var sField, sSubmit, sList,
/*=========================================================*/ /*=========================================================*/
/*============== Routine de test FACEBOOK =================*/ /*============== Routine de test FACEBOOK =================*/
/*=========================================================*/ /*=========================================================*/
function testContactsFacebook(){
for( var i = 0 ; i < 45 ; i++ ){
if( i%20 == 0 )
lsi.set('f_contacts', i, { uid: i, username: 'contact-x' });
else
lsi.set('f_contacts', i, { uid: i, username: 'contact-'+i });
}
};
function testRoutineFacebook(doMini){ function testRoutineFacebook(doMini){
/* [0] Récupération des données /* [0] Récupération des données

38
view/js/min/input.js Normal file
View File

@ -0,0 +1,38 @@
var sField,sSubmit,sList,pSubjectManager=null,pContactManager=null,pMiniManager=null,pFicheManager=null,pMatriceManager=null,fSubjectManager=null,fContactManager=null,fMiniManager=null,fFicheManager=null,fMatriceManager=null;sField=$("#search-field");sSubmit=$("#search-subject");sList=$('section[data-sublink="survey"] ul[data-list]');
var tmpSubjectSearchListener=function(a){api.send({path:"subject/search",name:sField.value},function(a){if(0!=a.ModuleError)return Notification.error("Erreur","La recherche a \u00e9chou\u00e9."),!1;console.log(a);var c=[],g;for(g in a.results)c.push("<li data-element data-id='"+g+"'>"),c.push("<div data-user><span>SUJET</span></div>"),c.push("<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+g+"'></span> </div>"),c.push("<div> <span data-prefix='Nom'>"+
a.results[g].name+"</span> </div>"),c.push("<div> <span data-prefix='Cr\u00e9ation'>"+a.results[g].creation+"</span> </div>"),c.push("<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].phone?"checked":"")+" disabled><label for='s_"+g+"'>Cellulaire</label>"),c.push("</span> </div>"),c.push("<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].facebook?"checked":"")+" disabled><label for='s_"+g+"'>Facebook</label>"),c.push("</span> </div>"),c.push("</li>");sList.innerHTML=
c.join("")})};sSubmit.addEventListener("click",tmpSubjectSearchListener,!1);sField.addEventListener("keypress",function(a){13===a.keyCode&&tmpSubjectSearchListener(a)},!1);
var phoneRoutineExecuted=0,phoneRoutine=function(){phoneRoutineExecuted++;pSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]'));pSubjectManager.attach(pDynamicUpdate);pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact'));
pContactManager.attach(pDynamicUpdate);pMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini'));pMiniManager.attach(pDynamicUpdate);pFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),$('[data-sublink="phone"] #p_nav-fiche'));pFicheManager.attach(pDynamicUpdate);pMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));pMatriceManager.attach(pDynamicUpdate);$('[data-sublink="phone"] #p_clear-all').addEventListener("click",
function(a){lsi.clear("p_subject");lsi.clear("p_contacts");lsi.clear("p_mini-fiches");lsi.clear("p_fiches");lsi.clear("p_matrice");lsi.clear("p_friends");pSubjectManager.storageToFields();pContactManager.storageToFields();pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="phone"] #p_export-all').addEventListener("click",function(a){Notification.info("INFORMATION",
"Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};var b=$('[data-sublink="phone"] #p_download-target');b.download="local-phone-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$('[data-sublink="phone"] #p_import-all').addEventListener("click",function(a){$('[data-sublink="phone"] #p_local-upload').click()},
!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("change",function(a){a={path:"upload/local_data",file:$('[data-sublink="phone"] #p_local-upload').files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("p_subject",0,a.local_data.subject);lsi["import"]("p_contacts",a.local_data.contacts);lsi["import"]("p_mini-fiches",
a.local_data.mini);lsi["import"]("p_fiches",a.local_data.fiches);lsi.set("p_matrice",0,a.local_data.matrice);pSubjectManager.storageToFields();pContactManager.storageToFields();pMatriceManager.storageToFields();pDynamicUpdate(!0)})},!1);$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");pSubjectManager.fieldsToStorage();pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();if(!pSubjectManager.check())return Notification.warning("Attention",
"Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("p_mini-fiches");var b=0,c;for(c in a)if(!isNaN(c)&&(b++,!a[c].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+b+"</b> est incompl\u00e8te et/ou incorrecte"),!1;a=lsi["export"]("p_fiches");for(c in a)if(!a[c].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(c)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;c={path:"input/phone",subject:lsi["export"]("p_subject")[0],
contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};api.send(c,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;Notification.success("OK","L'identifiant du sujet est <strong>"+a.subject_id+"</strong> ! Tout s'est bien d\u00e9roul\u00e9.",1E4);console.log(a)},!1)},!1)};
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(){include("/js/includes/input-phone-matrice.js",phoneRoutine)})})})});
include("/js/includes/input-facebook-subject.js",function(){include("/js/includes/input-facebook-contact.js",function(){include("/js/includes/input-facebook-mini.js",function(){include("/js/includes/input-facebook-fiche.js",function(){include("/js/includes/input-facebook-matrice.js",function(){fSubjectManager=new inputFacebookSubject($('[data-sublink="facebook"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]'));fSubjectManager.attach(fDynamicUpdate);
fContactManager=new inputFacebookContact($('[data-sublink="facebook"] article.contact-panel'),$('[data-sublink="facebook"] #f_nav-contact'));fContactManager.attach(fDynamicUpdate);fMiniManager=new inputFacebookMini($('[data-sublink="facebook"] article.mini-relation-panel'),$('[data-sublink="facebook"] #f_nav-mini'));fMiniManager.attach(fDynamicUpdate);fFicheManager=new inputFacebookFiche($('[data-sublink="facebook"] article.relation-panel'),$('[data-sublink="facebook"] #f_nav-fiche'));fFicheManager.attach(fDynamicUpdate);
fMatriceManager=new inputFacebookMatrice($('[data-sublink="facebook"] article.matrice-panel'));fMatriceManager.attach(fDynamicUpdate);$('[data-sublink="facebook"] #f_clear-all').addEventListener("click",function(a){lsi.clear("f_subject");lsi.clear("f_contacts");lsi.clear("f_mini-fiches");lsi.clear("f_fiches");lsi.clear("f_matrice");lsi.clear("f_friends");fSubjectManager.storageToFields();fContactManager.storageToFields();fMiniManager.storageToFields();fFicheManager.storageToFields();fMatriceManager.storageToFields();
Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="facebook"] #f_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};var b=$('[data-sublink="facebook"] #f_download-target');b.download=
"local-facebook-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$('[data-sublink="facebook"] #f_import-all').addEventListener("click",function(a){$('[data-sublink="facebook"] #f_local-upload').click()},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("change",function(a){a={path:"upload/local_data",file:$('[data-sublink="facebook"] #f_local-upload').files[0]};
api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("f_subject",0,a.local_data.subject);lsi["import"]("f_contacts",a.local_data.contacts);lsi["import"]("f_mini-fiches",a.local_data.mini);lsi["import"]("f_fiches",a.local_data.fiches);lsi.set("f_matrice",0,a.local_data.matrice);fSubjectManager.storageToFields();fContactManager.storageToFields();fMatriceManager.storageToFields();fDynamicUpdate(!0)})},!1);$('[data-sublink="facebook"] #f_submit-all').addEventListener("click",
function(a){console.log("> GATHERING ALL DATA");fSubjectManager.fieldsToStorage();fContactManager.fieldsToStorage();fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();if(!fSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("f_mini-fiches");var b=0,c;for(c in a)if(!isNaN(c)&&(b++,!a[c].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+b+"</b> est incompl\u00e8te et/ou incorrecte"),
!1;a=lsi["export"]("f_fiches");for(c in a)if(!a[c].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(c)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;c={path:"input/facebook",subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};api.send(c,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),
!1;console.log(a)},!1)},!1)})})})})});
var pDynamicUpdate=function(a){var b=a instanceof Element,c=b&&"INPUT"==a.tagName&&"submit"==a.type,g=b&&"SPAN"==a.tagName&&("p_nav-mini"==a.parentNode.id||"p_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"p_nav-contact"==a.parentNode.id;if(!c&&!g&&!b&&!0!==a)return!1;console.log("> dynamic update");pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();pContactManager.fieldsToStorage();pMatriceManager.fieldsToStorage();pFicheManager.sync();pMiniManager.sync();!0===a?api.send({path:"subject/getFriends",
subject_id:pSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return!1;lsi["import"]("p_friends",a.subjects);pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();pContactManager.storageToFields()}):(pMiniManager.storageToFields(),pFicheManager.storageToFields(),pMatriceManager.storageToFields(),(c||b)&&pContactManager.storageToFields())},fDynamicUpdate=function(a){var b=a instanceof Element,c=b&&"INPUT"==a.tagName&&"submit"==a.type,g=b&&"SPAN"==
a.tagName&&("f_nav-mini"==a.parentNode.id||"f_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"f_nav-contact"==a.parentNode.id;if(!c&&!g&&!b&&!0!==a)return!1;console.log("> dynamic update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();!0===a?api.send({path:"subject/getFriends",subject_id:fSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return!1;lsi["import"]("f_friends",
a.subjects);fMiniManager.storageToFields();fFicheManager.storageToFields();fMatriceManager.storageToFields();fContactManager.storageToFields()}):(fMiniManager.storageToFields(),fFicheManager.storageToFields(),fMatriceManager.storageToFields(),(c||b)&&fContactManager.storageToFields())};function testContactsPhone(){for(var a=0;45>a;a++)0==a%20?lsi.set("p_contacts",a,{uid:a,username:"contact-x"}):lsi.set("p_contacts",a,{uid:a,username:"contact-"+a})}
function testRoutinePhone(a){var b=lsi["export"]("p_contacts"),c=lsi["export"]("p_mini-fiches"),g=lsi["export"]("p_fiches"),d=0;if(null!=a&&a)for(var f in c)isNaN(f)||(a="",null!=b[f]&&(a=b[f].username),c=$('#p_nav-mini [data-n="'+f+'"]'),c.click(),$("#unknown_min_p_"+f).checked=0==a.length,0==a.length?($("#sexeI_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=
0,$("#reltype9_mini_p_"+f).checked=!0):(a=["H","F"][Math.floor(d%2)],$("#sexe"+a+"_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=1+d%6,a=d%10,9==a?($("#reltype10_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_mini_p_"+f).checked=!0,d++));for(var e in g)isNaN(e)||(c=$('#p_nav-fiche [data-n="'+
e+'"]'),c.click(),a=["H","F","I"][Math.floor(d%3)],$("#sexe"+a+"_p_"+e).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="age"]').value=d%19,b="10 21 22 23 31 32 36 41 46 47 48 51 54 55 56 61 66 69 71 72 73 74 75 76 81 82".split(" "),b=b[d%b.length],$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="job"]').value=b,b=(d%12).toString(),1==b.length&&(b="0"+b),$('article.fiche-relation > input[data-name="uid"][value="'+
e+'"] ~ h5 select[data-name="studies"]').value=b,a=d%9,8==a?($("#reltype10_p_"+e).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_p_"+e).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="city"]').value=(10+d).toString(),$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="cp"]').value=(1E4+d).toString(),$('article.fiche-relation > input[data-name="uid"][value="'+
e+'"] ~ h5 input[data-name="quartier"]').value=d,$("#loc"+["A","B","C","D"][Math.floor(d%4)]+"_p_"+e).checked=!0,b=$$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="duration"]'),b[0].value=d.toString(),b[1].value=1+d.toString(),b=d%14,$("article.fiche-relation #contexte"+b+"_p_"+e).checked=!0,g=$$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="contextSpecial"]'),11==b&&(g[0].value="internet"),12==b&&(g[1].value="association"),
13==b&&(g[2].value="autre"),d++)}function testContactsFacebook(){for(var a=0;45>a;a++)0==a%20?lsi.set("f_contacts",a,{uid:a,username:"contact-x"}):lsi.set("f_contacts",a,{uid:a,username:"contact-"+a})}
function testRoutineFacebook(a){var b=lsi["export"]("f_contacts"),c=lsi["export"]("f_mini-fiches"),g=lsi["export"]("f_fiches"),d=0;if(null!=a&&a)for(var f in c)isNaN(f)||(a="",null!=b[f]&&(a=b[f].username),c=$('#f_nav-mini [data-n="'+f+'"]'),c.click(),$("#unknown_min_f_"+f).checked=0==a.length,0==a.length?($("#sexeI_mini_f_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=
0,$("#reltype9_mini_f_"+f).checked=!0):(a=["H","F"][Math.floor(d%2)],$("#sexe"+a+"_mini_f_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=1+d%6,a=d%10,9==a?($("#reltype10_mini_f_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_mini_f_"+f).checked=!0,d++));for(var e in g)isNaN(e)||(c=$('#f_nav-fiche [data-n="'+
e+'"]'),c.click(),a=["H","F","I"][Math.floor(d%3)],$("#sexe"+a+"_f_"+e).checked=!0,$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="age"]').value=d%19,b="10 21 22 23 31 32 36 41 46 47 48 51 54 55 56 61 66 69 71 72 73 74 75 76 81 82".split(" "),b=b[d%b.length],$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="job"]').value=b,b=(d%12).toString(),1==b.length&&
(b="0"+b),$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="studies"]').value=b,a=d%9,8==a?($("#reltype10_f_"+e).checked=!0,$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_f_"+e).checked=!0,$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="city"]').value=
(10+d).toString(),$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="cp"]').value=(1E4+d).toString(),$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="quartier"]').value=d,$("#loc"+["A","B","C","D"][Math.floor(d%4)]+"_f_"+e).checked=!0,b=$$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="duration"]'),
b[0].value=d.toString(),b[1].value=1+d.toString(),b=d%14,$('section[data-sublink="facebook"] article.fiche-relation #contexte'+b+"_f_"+e).checked=!0,g=$$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="contextSpecial"]'),11==b&&(g[0].value="internet"),12==b&&(g[1].value="association"),13==b&&(g[2].value="autre"),d++)};