2016-09-30 09:03:18 +00:00
|
|
|
var sField, sSubmit, sList,
|
2016-10-02 16:01:35 +00:00
|
|
|
pSubjectManager = null,
|
|
|
|
pContactManager = null,
|
|
|
|
pMiniManager = null,
|
|
|
|
pFicheManager = null,
|
|
|
|
pMatriceManager = null,
|
|
|
|
|
|
|
|
fSubjectManager = null,
|
|
|
|
fContactManager = null,
|
|
|
|
fMiniManager = null,
|
|
|
|
fFicheManager = null,
|
|
|
|
fMatriceManager = null;
|
2016-05-26 14:33:00 +00:00
|
|
|
|
2016-10-20 11:16:31 +00:00
|
|
|
var input_ts = Date.now();
|
2016-05-26 14:33:00 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/*=========================================================*/
|
|
|
|
/*=========== Gestion de la recherche de sujet ============*/
|
|
|
|
/*=========================================================*/
|
|
|
|
/* (1) On récupère les éléments utiles
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
sField = $('#search-field');
|
|
|
|
sSubmit = $('#search-subject');
|
|
|
|
sList = $('section[data-sublink="survey"] ul[data-list]');
|
|
|
|
|
|
|
|
|
|
|
|
/* (2) Routine de recherche
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
var tmpSubjectSearchListener = function(e){
|
|
|
|
|
|
|
|
/* (1) On construit la requête */
|
|
|
|
var request = {
|
|
|
|
path: 'subject/search',
|
|
|
|
name: sField.value
|
|
|
|
};
|
2016-05-26 14:33:00 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On effectue la requête */
|
|
|
|
api.send(request, function(response){
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Si erreur
|
|
|
|
if( response.ModuleError != 0 ){
|
|
|
|
Notification.error('Erreur', 'La recherche a échoué.')
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-26 14:33:00 +00:00
|
|
|
|
|
|
|
|
2016-05-27 08:39:39 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
console.log(response);
|
2016-05-26 14:33:00 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (3) On remplit la liste des résultats */
|
|
|
|
var htmlContent = [];
|
|
|
|
for( var id in response.results ){
|
|
|
|
htmlContent.push("<li data-element data-id='"+id+"'>");
|
2016-05-26 14:33:00 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
htmlContent.push("<div data-user><span>SUJET</span></div>");
|
2016-05-26 14:33:00 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
htmlContent.push("<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+id+"'></span> </div>");
|
2016-05-26 14:33:00 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
htmlContent.push("<div> <span data-prefix='Nom'>"+response.results[id].name+"</span> </div>");
|
2016-05-26 14:33:00 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
htmlContent.push("<div> <span data-prefix='Création'>"+response.results[id].creation+"</span> </div>");
|
2016-05-26 14:33:00 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
htmlContent.push("<div> <span><input type='checkbox' id='s_"+id+"' "+((response.results[id].phone!=null)?'checked':'')+" disabled><label for='s_"+id+"'>Cellulaire</label>");
|
|
|
|
htmlContent.push("</span> </div>");
|
2016-05-26 14:33:00 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
htmlContent.push("<div> <span><input type='checkbox' id='s_"+id+"' "+((response.results[id].facebook!=null)?'checked':'')+" disabled><label for='s_"+id+"'>Facebook</label>");
|
|
|
|
htmlContent.push("</span> </div>");
|
2016-05-26 14:33:00 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
htmlContent.push( "</li>");
|
|
|
|
}
|
2016-05-26 14:33:00 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
sList.innerHTML = htmlContent.join('');
|
2016-05-26 14:33:00 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
});
|
2016-05-26 14:33:00 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
};
|
2016-05-26 14:33:00 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (3) Attachement des évènements
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
sSubmit.addEventListener('click', tmpSubjectSearchListener, false);
|
2016-05-26 14:33:00 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
sField.addEventListener('keypress', function(e){
|
|
|
|
if( e.keyCode === 13 )
|
|
|
|
tmpSubjectSearchListener(e);
|
|
|
|
}, false);
|
2016-05-26 14:33:00 +00:00
|
|
|
|
2016-10-09 15:44:06 +00:00
|
|
|
|
|
|
|
|
2016-04-22 17:35:05 +00:00
|
|
|
|
2016-04-28 16:58:18 +00:00
|
|
|
|
2016-05-18 15:00:00 +00:00
|
|
|
|
|
|
|
|
2016-10-10 10:24:03 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/*=========================================================*/
|
|
|
|
/*========== Gestion du formulaire téléphonique ===========*/
|
|
|
|
/*=========================================================*/
|
2016-10-12 16:43:51 +00:00
|
|
|
var pAlready = 0;
|
|
|
|
var pLoaded = [ 0, 0, 0, 0, 0 ];
|
2016-05-18 15:00:00 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
var phoneRoutine = function(){
|
2016-10-12 16:43:51 +00:00
|
|
|
if( !Math.min.apply(Math, pLoaded) | pAlready )
|
2016-10-10 10:24:03 +00:00
|
|
|
return;
|
|
|
|
|
2016-10-12 16:43:51 +00:00
|
|
|
pAlready = 1;
|
2016-05-18 15:00:00 +00:00
|
|
|
|
2016-10-11 12:05:59 +00:00
|
|
|
console.groupEnd();
|
2016-10-10 08:58:44 +00:00
|
|
|
console.group('[phone] Initialization');
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (1) Gestion du formulaire du sujet
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
/* (1) On crée une instance du manager du sujet */
|
|
|
|
pSubjectManager = new inputPhoneSubject(
|
|
|
|
$('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),
|
|
|
|
$('[data-sublink="phone"] article.subject-panel [data-name="submit"]')
|
|
|
|
);
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On le démarre */
|
|
|
|
pSubjectManager.attach(pDynamicUpdate);
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-02 11:36:14 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) Gestion des formulaires de contact
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
/* (1) On crée une instance du gestionnaire des CONTACTS */
|
|
|
|
pContactManager = new inputPhoneContact(
|
|
|
|
$('[data-sublink="phone"] article.contact-panel'),
|
|
|
|
$('[data-sublink="phone"] #p_nav-contact')
|
|
|
|
);
|
2016-05-18 12:46:13 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On le démarre */
|
|
|
|
pContactManager.attach(pDynamicUpdate);
|
2016-05-03 13:18:09 +00:00
|
|
|
|
2016-05-09 07:34:17 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (3) Gestion des mini fiches relation
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
/* (1) On crée une instance du gestionnaire des mini fiches relation */
|
|
|
|
pMiniManager = new inputPhoneMini(
|
|
|
|
$('[data-sublink="phone"] article.mini-relation-panel'),
|
|
|
|
$('[data-sublink="phone"] #p_nav-mini')
|
|
|
|
);
|
2016-05-03 09:47:05 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On le démarre */
|
|
|
|
pMiniManager.attach(pDynamicUpdate);
|
2016-05-03 14:29:12 +00:00
|
|
|
|
2016-05-12 19:47:52 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (4) Gestion des fiches relation
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
/* (1) On crée une instance du gestionnaire des fiches relation */
|
|
|
|
pFicheManager = new inputPhoneFiche(
|
|
|
|
$('[data-sublink="phone"] article.relation-panel'),
|
|
|
|
$('[data-sublink="phone"] #p_nav-fiche')
|
|
|
|
);
|
2016-05-03 14:29:12 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On le démarre */
|
2016-10-12 16:43:51 +00:00
|
|
|
pFicheManager.top_size = 20;
|
2016-10-10 08:58:44 +00:00
|
|
|
pFicheManager.attach(pDynamicUpdate);
|
2016-05-03 14:29:12 +00:00
|
|
|
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (5) Gestion de la matrice de relations
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
/* (1) On crée une instance du gestionnaire de la matrice */
|
|
|
|
pMatriceManager = new inputPhoneMatrice(
|
|
|
|
$('[data-sublink="phone"] article.matrice-panel')
|
|
|
|
);
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On le démarre */
|
|
|
|
pMatriceManager.attach(pDynamicUpdate);
|
2016-09-27 14:13:51 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (7) Gestion de l'effacement des données locales
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
$('[data-sublink="phone"] #p_clear-all').addEventListener('click', function(e){
|
|
|
|
/* (1) On vide tous les dataset de données */
|
|
|
|
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');
|
|
|
|
|
|
|
|
|
|
|
|
/* (2) On met à jour l'affichage */
|
|
|
|
pSubjectManager.storageToFields();
|
|
|
|
pContactManager.storageToFields();
|
|
|
|
pMiniManager.storageToFields();
|
|
|
|
pFicheManager.storageToFields();
|
|
|
|
pMatriceManager.storageToFields();
|
|
|
|
|
|
|
|
Notification.success('OK', 'Les données ont été supprimées');
|
|
|
|
}, false);
|
2016-09-27 14:13:51 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (8) Gestion de l'export des données locales
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
$('[data-sublink="phone"] #p_export-all').addEventListener('click', function(e){
|
2016-09-27 14:13:51 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
Notification.info('INFORMATION', 'Lancement du téléchargement de la sauvegarde');
|
2016-09-27 14:13:51 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (1) On construit les données */
|
|
|
|
var data = {
|
|
|
|
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]
|
|
|
|
};
|
2016-09-27 14:13:51 +00:00
|
|
|
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On lance le téléchargement */
|
|
|
|
var downloadTarget = $('[data-sublink="phone"] #p_download-target'); // On récupère le lien (<a>) caché qui fera le téléchargement
|
2016-10-11 10:44:53 +00:00
|
|
|
downloadTarget.download = 'local-facebook-data.json'; // Nom du fichier qui sera téléchargé
|
2016-10-10 08:58:44 +00:00
|
|
|
downloadTarget.href = 'data:application/octet-stream,' + encodeURIComponent(JSON.stringify(data)); // Contenu
|
|
|
|
downloadTarget.click(); // On lance le téléchargement
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
}, false);
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-05-03 14:29:12 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (9) Gestion de l'import des données locales
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
// Le bouton lance l'<input> file
|
|
|
|
$('[data-sublink="phone"] #p_import-all').addEventListener('click', function(e){
|
|
|
|
$('[data-sublink="phone"] #p_local-upload').click();
|
|
|
|
}, false);
|
2016-05-03 14:29:12 +00:00
|
|
|
|
2016-05-03 14:46:38 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// On vide l'input de type 'file' quand on clique
|
|
|
|
$('[data-sublink="phone"] #p_local-upload').addEventListener('click', function(e){
|
|
|
|
e.target.value = null;
|
|
|
|
}, false);
|
2016-05-12 15:01:31 +00:00
|
|
|
|
2016-05-03 14:29:12 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Gestion de l'upload d'une sauvegarde de formulaire local
|
|
|
|
$('[data-sublink="phone"] #p_local-upload').addEventListener('change', function(e){
|
|
|
|
/* (1) Rédaction de la requête d'upload */
|
|
|
|
var request = {
|
|
|
|
path: 'upload/local_data',
|
|
|
|
file: $('[data-sublink="phone"] #p_local-upload').files[0]
|
|
|
|
};
|
2016-05-03 14:29:12 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) Upload et réponse */
|
|
|
|
api.send(request, function(response){
|
|
|
|
console.log(response);
|
2016-05-03 14:29:12 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Si erreur, on quitte
|
|
|
|
if( response.ModuleError != 0 ){
|
|
|
|
Notification.error('Erreur', response.ModuleError);
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-03 14:29:12 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (3) On enregistre les données dans le 'localStorage' */
|
|
|
|
lsi.set('p_subject', 0, response.local_data.subject);
|
|
|
|
lsi.import('p_contacts', response.local_data.contacts);
|
|
|
|
lsi.import('p_mini-fiches', response.local_data.mini);
|
|
|
|
lsi.import('p_fiches', response.local_data.fiches);
|
|
|
|
lsi.set('p_matrice', 0, response.local_data.matrice);
|
2016-05-12 15:01:31 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (3) On met à jour l'affichage */
|
|
|
|
pSubjectManager.storageToFields();
|
|
|
|
pContactManager.storageToFields();
|
|
|
|
pMatriceManager.storageToFields();
|
|
|
|
pDynamicUpdate(true);
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
}, false);
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-09-27 14:13:51 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (10) Gestion de la validation et de l'envoi des données
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
$('[data-sublink="phone"] #p_submit-all').addEventListener('click', function(e){
|
|
|
|
console.log('> GATHERING ALL DATA');
|
2016-09-27 14:13:51 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (1) On met dans la mémoire tout les champs non enregistrés */
|
|
|
|
pSubjectManager.fieldsToStorage();
|
|
|
|
pContactManager.fieldsToStorage();
|
|
|
|
pMiniManager.fieldsToStorage();
|
|
|
|
pFicheManager.fieldsToStorage();
|
|
|
|
|
|
|
|
/* (2) Vérification de la validité de toutes les données */
|
|
|
|
// {1} Vérification du sujet //
|
|
|
|
if( !pSubjectManager.check() ){
|
|
|
|
Notification.warning('Attention', 'Vous devez saisir les informations du <i>sujet</i>');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// {2} Vérification des mini-fiches //
|
|
|
|
var mini = lsi.export('p_mini-fiches');
|
|
|
|
var i = 0;
|
|
|
|
for( var id in mini ){ if( !isNaN(id) ){
|
|
|
|
|
|
|
|
i++
|
|
|
|
|
|
|
|
if( !mini[id].valid ){
|
|
|
|
Notification.warning('Attention', 'La <i>fiche rapide</i> <b>'+i+'</b> est incomplète et/ou incorrecte');
|
2016-05-27 10:13:19 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-05-03 14:29:12 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
}}
|
|
|
|
// {3} Vérification des fiches //
|
|
|
|
var fiches = lsi.export('p_fiches');
|
|
|
|
for( var id in fiches )
|
|
|
|
if( !fiches[id].valid ){
|
|
|
|
Notification.warning('Attention', 'La <i>fiche complète</i> <b>'+(parseInt(id)+1)+'</b> est incomplète et/ou incorrecte');
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-03 14:46:38 +00:00
|
|
|
|
2016-05-03 14:29:12 +00:00
|
|
|
|
2016-05-12 15:01:31 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (3) On prépare la requête avec toutes les données */
|
|
|
|
var request = {
|
2016-10-11 10:44:53 +00:00
|
|
|
path: 'input/facebook',
|
2016-05-03 14:29:12 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
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]
|
|
|
|
};
|
2016-05-03 09:47:05 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (4) On envoie la requête et traite la réponse */
|
|
|
|
api.send(request, function(response){
|
|
|
|
console.log(response);
|
2016-05-03 14:29:12 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Si erreur, on la notifie
|
|
|
|
if( response.ModuleError != 0 ){
|
|
|
|
Notification.error('ERREUR', response.ModuleError);
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-03 14:46:38 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
Notification.success('OK', "L'identifiant du sujet est <strong>"+response.subject_id+"</strong> ! Tout s'est bien déroulé.", 10000);
|
2016-05-03 09:47:05 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
console.log(response);
|
2016-05-10 16:43:31 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
}, false);
|
2016-05-12 17:30:53 +00:00
|
|
|
|
2016-05-10 16:43:31 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
}, false);
|
2016-04-27 16:32:44 +00:00
|
|
|
|
|
|
|
|
2016-10-11 12:05:59 +00:00
|
|
|
console.groupEnd();
|
2016-04-27 16:32:44 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
};
|
2016-05-18 12:46:13 +00:00
|
|
|
|
2016-10-12 16:43:51 +00:00
|
|
|
include('/js/includes/input-phone-subject.js', function(){ pLoaded[0] = 1; phoneRoutine(); });
|
|
|
|
include('/js/includes/input-phone-contact.js', function(){ pLoaded[1] = 1; phoneRoutine(); });
|
|
|
|
include('/js/includes/input-phone-mini.js', function(){ pLoaded[2] = 1; phoneRoutine(); });
|
|
|
|
include('/js/includes/input-phone-fiche.js', function(){ pLoaded[3] = 1; phoneRoutine(); });
|
|
|
|
include('/js/includes/input-phone-matrice.js', function(){ pLoaded[4] = 1; phoneRoutine(); });
|
2016-05-18 12:46:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/*=========================================================*/
|
|
|
|
/*=========== Gestion du formulaire facebook ==============*/
|
|
|
|
/*=========================================================*/
|
2016-10-12 16:43:51 +00:00
|
|
|
var fAlready = 0;
|
|
|
|
var fLoaded = [ 0, 0, 0, 0, 0 ];
|
2016-10-11 10:44:53 +00:00
|
|
|
|
|
|
|
var facebookRoutine = function(){
|
2016-10-12 16:43:51 +00:00
|
|
|
if( !Math.min.apply(Math, fLoaded) | fAlready )
|
2016-10-11 10:44:53 +00:00
|
|
|
return;
|
2016-05-18 12:46:13 +00:00
|
|
|
|
2016-10-12 16:43:51 +00:00
|
|
|
fAlready = 1;
|
2016-10-11 10:44:53 +00:00
|
|
|
|
2016-10-11 12:05:59 +00:00
|
|
|
console.groupEnd();
|
2016-10-11 10:44:53 +00:00
|
|
|
console.group('[facebook] Initialization');
|
2016-05-18 12:46:13 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (1) Gestion du formulaire du sujet
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
/* (1) On crée une instance du manager du sujet */
|
|
|
|
fSubjectManager = new inputFacebookSubject(
|
|
|
|
$('[data-sublink="facebook"] article.subject-panel [data-name="subject_id"]'),
|
|
|
|
$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]')
|
|
|
|
);
|
2016-05-18 12:46:13 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On le démarre */
|
|
|
|
fSubjectManager.attach(fDynamicUpdate);
|
2016-05-18 12:46:13 +00:00
|
|
|
|
2016-05-02 19:21:09 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) Gestion des formulaires de contact
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
/* (1) On crée une instance du gestionnaire des CONTACTS */
|
|
|
|
fContactManager = new inputFacebookContact(
|
|
|
|
$('[data-sublink="facebook"] article.contact-panel'),
|
|
|
|
$('[data-sublink="facebook"] #f_nav-contact')
|
|
|
|
);
|
2016-05-03 10:08:24 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On le démarre */
|
|
|
|
fContactManager.attach(fDynamicUpdate);
|
2016-05-03 10:08:24 +00:00
|
|
|
|
2016-05-03 09:11:41 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (3) Gestion des mini fiches relation
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
/* (1) On crée une instance du gestionnaire des mini fiches relation */
|
|
|
|
fMiniManager = new inputFacebookMini(
|
|
|
|
$('[data-sublink="facebook"] article.mini-relation-panel'),
|
|
|
|
$('[data-sublink="facebook"] #f_nav-mini')
|
|
|
|
);
|
2016-05-09 07:34:17 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On le démarre */
|
|
|
|
fMiniManager.attach(fDynamicUpdate);
|
2016-05-03 09:11:41 +00:00
|
|
|
|
2016-05-09 07:34:17 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (4) Gestion des fiches relation
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
/* (1) On crée une instance du gestionnaire des fiches relation */
|
|
|
|
fFicheManager = new inputFacebookFiche(
|
|
|
|
$('[data-sublink="facebook"] article.relation-panel'),
|
|
|
|
$('[data-sublink="facebook"] #f_nav-fiche')
|
|
|
|
);
|
2016-05-03 10:08:24 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On le démarre */
|
2016-10-12 16:43:51 +00:00
|
|
|
fFicheManager.top_size = 20;
|
2016-10-10 08:58:44 +00:00
|
|
|
fFicheManager.attach(fDynamicUpdate);
|
2016-05-03 09:11:41 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (5) Gestion de la matrice de relations
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
/* (1) On crée une instance du gestionnaire de la matrice */
|
|
|
|
fMatriceManager = new inputFacebookMatrice(
|
|
|
|
$('[data-sublink="facebook"] article.matrice-panel')
|
|
|
|
);
|
2016-05-02 19:21:09 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On le démarre */
|
|
|
|
fMatriceManager.attach(fDynamicUpdate);
|
2016-05-02 19:21:09 +00:00
|
|
|
|
2016-04-30 09:33:01 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (7) Gestion de l'effacement des données locales
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
$('[data-sublink="facebook"] #f_clear-all').addEventListener('click', function(e){
|
|
|
|
/* (1) On vide tous les dataset de données */
|
|
|
|
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');
|
|
|
|
|
|
|
|
|
|
|
|
/* (2) On met à jour l'affichage */
|
|
|
|
fSubjectManager.storageToFields();
|
|
|
|
fContactManager.storageToFields();
|
|
|
|
fMiniManager.storageToFields();
|
|
|
|
fFicheManager.storageToFields();
|
|
|
|
fMatriceManager.storageToFields();
|
|
|
|
|
|
|
|
Notification.success('OK', 'Les données ont été supprimées');
|
|
|
|
}, false);
|
2016-05-13 09:14:41 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (8) Gestion de l'export des données locales
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
$('[data-sublink="facebook"] #f_export-all').addEventListener('click', function(e){
|
2016-05-10 14:51:09 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
Notification.info('INFORMATION', 'Lancement du téléchargement de la sauvegarde');
|
2016-05-10 14:51:09 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (1) On construit les données */
|
|
|
|
var data = {
|
|
|
|
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]
|
|
|
|
};
|
2016-05-10 14:51:09 +00:00
|
|
|
|
2016-04-30 10:19:51 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On lance le téléchargement */
|
|
|
|
var downloadTarget = $('[data-sublink="facebook"] #f_download-target'); // On récupère le lien (<a>) caché qui fera le téléchargement
|
2016-10-17 09:45:25 +00:00
|
|
|
downloadTarget.download = 'local-facebook-data.json'; // Nom du fichier qui sera téléchargé
|
2016-10-10 08:58:44 +00:00
|
|
|
downloadTarget.href = 'data:application/octet-stream,' + encodeURIComponent(JSON.stringify(data)); // Contenu
|
|
|
|
downloadTarget.click(); // On lance le téléchargement
|
2016-04-30 09:33:01 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
}, false);
|
2016-05-13 09:47:45 +00:00
|
|
|
|
2016-05-10 16:43:31 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (9) Gestion de l'import des données locales
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
// Le bouton lance l'<input> file
|
|
|
|
$('[data-sublink="facebook"] #f_import-all').addEventListener('click', function(e){
|
|
|
|
$('[data-sublink="facebook"] #f_local-upload').click();
|
|
|
|
}, false);
|
2016-05-27 14:32:26 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// On vide l'input de type 'file' quand on clique
|
|
|
|
$('[data-sublink="facebook"] #f_local-upload').addEventListener('click', function(e){
|
|
|
|
e.target.value = null;
|
|
|
|
}, false);
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-05-10 16:43:31 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Gestion de l'upload d'une sauvegarde de formulaire local
|
|
|
|
$('[data-sublink="facebook"] #f_local-upload').addEventListener('change', function(e){
|
|
|
|
/* (1) Rédaction de la requête d'upload */
|
|
|
|
var request = {
|
|
|
|
path: 'upload/local_data',
|
|
|
|
file: $('[data-sublink="facebook"] #f_local-upload').files[0]
|
|
|
|
};
|
2016-04-30 09:33:01 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) Upload et réponse */
|
|
|
|
api.send(request, function(response){
|
|
|
|
console.log(response);
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Si erreur, on quitte
|
|
|
|
if( response.ModuleError != 0 ){
|
|
|
|
Notification.error('Erreur', response.ModuleError);
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-27 14:13:51 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (3) On enregistre les données dans le 'localStorage' */
|
|
|
|
lsi.set('f_subject', 0, response.local_data.subject);
|
|
|
|
lsi.import('f_contacts', response.local_data.contacts);
|
|
|
|
lsi.import('f_mini-fiches', response.local_data.mini);
|
|
|
|
lsi.import('f_fiches', response.local_data.fiches);
|
|
|
|
lsi.set('f_matrice', 0, response.local_data.matrice);
|
2016-09-27 14:13:51 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (3) On met à jour l'affichage */
|
2016-10-11 10:44:53 +00:00
|
|
|
pSubjectManager.storageToFields();
|
|
|
|
pContactManager.storageToFields();
|
|
|
|
pMatriceManager.storageToFields();
|
|
|
|
pDynamicUpdate(true);
|
2016-04-30 09:33:01 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
});
|
2016-05-18 12:46:13 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
}, false);
|
2016-05-18 12:46:13 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (10) Gestion de la validation et de l'envoi des données
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
$('[data-sublink="facebook"] #f_submit-all').addEventListener('click', function(e){
|
|
|
|
console.log('> GATHERING ALL DATA');
|
2016-05-18 12:46:13 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (1) On met dans la mémoire tout les champs non enregistrés */
|
2016-10-11 10:44:53 +00:00
|
|
|
pSubjectManager.fieldsToStorage();
|
|
|
|
pContactManager.fieldsToStorage();
|
|
|
|
pMiniManager.fieldsToStorage();
|
|
|
|
pFicheManager.fieldsToStorage();
|
2016-05-18 12:46:13 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) Vérification de la validité de toutes les données */
|
|
|
|
// {1} Vérification du sujet //
|
2016-10-11 10:44:53 +00:00
|
|
|
if( !pSubjectManager.check() ){
|
2016-10-10 08:58:44 +00:00
|
|
|
Notification.warning('Attention', 'Vous devez saisir les informations du <i>sujet</i>');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// {2} Vérification des mini-fiches //
|
|
|
|
var mini = lsi.export('f_mini-fiches');
|
|
|
|
var i = 0;
|
|
|
|
for( var id in mini ){ if( !isNaN(id) ){
|
2016-05-18 12:46:13 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
i++
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
if( !mini[id].valid ){
|
|
|
|
Notification.warning('Attention', 'La <i>fiche rapide</i> <b>'+i+'</b> est incomplète et/ou incorrecte');
|
2016-05-18 15:00:00 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-10-10 08:58:44 +00:00
|
|
|
|
|
|
|
}}
|
|
|
|
// {3} Vérification des fiches //
|
|
|
|
var fiches = lsi.export('f_fiches');
|
|
|
|
for( var id in fiches )
|
|
|
|
if( !fiches[id].valid ){
|
|
|
|
Notification.warning('Attention', 'La <i>fiche complète</i> <b>'+(parseInt(id)+1)+'</b> est incomplète et/ou incorrecte');
|
2016-05-22 12:49:20 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-05-18 12:46:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (3) On prépare la requête avec toutes les données */
|
|
|
|
var request = {
|
2016-10-11 10:44:53 +00:00
|
|
|
path: 'input/phone',
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
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]
|
|
|
|
};
|
2016-05-18 12:46:13 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (4) On envoie la requête et traite la réponse */
|
|
|
|
api.send(request, function(response){
|
|
|
|
console.log(response);
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Si erreur, on la notifie
|
|
|
|
if( response.ModuleError != 0 ){
|
|
|
|
Notification.error('ERREUR', response.ModuleError);
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-11 10:44:53 +00:00
|
|
|
Notification.success('OK', "L'identifiant du sujet est <strong>"+response.subject_id+"</strong> ! Tout s'est bien déroulé.", 10000);
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
console.log(response);
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
}, false);
|
2016-05-26 17:43:50 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
}, false);
|
2016-05-26 17:43:50 +00:00
|
|
|
|
|
|
|
|
2016-10-11 12:05:59 +00:00
|
|
|
console.groupEnd();
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-11 10:44:53 +00:00
|
|
|
};
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-12 16:43:51 +00:00
|
|
|
include('/js/includes/input-facebook-subject.js', function(){ fLoaded[0] = 1; facebookRoutine(); });
|
|
|
|
include('/js/includes/input-facebook-contact.js', function(){ fLoaded[1] = 1; facebookRoutine(); });
|
|
|
|
include('/js/includes/input-facebook-mini.js', function(){ fLoaded[2] = 1; facebookRoutine(); });
|
|
|
|
include('/js/includes/input-facebook-fiche.js', function(){ fLoaded[3] = 1; facebookRoutine(); });
|
|
|
|
include('/js/includes/input-facebook-matrice.js', function(){ fLoaded[4] = 1; facebookRoutine(); });
|
2016-05-26 17:43:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-02 11:04:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-09 15:44:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* [1] Initialisation des utilitaires et variables PHONE
|
|
|
|
=========================================================*/
|
|
|
|
/* (2) Fonctions utiles */
|
|
|
|
var pDynamicUpdate = function(target){
|
2016-10-09 15:44:06 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (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';
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Si erreur, on retourne une erreur
|
|
|
|
if( !isSaveButton && !isNavButton && !isNavContact && target !== true )
|
|
|
|
return false;
|
2016-10-09 15:44:06 +00:00
|
|
|
|
|
|
|
|
2016-10-12 14:20:46 +00:00
|
|
|
console.groupEnd(); console.groupEnd();
|
2016-10-10 08:58:44 +00:00
|
|
|
console.group('[phone] Dynamic Update');
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (1) On enregistre les MINI fiches relation */
|
|
|
|
pMiniManager.fieldsToStorage();
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On enregister les FICHES relation */
|
|
|
|
pFicheManager.fieldsToStorage();
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (3) On enregistre les CONTACTS */
|
|
|
|
pContactManager.fieldsToStorage();
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (4) On enregistre la MATRICE */
|
|
|
|
pMatriceManager.fieldsToStorage();
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (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();
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (6) On synchronise les MINI avec les CONTACTS */
|
|
|
|
// Supprime les contacts déja dans les FICHES
|
|
|
|
pMiniManager.sync();
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (7) On récupère tous les amis du sujet */
|
|
|
|
if( target === true ){
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
api.send({ path: 'subject/getFriends', subject_id: pSubjectManager.subject_id.value }, function(response){
|
|
|
|
// Si erreur, on quitte
|
2016-10-12 14:20:46 +00:00
|
|
|
if( response.ModuleError != 0 ){
|
|
|
|
console.groupEnd();
|
2016-10-10 08:58:44 +00:00
|
|
|
return false;
|
2016-10-12 14:20:46 +00:00
|
|
|
}
|
2016-10-10 08:58:44 +00:00
|
|
|
|
|
|
|
// On enregistre les contacts existants
|
|
|
|
lsi.import('p_friends', response.subjects);
|
2016-10-09 15:44:06 +00:00
|
|
|
|
|
|
|
/* (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 */
|
2016-10-10 08:58:44 +00:00
|
|
|
pContactManager.storageToFields();
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-20 11:16:31 +00:00
|
|
|
/* (9) On met à jour les barres de navigation */
|
|
|
|
pMiniManager.updateNavBar();
|
|
|
|
pFicheManager.updateNavBar();
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
});
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-02 11:04:32 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
}else{
|
2016-10-02 11:04:32 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (8) On affiche le tout */
|
|
|
|
pMiniManager.storageToFields();
|
|
|
|
pFicheManager.storageToFields();
|
|
|
|
pMatriceManager.storageToFields();
|
2016-10-02 11:36:14 +00:00
|
|
|
|
2016-10-20 11:16:31 +00:00
|
|
|
/* (9) On met à jour les barres de navigation */
|
|
|
|
pMiniManager.updateNavBar();
|
|
|
|
pFicheManager.updateNavBar();
|
|
|
|
|
|
|
|
/* (10) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
|
2016-10-10 08:58:44 +00:00
|
|
|
( isSaveButton || isNavContact ) && pContactManager.storageToFields();
|
2016-10-02 11:36:14 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
}
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-11 12:05:59 +00:00
|
|
|
console.groupEnd();
|
2016-10-10 08:58:44 +00:00
|
|
|
};
|
2016-10-09 15:44:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* [2] Initialisation des utilitaires et variables FACEBEOOK
|
|
|
|
=========================================================*
|
|
|
|
/* (2) Fonctions utiles */
|
|
|
|
var fDynamicUpdate = function(target){
|
2016-10-09 15:44:06 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (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';
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Si erreur, on retourne une erreur
|
|
|
|
if( !isSaveButton && !isNavButton && !isNavContact && target !== true )
|
|
|
|
return false;
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-12 14:20:46 +00:00
|
|
|
console.groupEnd(); console.groupEnd();
|
2016-10-10 08:58:44 +00:00
|
|
|
console.group('[facebook] Dynamic Update');
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (1) On enregistre les MINI fiches relation */
|
|
|
|
fMiniManager.fieldsToStorage();
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On enregister les FICHES relation */
|
|
|
|
fFicheManager.fieldsToStorage();
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (3) On enregistre les CONTACTS */
|
|
|
|
fContactManager.fieldsToStorage();
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (4) On enregistre la MATRICE */
|
|
|
|
fMatriceManager.fieldsToStorage();
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (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();
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (6) On synchronise les MINI avec les CONTACTS */
|
|
|
|
// Supprime les contacts déja dans les FICHES
|
|
|
|
fMiniManager.sync();
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (7) On récupère tous les amis du sujet */
|
|
|
|
if( target === true ){
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
api.send({ path: 'subject/getFriends', subject_id: fSubjectManager.subject_id.value }, function(response){
|
|
|
|
// Si erreur, on quitte
|
2016-10-12 14:20:46 +00:00
|
|
|
if( response.ModuleError != 0 ){
|
|
|
|
console.groupEnd();
|
2016-10-10 08:58:44 +00:00
|
|
|
return false;
|
2016-10-12 14:20:46 +00:00
|
|
|
}
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// On enregistre les contacts existants
|
|
|
|
lsi.import('f_friends', response.subjects);
|
2016-10-09 15:44:06 +00:00
|
|
|
|
|
|
|
/* (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 */
|
2016-10-10 08:58:44 +00:00
|
|
|
fContactManager.storageToFields();
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
});
|
2016-10-02 11:36:14 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
}else{
|
2016-10-02 11:04:32 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (8) On affiche le tout */
|
|
|
|
fMiniManager.storageToFields();
|
|
|
|
fFicheManager.storageToFields();
|
|
|
|
fMatriceManager.storageToFields();
|
2016-10-02 11:04:32 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
|
|
|
|
if( isSaveButton || isNavContact )
|
|
|
|
fContactManager.storageToFields();
|
|
|
|
}
|
2016-10-02 11:04:32 +00:00
|
|
|
|
2016-10-11 12:05:59 +00:00
|
|
|
console.groupEnd();
|
2016-10-10 08:58:44 +00:00
|
|
|
|
|
|
|
};
|
2016-10-02 11:04:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-09 15:44:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-26 17:43:50 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/*=========================================================*/
|
|
|
|
/*============= Routine de test CELLULAIRE ================*/
|
|
|
|
/*=========================================================*/
|
|
|
|
function testContactsPhone(){
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
for( var i = 0 ; i < 45 ; i++ ){
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
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 });
|
|
|
|
}
|
|
|
|
};
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
function testRoutinePhone(doMini){
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* [0] Récupération des données
|
|
|
|
=========================================================*/
|
|
|
|
var contacts = lsi.export('p_contacts');
|
|
|
|
var mini = lsi.export('p_mini-fiches');
|
|
|
|
var fiches = lsi.export('p_fiches');
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
var count = 0;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* [1] Remplissage des mini-fiches
|
|
|
|
=========================================================*/
|
|
|
|
if( doMini != null && doMini ){
|
|
|
|
for( var m in mini ){
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (0) Si la fiche n'est pas affichée, on passe à la suivante */
|
|
|
|
if( isNaN(m) )
|
|
|
|
continue;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (1) On récupére le nom du contact associé */
|
|
|
|
var name = '';
|
|
|
|
if( contacts[m] != null )
|
|
|
|
name = contacts[m].username;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On remplit la mini fiche */
|
|
|
|
// {1} On se positionne sur la fiche en question //
|
|
|
|
var navBut = $('#p_nav-mini [data-n="'+m+'"]');
|
|
|
|
navBut.click();
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {2} Si la personne n'a pas de nom, on met que ce contact est inconnu, puis les valeurs par défaut //
|
|
|
|
$('#unknown_min_p_'+m).checked = name.length == 0;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (3) Si personne inconnue -> valeurs indéterminées */
|
|
|
|
if( name.length == 0 ){
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {1} Sexe indéterminé //
|
|
|
|
$('#sexeI_mini_p_'+m).checked = true;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {2} Age indéterminé //
|
|
|
|
$('input[data-name="uid"][value="'+m+'"] ~ h5 select[data-name="age"]').value = count % 19;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {3} Etudes indéterminées //
|
|
|
|
$('input[data-name="uid"][value="'+m+'"] ~ h5 select[data-name="studies"]').value = 0;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {4} Type de relation inconnue //
|
|
|
|
$('#reltype9_mini_p_'+m).checked = true;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
continue;
|
|
|
|
/* (4) Si la personne est connue on incrémente les valeurs */
|
|
|
|
}else{
|
|
|
|
|
|
|
|
// {1} On remplit le sexe //
|
|
|
|
var sexeVal = ['H', 'F'][ Math.floor(count % 2) ];
|
|
|
|
$('#sexe'+sexeVal+'_mini_p_'+m).checked = true;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {2} On remplit l'age //
|
|
|
|
$('input[data-name="uid"][value="'+m+'"] ~ h5 select[data-name="age"]').value = count % 19;
|
|
|
|
|
|
|
|
// {3} On remplit les études //
|
|
|
|
$('input[data-name="uid"][value="'+m+'"] ~ h5 select[data-name="studies"]').value = 1 + (count % 6);
|
|
|
|
|
|
|
|
// {4} Type de relation //
|
|
|
|
var relVal = count % 10;
|
|
|
|
// Si AUTRE
|
|
|
|
if( relVal == 9 ){
|
|
|
|
$('#reltype10_mini_p_'+m).checked = true;
|
|
|
|
$('input[data-name="uid"][value="'+m+'"] ~ h5 input[data-name="reltypeSpecial"]').value = 'autre';
|
|
|
|
// Sinon
|
|
|
|
}else
|
|
|
|
$('#reltype'+relVal+'_mini_p_'+m).checked = true;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
count++;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-26 17:43:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* [2] Remplissage des fiches complètes
|
|
|
|
=========================================================*/
|
|
|
|
for( var f in fiches ){
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (0) Si la fiche n'est pas affichée, on passe à la suivante */
|
|
|
|
if( isNaN(f) )
|
|
|
|
continue;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (1) On récupére le nom du contact associé */
|
|
|
|
var name = '';
|
|
|
|
if( contacts[fiches[f].contact] != null )
|
|
|
|
name = contacts[fiches[f].contact].username;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On remplit la fiche */
|
|
|
|
// {1} On se positionne sur la fiche en question //
|
|
|
|
var navBut = $('#p_nav-fiche [data-n="'+f+'"]');
|
|
|
|
navBut.click();
|
2016-05-26 17:43:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {1} On remplit le sexe //
|
|
|
|
var sexeVal = ['H', 'F', 'I'][ Math.floor(count % 3) ];
|
|
|
|
$('#sexe'+sexeVal+'_p_'+f).checked = true;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {2} On remplit l'age //
|
|
|
|
$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value = count % 19;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {3} On remplit la profession //
|
|
|
|
var jobVal = ['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'];
|
|
|
|
jobVal = jobVal[ count % jobVal.length ];
|
|
|
|
$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="job"]').value = jobVal;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {4} On remplit les études //
|
|
|
|
var stuVal = (count % 12).toString();
|
|
|
|
if( stuVal.length == 1 ) stuVal = '0'+stuVal;
|
|
|
|
$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value = stuVal;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {5} Type de relation //
|
|
|
|
var relVal = count % 9;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Si AUTRE
|
|
|
|
if( relVal == 8 ){
|
|
|
|
$('#reltype10_p_'+f).checked = true;
|
|
|
|
$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="reltypeSpecial"]').value = 'autre';
|
|
|
|
// Sinon
|
|
|
|
}else
|
|
|
|
$('#reltype'+relVal+'_p_'+f).checked = true;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {6} La ville, le CP et le quartier //
|
|
|
|
$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="city"]').value = (10 + count).toString();
|
|
|
|
$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="cp"]').value = (10000 + count).toString();
|
|
|
|
$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="quartier"]').value = count;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {7} Temps entre les domiciles //
|
|
|
|
var locVal = ['A', 'B', 'C', 'D'][ Math.floor(count % 4) ];
|
|
|
|
$('#loc'+locVal+'_p_'+f).checked = true;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {8} Temps de connaissance //
|
|
|
|
var duration = $$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="duration"]');
|
|
|
|
duration[0].value = count.toString();
|
|
|
|
duration[1].value = 1+count.toString();
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {9} Contexte de rencontre //
|
|
|
|
var ctxVal = count % 14;
|
|
|
|
$('article.fiche-relation #contexte'+ctxVal+'_p_'+f).checked = true;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
var ctxSpe = $$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="contextSpecial"]');
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Si special1
|
|
|
|
if( ctxVal == 11 )
|
|
|
|
ctxSpe[0].value = 'internet';
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Si special2
|
|
|
|
if( ctxVal == 12 )
|
|
|
|
ctxSpe[1].value = 'association';
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Si special3
|
|
|
|
if( ctxVal == 13 )
|
|
|
|
ctxSpe[2].value = 'autre';
|
2016-05-26 17:43:50 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
|
|
|
|
count++;
|
2016-05-26 17:43:50 +00:00
|
|
|
|
2016-09-27 14:13:51 +00:00
|
|
|
}
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
}
|
2016-05-27 14:32:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/*=========================================================*/
|
|
|
|
/*============== Routine de test FACEBOOK =================*/
|
|
|
|
/*=========================================================*/
|
|
|
|
function testContactsFacebook(){
|
2016-10-09 15:44:06 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
for( var i = 0 ; i < 45 ; i++ ){
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
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 });
|
|
|
|
}
|
|
|
|
};
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
function testRoutineFacebook(doMini){
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* [0] Récupération des données
|
|
|
|
=========================================================*/
|
|
|
|
var contacts = lsi.export('f_contacts');
|
|
|
|
var mini = lsi.export('f_mini-fiches');
|
|
|
|
var fiches = lsi.export('f_fiches');
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
var count = 0;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* [1] Remplissage des mini-fiches
|
|
|
|
=========================================================*/
|
|
|
|
if( doMini != null && doMini ){
|
|
|
|
for( var m in mini ){
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (0) Si la fiche n'est pas affichée, on passe à la suivante */
|
|
|
|
if( isNaN(m) )
|
|
|
|
continue;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (1) On récupére le nom du contact associé */
|
|
|
|
var name = '';
|
|
|
|
if( contacts[m] != null )
|
|
|
|
name = contacts[m].username;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On remplit la mini fiche */
|
|
|
|
// {1} On se positionne sur la fiche en question //
|
|
|
|
var navBut = $('#f_nav-mini [data-n="'+m+'"]');
|
|
|
|
navBut.click();
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {2} Si la personne n'a pas de nom, on met que ce contact est inconnu, puis les valeurs par défaut //
|
|
|
|
$('#unknown_min_f_'+m).checked = name.length == 0;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (3) Si personne inconnue -> valeurs indéterminées */
|
|
|
|
if( name.length == 0 ){
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {1} Sexe indéterminé //
|
|
|
|
$('#sexeI_mini_f_'+m).checked = true;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {2} Age indéterminé //
|
|
|
|
$('input[data-name="uid"][value="'+m+'"] ~ h5 select[data-name="age"]').value = count % 19;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {3} Etudes indéterminées //
|
|
|
|
$('input[data-name="uid"][value="'+m+'"] ~ h5 select[data-name="studies"]').value = 0;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {4} Type de relation inconnue //
|
|
|
|
$('#reltype9_mini_f_'+m).checked = true;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
continue;
|
|
|
|
/* (4) Si la personne est connue on incrémente les valeurs */
|
|
|
|
}else{
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {1} On remplit le sexe //
|
|
|
|
var sexeVal = ['H', 'F'][ Math.floor(count % 2) ];
|
|
|
|
$('#sexe'+sexeVal+'_mini_f_'+m).checked = true;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {2} On remplit l'age //
|
|
|
|
$('input[data-name="uid"][value="'+m+'"] ~ h5 select[data-name="age"]').value = count % 19;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {3} On remplit les études //
|
|
|
|
$('input[data-name="uid"][value="'+m+'"] ~ h5 select[data-name="studies"]').value = 1 + (count % 6);
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {4} Type de relation //
|
|
|
|
var relVal = count % 10;
|
|
|
|
// Si AUTRE
|
|
|
|
if( relVal == 9 ){
|
|
|
|
$('#reltype10_mini_f_'+m).checked = true;
|
|
|
|
$('input[data-name="uid"][value="'+m+'"] ~ h5 input[data-name="reltypeSpecial"]').value = 'autre';
|
|
|
|
// Sinon
|
|
|
|
}else
|
|
|
|
$('#reltype'+relVal+'_mini_f_'+m).checked = true;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-09-27 14:13:51 +00:00
|
|
|
}
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
count++;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-09-27 14:13:51 +00:00
|
|
|
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* [2] Remplissage des fiches complètes
|
|
|
|
=========================================================*/
|
|
|
|
for( var f in fiches ){
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (0) Si la fiche n'est pas affichée, on passe à la suivante */
|
|
|
|
if( isNaN(f) )
|
|
|
|
continue;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (1) On récupére le nom du contact associé */
|
|
|
|
var name = '';
|
|
|
|
if( contacts[fiches[f].contact] != null )
|
|
|
|
name = contacts[fiches[f].contact].username;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
/* (2) On remplit la fiche */
|
|
|
|
// {1} On se positionne sur la fiche en question //
|
|
|
|
var navBut = $('#f_nav-fiche [data-n="'+f+'"]');
|
|
|
|
navBut.click();
|
2016-05-27 14:32:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {1} On remplit le sexe //
|
|
|
|
var sexeVal = ['H', 'F', 'I'][ Math.floor(count % 3) ];
|
|
|
|
$('#sexe'+sexeVal+'_f_'+f).checked = true;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {2} On remplit l'age //
|
|
|
|
$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value = count % 19;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {3} On remplit la profession //
|
|
|
|
var jobVal = ['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'];
|
|
|
|
jobVal = jobVal[ count % jobVal.length ];
|
|
|
|
$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="job"]').value = jobVal;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {4} On remplit les études //
|
|
|
|
var stuVal = (count % 12).toString();
|
|
|
|
if( stuVal.length == 1 ) stuVal = '0'+stuVal;
|
|
|
|
$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value = stuVal;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {5} Type de relation //
|
|
|
|
var relVal = count % 9;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Si AUTRE
|
|
|
|
if( relVal == 8 ){
|
|
|
|
$('#reltype10_f_'+f).checked = true;
|
|
|
|
$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="reltypeSpecial"]').value = 'autre';
|
|
|
|
// Sinon
|
|
|
|
}else
|
|
|
|
$('#reltype'+relVal+'_f_'+f).checked = true;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {6} La ville, le CP et le quartier //
|
|
|
|
$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="city"]').value = (10 + count).toString();
|
|
|
|
$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="cp"]').value = (10000 + count).toString();
|
|
|
|
$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="quartier"]').value = count;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {7} Temps entre les domiciles //
|
|
|
|
var locVal = ['A', 'B', 'C', 'D'][ Math.floor(count % 4) ];
|
|
|
|
$('#loc'+locVal+'_f_'+f).checked = true;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {8} Temps de connaissance //
|
|
|
|
var duration = $$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="duration"]');
|
|
|
|
duration[0].value = count.toString();
|
|
|
|
duration[1].value = 1+count.toString();
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// {9} Contexte de rencontre //
|
|
|
|
var ctxVal = count % 14;
|
|
|
|
$('section[data-sublink="facebook"] article.fiche-relation #contexte'+ctxVal+'_f_'+f).checked = true;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
var ctxSpe = $$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="contextSpecial"]');
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Si special1
|
|
|
|
if( ctxVal == 11 )
|
|
|
|
ctxSpe[0].value = 'internet';
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Si special2
|
|
|
|
if( ctxVal == 12 )
|
|
|
|
ctxSpe[1].value = 'association';
|
2016-05-27 14:32:26 +00:00
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
// Si special3
|
|
|
|
if( ctxVal == 13 )
|
|
|
|
ctxSpe[2].value = 'autre';
|
2016-05-27 14:32:26 +00:00
|
|
|
|
|
|
|
|
2016-10-10 08:58:44 +00:00
|
|
|
|
|
|
|
count++;
|
2016-05-27 14:32:26 +00:00
|
|
|
|
|
|
|
}
|
2016-10-10 08:58:44 +00:00
|
|
|
|
|
|
|
}
|