diff --git a/js/includes/input-facebook-contact-min.js b/js/includes/input-facebook-contact-min.js new file mode 100644 index 0000000..f1cd7c4 --- /dev/null +++ b/js/includes/input-facebook-contact-min.js @@ -0,0 +1,8 @@ +function inputFacebookContact(a,b){this.container=a;this.nav_container=b}inputFacebookContact.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};inputFacebookContact.prototype.check=function(a){var b=0=a.length&&this.add({uid:a.length});this.updateNavBar()}; +inputFacebookContact.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"nav-contact"!=a.parentNode.id)return!1;for(var b=$$('[data-sublink="facebook"] #f_nav-contact > span.active'),c=0;c'+(1+b/10)+""}this.nav($('[data-sublink="facebook"] #f_nav-contact [data-n="'+this.selected+'"]'))}; +inputFacebookContact.prototype.attach=function(a){console.log("CONTACTS: ATTACH");lsi.createDataset("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)}; diff --git a/js/includes/input-facebook-contact.js b/js/includes/input-facebook-contact.js new file mode 100644 index 0000000..fa6ed2a --- /dev/null +++ b/js/includes/input-facebook-contact.js @@ -0,0 +1,244 @@ +/* [0] Constructeur -> définit le conteneur et le bouton d'ajout +=========================================================*/ +function inputFacebookContact(container, navContainer){ + this.container = container; + this.nav_container = navContainer; +} + +/* [1] Attributs +=========================================================*/ +inputFacebookContact.prototype = { + container: this.container, // Conteneur des formulaires de contact + nav_container: this.nav_container, // Conteneur de la navigation entre les formulaires + selected: 0, // UID du permier des contacts sélectionnés (10 par 10) + handler: null // Fonction pour l'enregistrement et la synchronisation des données +}; + + + +/* [2] Vérification des données d'un contact +=========================================================*/ +inputFacebookContact.prototype.check = function(deflated){ + /* (1) Le numéro n'est pas vide */ + var validForm = deflated.number.length > 0; + /* (2) ET le pseudo et/ou le prénom et/ou le nom n'est pas vide */ + validForm = validForm && deflated.username.length+deflated.firstname.length+deflated.lastname.length > 0; + + /* (3) On retourne la validité du formulaire */ + return validForm +} + + +/* [3] Gestion de l'enregistrement des formulaires de contact +=========================================================*/ +inputFacebookContact.prototype.fieldsToStorage = function(){ + console.log('CONTACTS: FIELDS TO STORAGE'); + + // {1} Pour chaque formulaire de contact présent // + var visibleContacts = $$('[data-sublink="facebook"] article.contact-panel .new-contact'); + for( var i = 0 ; i < visibleContacts.length ; i++ ){ + + // {2} On initialise notre deflater pour récupérer les valeurs // + var deflater = new FormDeflater(visibleContacts[i], ['input'], ['data-name']); + + // {3} On enregistre ce contact si le numéro n'est pas vide et soit pseudo/prénom/nom // + var deflated = deflater.deflate(); + + // Si le formulaire n'est pas valide, on ne l'enregistre pas + if( !this.check(deflated) ) continue; + + // {4} On récupère et met en forme les valeurs du deflater // + var obj = { + uid: parseInt(deflated.uid), + number: deflated.number, + username: deflated.username, + firstname: deflated.firstname, + lastname: deflated.lastname, + + call: parseInt(deflated.call), + sms: parseInt(deflated.sms), + + countcall: parseInt(deflated.countcall), + countsms: parseInt(deflated.countsms) + }; + + /* (5) On calcule et ajoute le hash des données */ + obj.hash = crc32( JSON.stringify(obj) ); + + // {6} On enregistre les données dans le 'localStorage' // + lsi.set('contacts', parseInt(deflated.uid), obj); + + } + +}; + + + + + + + + + +/* [4] Gestion de l'ajout physique d'un nouveau contact +=========================================================*/ +/* +* +* @objectData Objet contenant les informations nécessaires à l'affichage +* +*/ +inputFacebookContact.prototype.add = function(objectData){ + console.log('CONTACTS: ADD'); + + // Si pas d'uid, on quitte + if( objectData == null || objectData.uid == null || isNaN(objectData.uid) ) + return false + + // {0} On formatte l'object // + objectData.number = (objectData.number != null) ? objectData.number : ''; + objectData.username = (objectData.username != null) ? objectData.username : ''; + objectData.firstname = (objectData.firstname != null) ? objectData.firstname : ''; + objectData.lastname = (objectData.lastname != null) ? objectData.lastname : ''; + objectData.call = (objectData.call != null) ? objectData.call : -1; + objectData.sms = (objectData.sms != null) ? objectData.sms : -1; + objectData.countcall = (objectData.countcall != null) ? objectData.countcall : 0; + objectData.countsms = (objectData.countsms != null) ? objectData.countsms : 0; + + + // {1} On ajoute le HTML // + this.container.innerHTML += contactBuilder.build(objectData); + + // {2} On attache les évènements sur les formulaires // + var contactForms = $$('[data-sublink="facebook"] article.contact-panel .new-contact'); + + // On met à jour les listener (remove, puis add) + var ptr = this; + for( var i = 0 ; i < contactForms.length ; i++ ){ + contactForms[i].removeEventListener('click', function(e){ ptr.nav(e.target); ptr.handler(e.target); }, false); + contactForms[i].addEventListener('click', function(e){ ptr.nav(e.target); ptr.handler(e.target); }, false); + } + +}; + + + + + + + + + + +/* [5] Gestion de l'affichage depuis le 'localStorage' +=========================================================*/ +inputFacebookContact.prototype.storageToFields = function(){ + console.log('CONTACTS: STORAGE TO FIELDS'); + + // {1} Pour chaque contact du 'localStorage' // + var contactKeys = lsi.keys('contacts'); + + // On réinitialise le HTML + this.container.innerHTML = ''; + + // {2} On ajoute chaque contact (parmi les séléctionnés) à la liste // + var min = this.selected; // On affiche du contact sélectionné + var max = this.selected+10; // On s'arrête à 10 contacs + + for( var i = min ; i < max && i < contactKeys.length ; i++ ) + this.add( lsi.get('contacts', contactKeys[i]) ); + + + // On ajoute un champ de plus à remplir si c'est la dernière page + if( max >= contactKeys.length ) + this.add({uid: contactKeys.length}); + + /* (3) On met à jour la barre de navigation */ + this.updateNavBar(); + +}; + + + + + + +/* [6] Gestion de la navigation entre les formulaires (10 par 10) +=========================================================*/ +inputFacebookContact.prototype.nav = function(element){ + /* (1) On vérifie que l'élément contient un nombre et existe */ + if( element == null ) + return false; + + if( element.getData('n') === false || isNaN(element.getData('n')) || element.parentNode.id != 'nav-contact' ) + return false; + + /* (2) On désactive tous les éléments actifs */ + var activeElements = $$('[data-sublink="facebook"] #f_nav-contact > span.active'); + for( var i = 0 ; i < activeElements.length ; i++ ) + activeElements[i].remClass('active'); + + /* (3) On active l'élément courant */ + element.addClass('active'); + this.selected = parseInt(element.getData('n')); +}; + + + + + + + +/* [7] Mise à jour de la navigation +=========================================================*/ +inputFacebookContact.prototype.updateNavBar = function(){ + var contactKeys = lsi.keys('contacts'); + var len = contactKeys.length; + + + /* (1) On vérifie si la barre de navigation est à jour */ + var navBarUpToDate = this.nav_container.children.length == len; + + + /* (2) On vide et remplit la barre de nav, si elle n'est pas à jour */ + if( !navBarUpToDate ){ + this.nav_container.innerHTML = ''; + + for( var i = 0 ; i < len ; i+=10 ) + this.nav_container.innerHTML += ''+ (1+i/10) +''; + } + + + /* (4) On séléctionne par défaut la dernière MINI fiche sélectionnée */ + this.nav( $('[data-sublink="facebook"] #f_nav-contact [data-n="'+( this.selected )+'"]') ); +}; + + + + + + +/* [8] Point d'amorçage de la gestion des contacts +=========================================================*/ +inputFacebookContact.prototype.attach = function(handler){ + console.log('CONTACTS: ATTACH'); + + /* (1) On initialise le jeu de données */ + lsi.createDataset('contacts'); + + /* (2) On charge les contacts depuis la mémoire ('localStorage') */ + this.storageToFields(); + + /* (3) On enregistre le handler */ + this.handler = handler; + + /* (4) On attache l'évènement sur le conteneur de navigation */ + var ptr = this; + this.nav_container.addEventListener('click', function(e){ + // 1. On gère la navigation + ptr.nav(e.target); + + // 2. On gere le chargement dynamique + ptr.handler(e.target); + }, false); + +}; diff --git a/js/includes/input-facebook-subject-min.js b/js/includes/input-facebook-subject-min.js new file mode 100644 index 0000000..b1237bd --- /dev/null +++ b/js/includes/input-facebook-subject-min.js @@ -0,0 +1,4 @@ +function inputFacebookSubject(a,b,c,d){this.username=a;this.firstname=b;this.lastname=c;this.store_button=d}inputFacebookSubject.prototype={store_button:this.store_button,username:this.username,firstname:this.firstname,lastname:this.lastname};inputFacebookSubject.prototype.check=function(){return validForm=validForm&&0 définit le conteneur et le bouton d'ajout +=========================================================*/ +function inputFacebookSubject(iUsername, iFirstname, iLastname, store_button){ + this.username = iUsername; + this.firstname = iFirstname; + this.lastname = iLastname; + + this.store_button = store_button; +} + +/* [1] Attributs +=========================================================*/ +inputFacebookSubject.prototype = { + store_button: this.store_button, // Bouton d'ajout d'un formulaire + username: this.username, + firstname: this.firstname, + lastname: this.lastname +}; + + +/* [2] Vérification d'un formulaire +=========================================================*/ +inputFacebookSubject.prototype.check = function(){ + // On renvoie la validité du formulaire + return validForm = validForm && this.username.value.length+this.firstname.value.length+this.lastname.value.length > 0; +}; + +/* [3] Gestion de l'enregistrement des formulaires de contact +=========================================================*/ +inputFacebookSubject.prototype.fieldsToStorage = function(){ + console.log('SUBJECT: FIELDS TO STORAGE'); + + // {1} Si le formulaire n'est pas valide, on ne l'enregistre pas // + if( !this.check() ) return false; + + // {2} On récupère et met en forme les valeurs du deflater // + var obj = { + username: this.username.value, + firstname: this.firstname.value, + lastname: this.lastname.value + }; + + // {3} On enregistre les données dans le 'localStorage' // + lsi.set('subject', 0, obj); + +}; + + + + + + +/* [4] Gestion de l'affichage depuis le 'localStorage' +=========================================================*/ +inputFacebookSubject.prototype.storageToFields = function(){ + console.log('SUBJECT: STORAGE TO FIELDS'); + + // {1} On récupère les informations du sujet // + var subjectData = lsi.get('subject', 0); + + if( subjectData == null ) + subjectData = { username: '', firstname: '', lastname: '' }; + + // {2} On restore les valeurs // + this.username.value = subjectData.username; + this.firstname.value = subjectData.firstname; + this.lastname.value = subjectData.lastname; +}; + + + +/* [5] Point d'amorçage de la gestion des contacts +=========================================================*/ +inputFacebookSubject.prototype.attach = function(){ + console.log('SUBJECT: ATTACH'); + + /* (1) On initialise le jeu de données */ + lsi.createDataset('subject'); + + // Pointeur pour les scopes des addEventListener() + var ptr = this; + // Handler de mise à jour quand les champs sont bons + function fts(e){ if( ptr.fieldsToStorage() ) ptr.storageToFields(); } + + + /* (2) On attache l'évènement sur le bouton d'enregistrement */ + this.store_button.addEventListener('click', fts, false); + + /* (3) On attache un évènement de 'blur' sur chaque '' */ + this.username.addEventListener( 'blur', fts, false); + this.firstname.addEventListener( 'blur', fts, false); + this.lastname.addEventListener( 'blur', fts, false); + + /* (4) On charge le sujet depuis la mémoire ('localStorage') */ + this.storageToFields(); +}; diff --git a/js/includes/input-html-data.js b/js/includes/input-html-data.js index ac66826..1ad7ae2 100644 --- a/js/includes/input-html-data.js +++ b/js/includes/input-html-data.js @@ -3,23 +3,23 @@ /* (1) Constructeur de formulaire de contact */ var contactBuilder = new HTMLBuilder(); contactBuilder.setLayout( - "

\n"+ + "

\n"+ - "\t\n"+ - "\t\n"+ - "\t\n"+ + "\t\n"+ + "\t\n"+ + "\t\n"+ - "\t\n"+ - "\t\n"+ + "\t\n"+ + "\t\n"+ - "\t \n"+ - "\t \n"+ - "\t \n"+ - "\t \n"+ - "\t \n"+ - "\t \n"+ - "\t\n"+ - "

\n\n"); + "\t \n"+ + "\t \n"+ + "\t \n"+ + "\t \n"+ + "\t \n"+ + "\t \n"+ + "\t\n"+ + "\n\n"); @@ -43,91 +43,91 @@ contactBuilder.setLayout( /* (2) Constructeur de MINI fiche de relation */ var miniFicheBuilder = new HTMLBuilder(); miniFicheBuilder.setLayout( - "
\n"+ + "
\n"+ - "\t\n"+ + "\t\n"+ - "\t\n"+ - "\t

@name

\n"+ + "\t\n"+ + "\t

@name

\n"+ - "\t
"+ - "\t\t@countcall appels"+ - "\t
"+ - "\t
"+ - "\t\t@countsms sms"+ - "\t
"+ + "\t
"+ + "\t\t@countcall appels"+ + "\t
"+ + "\t
"+ + "\t\t@countsms sms"+ + "\t
"+ - "\t
\n"+ - "\t\t\n"+ - "\t\t   \n"+ - "\t
\n"+ + "\t
\n"+ + "\t\t\n"+ + "\t\t   \n"+ + "\t
\n"+ - "\t
\n"+ - "\t\t\n"+ - "\t
\n"+ + "\t
\n"+ + "\t\t\n"+ + "\t
\n"+ - "\t
\n"+ - "\t\t\n"+ - "\t
\n"+ + "\t
\n"+ + "\t\t\n"+ + "\t
\n"+ - "\t

Type de relation

\n"+ - "\t
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t
\n"+ + "\t

Type de relation

\n"+ + "\t
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t
\n"+ - "\t

Où habite t-elle/il ?

\n"+ - "\t
\n"+ - "\t\tÀ combien de temps est-ce de chez vous ?
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t
\n"+ - "
"); + "\t

Où habite t-elle/il ?

\n"+ + "\t
\n"+ + "\t\tÀ combien de temps est-ce de chez vous ?
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t
\n"+ + "
"); @@ -176,284 +176,284 @@ miniFicheBuilder.setLayout( /* (3) Constructeur de formulaire fiche relation */ var ficheBuilder = new HTMLBuilder(); ficheBuilder.setLayout( - "
\n"+ + "
\n"+ - "\t\n"+ - "\t\n"+ + "\t\n"+ + "\t\n"+ - "\t

@name

\n"+ + "\t

@name

\n"+ - "\t
"+ - "\t\t@countcall appels"+ - "\t
"+ - "\t
"+ - "\t\t@countsms sms"+ - "\t
"+ + "\t
"+ + "\t\t@countcall appels"+ + "\t
"+ + "\t
"+ + "\t\t@countsms sms"+ + "\t
"+ - "\t
\n"+ - "\t\t\n"+ - "\t\t   \n"+ - "\t
\n"+ + "\t
\n"+ + "\t\t\n"+ + "\t\t   \n"+ + "\t
\n"+ - "\t
\n"+ - "\t\t\n"+ - "\t
\n"+ + "\t
\n"+ + "\t\t\n"+ + "\t
\n"+ - "\t
\n"+ - "\t\t\n"+ - "\t
\n"+ + "\t
\n"+ + "\t\t\n"+ + "\t
\n"+ - "\t
\n"+ - "\t\tSituation familiale:
\n"+ - "\t\t
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   \n"+ - "\t
\n"+ + "\t
\n"+ + "\t\tSituation familiale:
\n"+ + "\t\t
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   \n"+ + "\t
\n"+ - "\t
\n"+ - "\t\t\n"+ + "\t\t\t\n"+ + "\t\t\t\n"+ + "\t\t\t\n"+ + "\t\t\t\n"+ + "\t\t\t\n"+ + "\t\t\t\n"+ + "\t\t\t\n"+ + "\t\t\t\n"+ + "\t\t\t\n"+ + "\t\t\t\t\n"+ + "\t\t\t\n"+ + "\t\t\t\t\n"+ + "\t\t\t\n"+ + "\t\t\t\t\n"+ + "\t\t\t\t\n"+ + "\t\t\t\t\n"+ - "\t\t\t\n"+ - "\t\t\t\t\n"+ - "\t\t\t\t\n"+ - "\t\t\t\t\n"+ - "\t\t\t\n"+ - "\t\t\t\t\n"+ - "\t\t\t\t\n"+ - "\t\t\t\t\n"+ - "\t\t\t\t\n"+ - "\t\t\n"+ - "\t
\n"+ + "\t\t\t\n"+ + "\t\t\t\t\n"+ + "\t\t\t\t\n"+ + "\t\t\t\t\n"+ + "\t\t\t\n"+ + "\t\t\t\t\n"+ + "\t\t\t\t\n"+ + "\t\t\t\t\n"+ + "\t\t\t\t\n"+ + "\t\t\n"+ + "\t\n"+ - "\t

Type de relation

\n"+ - "\t
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t
\n"+ + "\t

Type de relation

\n"+ + "\t
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t
\n"+ - "\t

Où habite t-elle/il ?

\n"+ + "\t

Où habite t-elle/il ?

\n"+ - "\t
\n"+ - "\t\t\n"+ - "\t\t
\n"+ - "\t
\n"+ - "\t
\n"+ - "\t\tSi Toulouse : \n"+ - "\t
\n"+ + "\t
\n"+ + "\t\t\n"+ + "\t\t
\n"+ + "\t
\n"+ + "\t
\n"+ + "\t\tSi Toulouse : \n"+ + "\t
\n"+ - "\t
\n"+ - "\t\tÀ combien de temps est-ce de chez vous ?
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t
\n"+ + "\t
\n"+ + "\t\tÀ combien de temps est-ce de chez vous ?
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t
\n"+ - "\t
\n"+ - "\t\tDepuis quand connaissez-vous cette personne ?

\n"+ - "\t\tmois\n"+ - "\t\tet    ans.\n"+ - "\t
\n"+ + "\t
\n"+ + "\t\tDepuis quand connaissez-vous cette personne ?

\n"+ + "\t\tmois\n"+ + "\t\tet    ans.\n"+ + "\t
\n"+ - "\t

Contexte de rencontre

\n"+ - "\t
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t
\n"+ + "\t

Contexte de rencontre

\n"+ + "\t
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t
\n"+ - "\t
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t\t   
\n"+ - "\t
\n"+ + "\t
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t\t   
\n"+ + "\t
\n"+ - "\t

Avec quelle fréquence discutez-vous avec cette personne ?

\n"+ - "\t
\n"+ - "\t\tFace à face
\n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t
\n"+ + "\t

Avec quelle fréquence discutez-vous avec cette personne ?

\n"+ + "\t
\n"+ + "\t\tFace à face
\n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t
\n"+ - "\t
\n"+ - "\t\tTéléphone ou skype et équivalent
\n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t
\n"+ + "\t
\n"+ + "\t\tTéléphone ou skype et équivalent
\n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t
\n"+ - "\t
\n"+ - "\t\tSMS, et équivalents
\n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t
\n"+ + "\t
\n"+ + "\t\tSMS, et équivalents
\n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t
\n"+ - "\t
\n"+ - "\t\tCourrier électronique
\n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t
\n"+ + "\t
\n"+ + "\t\tCourrier électronique
\n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t
\n"+ - "\t
\n"+ - "\t\tFacebook ou autre réseau social
\n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t
\n"+ + "\t
\n"+ + "\t\tFacebook ou autre réseau social
\n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t
\n"+ - "\t

Comment êtes-vous « connecté » à cette personne ?

\n"+ - "\t
\n"+ - "\t\tSes coordonnées sont dans votre carnet d’adresse
\n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t
\n"+ + "\t

Comment êtes-vous « connecté » à cette personne ?

\n"+ + "\t
\n"+ + "\t\tSes coordonnées sont dans votre carnet d’adresse
\n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t
\n"+ - "\t
\n"+ - "\t\tSon numéro de mobile est enregistré sur votre mobile (ou vous-mêmes êtes sur le sien)
\n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t
\n"+ + "\t
\n"+ + "\t\tSon numéro de mobile est enregistré sur votre mobile (ou vous-mêmes êtes sur le sien)
\n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t
\n"+ - "\t
\n"+ - "\t\tElle figure parmi vos amis facebook
\n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t
\n"+ + "\t
\n"+ + "\t\tElle figure parmi vos amis facebook
\n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t
\n"+ - "\t
\n"+ - "\t\tElle figure parmi vos amis facebook et vous interagissez avec elle sur ce dispositif régulièrement
\n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t
\n"+ + "\t
\n"+ + "\t\tElle figure parmi vos amis facebook et vous interagissez avec elle sur ce dispositif régulièrement
\n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t
\n"+ - "\t
\n"+ - "\t\tVous le suivez sur Twitter
\n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t
\n"+ + "\t
\n"+ + "\t\tVous le suivez sur Twitter
\n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t
\n"+ - "\t
\n"+ - "\t\tVous communiquez avec cette personne sur Twitter
\n"+ - "\t\t   \n"+ - "\t\t   \n"+ - "\t
\n"+ + "\t
\n"+ + "\t\tVous communiquez avec cette personne sur Twitter
\n"+ + "\t\t   \n"+ + "\t\t   \n"+ + "\t
\n"+ - "\t
\n"+ - "\t\tVous communiquez dans autre réseau social : \n"+ - "\t
\n"+ + "\t
\n"+ + "\t\tVous communiquez dans autre réseau social : \n"+ + "\t
\n"+ - "\t
\n"+ - "\t\tVous communiquez dans un autre dispositif (blogs, jeu vidéo ou autre) : \n"+ - "\t
\n"+ + "\t
\n"+ + "\t\tVous communiquez dans un autre dispositif (blogs, jeu vidéo ou autre) : \n"+ + "\t
\n"+ - "
\n"); + "
\n"); diff --git a/js/includes/input-phone-contact-min.js b/js/includes/input-phone-contact-min.js index 8d2f037..db16074 100644 --- a/js/includes/input-phone-contact-min.js +++ b/js/includes/input-phone-contact-min.js @@ -1,8 +1,8 @@ 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.check=function(a){var b=0=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"))||"nav-contact"!=a.parentNode.id)return!1;for(var b=$$("#nav-contact > span.active"),c=0;c'+(1+b/10)+""}this.nav($('#nav-contact [data-n="'+this.selected+'"]'))}; +inputPhoneContact.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"nav-contact"!=a.parentNode.id)return!1;for(var b=$$('[data-sublink="phone"] #p_nav-contact > span.active'),c=0;c'+(1+b/10)+""}this.nav($('[data-sublink="phone"] #p_nav-contact [data-n="'+this.selected+'"]'))}; inputPhoneContact.prototype.attach=function(a){console.log("CONTACTS: ATTACH");lsi.createDataset("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)}; diff --git a/js/includes/input-phone-contact.js b/js/includes/input-phone-contact.js index f8f9bfd..28084f4 100644 --- a/js/includes/input-phone-contact.js +++ b/js/includes/input-phone-contact.js @@ -1,17 +1,17 @@ /* [0] Constructeur -> définit le conteneur et le bouton d'ajout =========================================================*/ function inputPhoneContact(container, navContainer){ - this.container = container; - this.nav_container = navContainer; + this.container = container; + this.nav_container = navContainer; } /* [1] Attributs =========================================================*/ inputPhoneContact.prototype = { - container: this.container, // Conteneur des formulaires de contact - nav_container: this.nav_container, // Conteneur de la navigation entre les formulaires - selected: 0, // UID du permier des contacts sélectionnés (10 par 10) - handler: null // Fonction pour l'enregistrement et la synchronisation des données + container: this.container, // Conteneur des formulaires de contact + nav_container: this.nav_container, // Conteneur de la navigation entre les formulaires + selected: 0, // UID du permier des contacts sélectionnés (10 par 10) + handler: null // Fonction pour l'enregistrement et la synchronisation des données }; @@ -19,56 +19,56 @@ inputPhoneContact.prototype = { /* [2] Vérification des données d'un contact =========================================================*/ inputPhoneContact.prototype.check = function(deflated){ - /* (1) Le numéro n'est pas vide */ - var validForm = deflated.number.length > 0; - /* (2) ET le pseudo et/ou le prénom et/ou le nom n'est pas vide */ - validForm = validForm && deflated.username.length+deflated.firstname.length+deflated.lastname.length > 0; + /* (1) Le numéro n'est pas vide */ + var validForm = deflated.number.length > 0; + /* (2) ET le pseudo et/ou le prénom et/ou le nom n'est pas vide */ + validForm = validForm && deflated.username.length+deflated.firstname.length+deflated.lastname.length > 0; - /* (3) On retourne la validité du formulaire */ - return validForm + /* (3) On retourne la validité du formulaire */ + return validForm } /* [3] Gestion de l'enregistrement des formulaires de contact =========================================================*/ inputPhoneContact.prototype.fieldsToStorage = function(){ - console.log('CONTACTS: FIELDS TO STORAGE'); + console.log('CONTACTS: FIELDS TO STORAGE'); - // {1} Pour chaque formulaire de contact présent // - var visibleContacts = $$('article.contact-panel .new-contact'); - for( var i = 0 ; i < visibleContacts.length ; i++ ){ + // {1} Pour chaque formulaire de contact présent // + var visibleContacts = $$('[data-sublink="phone"] article.contact-panel .new-contact'); + for( var i = 0 ; i < visibleContacts.length ; i++ ){ - // {2} On initialise notre deflater pour récupérer les valeurs // - var deflater = new FormDeflater(visibleContacts[i], ['input'], ['data-name']); + // {2} On initialise notre deflater pour récupérer les valeurs // + var deflater = new FormDeflater(visibleContacts[i], ['input'], ['data-name']); - // {3} On enregistre ce contact si le numéro n'est pas vide et soit pseudo/prénom/nom // - var deflated = deflater.deflate(); + // {3} On enregistre ce contact si le numéro n'est pas vide et soit pseudo/prénom/nom // + var deflated = deflater.deflate(); - // Si le formulaire n'est pas valide, on ne l'enregistre pas - if( !this.check(deflated) ) continue; + // Si le formulaire n'est pas valide, on ne l'enregistre pas + if( !this.check(deflated) ) continue; - // {4} On récupère et met en forme les valeurs du deflater // - var obj = { - uid: parseInt(deflated.uid), - number: deflated.number, - username: deflated.username, - firstname: deflated.firstname, - lastname: deflated.lastname, + // {4} On récupère et met en forme les valeurs du deflater // + var obj = { + uid: parseInt(deflated.uid), + number: deflated.number, + username: deflated.username, + firstname: deflated.firstname, + lastname: deflated.lastname, - call: parseInt(deflated.call), - sms: parseInt(deflated.sms), + call: parseInt(deflated.call), + sms: parseInt(deflated.sms), - countcall: parseInt(deflated.countcall), - countsms: parseInt(deflated.countsms) - }; + countcall: parseInt(deflated.countcall), + countsms: parseInt(deflated.countsms) + }; - /* (5) On calcule et ajoute le hash des données */ - obj.hash = crc32( JSON.stringify(obj) ); + /* (5) On calcule et ajoute le hash des données */ + obj.hash = crc32( JSON.stringify(obj) ); - // {6} On enregistre les données dans le 'localStorage' // - lsi.set('contacts', parseInt(deflated.uid), obj); + // {6} On enregistre les données dans le 'localStorage' // + lsi.set('contacts', parseInt(deflated.uid), obj); - } + } }; @@ -88,35 +88,35 @@ inputPhoneContact.prototype.fieldsToStorage = function(){ * */ inputPhoneContact.prototype.add = function(objectData){ - console.log('CONTACTS: ADD'); + console.log('CONTACTS: ADD'); - // Si pas d'uid, on quitte - if( objectData == null || objectData.uid == null || isNaN(objectData.uid) ) - return false + // Si pas d'uid, on quitte + if( objectData == null || objectData.uid == null || isNaN(objectData.uid) ) + return false - // {0} On formatte l'object // - objectData.number = (objectData.number != null) ? objectData.number : ''; - objectData.username = (objectData.username != null) ? objectData.username : ''; - objectData.firstname = (objectData.firstname != null) ? objectData.firstname : ''; - objectData.lastname = (objectData.lastname != null) ? objectData.lastname : ''; - objectData.call = (objectData.call != null) ? objectData.call : -1; - objectData.sms = (objectData.sms != null) ? objectData.sms : -1; - objectData.countcall = (objectData.countcall != null) ? objectData.countcall : 0; - objectData.countsms = (objectData.countsms != null) ? objectData.countsms : 0; + // {0} On formatte l'object // + objectData.number = (objectData.number != null) ? objectData.number : ''; + objectData.username = (objectData.username != null) ? objectData.username : ''; + objectData.firstname = (objectData.firstname != null) ? objectData.firstname : ''; + objectData.lastname = (objectData.lastname != null) ? objectData.lastname : ''; + objectData.call = (objectData.call != null) ? objectData.call : -1; + objectData.sms = (objectData.sms != null) ? objectData.sms : -1; + objectData.countcall = (objectData.countcall != null) ? objectData.countcall : 0; + objectData.countsms = (objectData.countsms != null) ? objectData.countsms : 0; - // {1} On ajoute le HTML // - this.container.innerHTML += contactBuilder.build(objectData); + // {1} On ajoute le HTML // + this.container.innerHTML += contactBuilder.build(objectData); - // {2} On attache les évènements sur les formulaires // - var contactForms = $$('article.contact-panel .new-contact'); + // {2} On attache les évènements sur les formulaires // + var contactForms = $$('[data-sublink="phone"] article.contact-panel .new-contact'); - // On met à jour les listener (remove, puis add) - var ptr = this; - for( var i = 0 ; i < contactForms.length ; i++ ){ - contactForms[i].removeEventListener('click', function(e){ ptr.nav(e.target); ptr.handler(e.target); }, false); - contactForms[i].addEventListener('click', function(e){ ptr.nav(e.target); ptr.handler(e.target); }, false); - } + // On met à jour les listener (remove, puis add) + var ptr = this; + for( var i = 0 ; i < contactForms.length ; i++ ){ + contactForms[i].removeEventListener('click', function(e){ ptr.nav(e.target); ptr.handler(e.target); }, false); + contactForms[i].addEventListener('click', function(e){ ptr.nav(e.target); ptr.handler(e.target); }, false); + } }; @@ -132,28 +132,28 @@ inputPhoneContact.prototype.add = function(objectData){ /* [5] Gestion de l'affichage depuis le 'localStorage' =========================================================*/ inputPhoneContact.prototype.storageToFields = function(){ - console.log('CONTACTS: STORAGE TO FIELDS'); + console.log('CONTACTS: STORAGE TO FIELDS'); - // {1} Pour chaque contact du 'localStorage' // - var contactKeys = lsi.keys('contacts'); + // {1} Pour chaque contact du 'localStorage' // + var contactKeys = lsi.keys('contacts'); - // On réinitialise le HTML - this.container.innerHTML = ''; + // On réinitialise le HTML + this.container.innerHTML = ''; - // {2} On ajoute chaque contact (parmi les séléctionnés) à la liste // - var min = this.selected; // On affiche du contact sélectionné - var max = this.selected+10; // On s'arrête à 10 contacs + // {2} On ajoute chaque contact (parmi les séléctionnés) à la liste // + var min = this.selected; // On affiche du contact sélectionné + var max = this.selected+10; // On s'arrête à 10 contacs - for( var i = min ; i < max && i < contactKeys.length ; i++ ) - this.add( lsi.get('contacts', contactKeys[i]) ); + for( var i = min ; i < max && i < contactKeys.length ; i++ ) + this.add( lsi.get('contacts', contactKeys[i]) ); - // On ajoute un champ de plus à remplir si c'est la dernière page - if( max >= contactKeys.length ) - this.add({uid: contactKeys.length}); + // On ajoute un champ de plus à remplir si c'est la dernière page + if( max >= contactKeys.length ) + this.add({uid: contactKeys.length}); - /* (3) On met à jour la barre de navigation */ - this.updateNavBar(); + /* (3) On met à jour la barre de navigation */ + this.updateNavBar(); }; @@ -165,21 +165,21 @@ inputPhoneContact.prototype.storageToFields = function(){ /* [6] Gestion de la navigation entre les formulaires (10 par 10) =========================================================*/ inputPhoneContact.prototype.nav = function(element){ - /* (1) On vérifie que l'élément contient un nombre et existe */ - if( element == null ) - return false; + /* (1) On vérifie que l'élément contient un nombre et existe */ + if( element == null ) + return false; - if( element.getData('n') === false || isNaN(element.getData('n')) || element.parentNode.id != 'nav-contact' ) - return false; + if( element.getData('n') === false || isNaN(element.getData('n')) || element.parentNode.id != 'nav-contact' ) + return false; - /* (2) On désactive tous les éléments actifs */ - var activeElements = $$('#nav-contact > span.active'); - for( var i = 0 ; i < activeElements.length ; i++ ) - activeElements[i].remClass('active'); + /* (2) On désactive tous les éléments actifs */ + var activeElements = $$('[data-sublink="phone"] #p_nav-contact > span.active'); + for( var i = 0 ; i < activeElements.length ; i++ ) + activeElements[i].remClass('active'); - /* (3) On active l'élément courant */ - element.addClass('active'); - this.selected = parseInt(element.getData('n')); + /* (3) On active l'élément courant */ + element.addClass('active'); + this.selected = parseInt(element.getData('n')); }; @@ -191,25 +191,25 @@ inputPhoneContact.prototype.nav = function(element){ /* [7] Mise à jour de la navigation =========================================================*/ inputPhoneContact.prototype.updateNavBar = function(){ - var contactKeys = lsi.keys('contacts'); - var len = contactKeys.length; + var contactKeys = lsi.keys('contacts'); + var len = contactKeys.length; - /* (1) On vérifie si la barre de navigation est à jour */ - var navBarUpToDate = this.nav_container.children.length == len; + /* (1) On vérifie si la barre de navigation est à jour */ + var navBarUpToDate = this.nav_container.children.length == len; - /* (2) On vide et remplit la barre de nav, si elle n'est pas à jour */ - if( !navBarUpToDate ){ - this.nav_container.innerHTML = ''; + /* (2) On vide et remplit la barre de nav, si elle n'est pas à jour */ + if( !navBarUpToDate ){ + this.nav_container.innerHTML = ''; - for( var i = 0 ; i < len ; i+=10 ) - this.nav_container.innerHTML += ''+ (1+i/10) +''; - } + for( var i = 0 ; i < len ; i+=10 ) + this.nav_container.innerHTML += ''+ (1+i/10) +''; + } - /* (4) On séléctionne par défaut la dernière MINI fiche sélectionnée */ - this.nav( $('#nav-contact [data-n="'+( this.selected )+'"]') ); + /* (4) On séléctionne par défaut la dernière MINI fiche sélectionnée */ + this.nav( $('[data-sublink="phone"] #p_nav-contact [data-n="'+( this.selected )+'"]') ); }; @@ -220,25 +220,25 @@ inputPhoneContact.prototype.updateNavBar = function(){ /* [8] Point d'amorçage de la gestion des contacts =========================================================*/ inputPhoneContact.prototype.attach = function(handler){ - console.log('CONTACTS: ATTACH'); + console.log('CONTACTS: ATTACH'); - /* (1) On initialise le jeu de données */ - lsi.createDataset('contacts'); + /* (1) On initialise le jeu de données */ + lsi.createDataset('contacts'); - /* (2) On charge les contacts depuis la mémoire ('localStorage') */ - this.storageToFields(); + /* (2) On charge les contacts depuis la mémoire ('localStorage') */ + this.storageToFields(); - /* (3) On enregistre le handler */ - this.handler = handler; + /* (3) On enregistre le handler */ + this.handler = handler; - /* (4) On attache l'évènement sur le conteneur de navigation */ - var ptr = this; - this.nav_container.addEventListener('click', function(e){ - // 1. On gère la navigation - ptr.nav(e.target); + /* (4) On attache l'évènement sur le conteneur de navigation */ + var ptr = this; + this.nav_container.addEventListener('click', function(e){ + // 1. On gère la navigation + ptr.nav(e.target); - // 2. On gere le chargement dynamique - ptr.handler(e.target); - }, false); + // 2. On gere le chargement dynamique + ptr.handler(e.target); + }, false); }; diff --git a/js/includes/input-phone-fiche-min.js b/js/includes/input-phone-fiche-min.js index d3bd845..159382a 100644 --- a/js/includes/input-phone-fiche-min.js +++ b/js/includes/input-phone-fiche-min.js @@ -1,19 +1,20 @@ function inputPhoneFiche(a,b){this.container=a;this.nav_container=b}inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{sexe:"0",age:".",job:".",famsit:"0",studies:".",reltype:"0",reltypeSpecial:"",city:"",quartier:"",cp:"",loc:"0",duration:["",""],context:"0",contextSpecial:["","",""],freq:["4","9","14","19","24"],connect:"1 3 5 7 9 11".split(" "),connectSpecial:["",""],timestamp:0,valid:!1}}; -inputPhoneFiche.prototype.fieldsToStorage=function(){console.log("FICHE: FIELDS TO STORAGE");for(var a=$$("article.relation-panel .fiche-relation"),b=0;b FICHE UPDATE"),c.timestamp=Date.now());lsi.set("fiches",c.uid,c)}}}; inputPhoneFiche.prototype.add=function(a){console.log("FICHE: ADD");if(null==a.uid||isNaN(a.uid)||null==a.contact||isNaN(a.contact))return!1;a.city=null!=a.city?a.city:this.defaultData.city;a.quartier=null!=a.quartier?a.quartier:this.defaultData.quartier;a.cp=null!=a.cp?a.cp:this.defaultData.cp;a.duration[0]=null!=a.duration[0]?a.duration[0]:this.defaultData.duration[0];a.duration[1]=null!=a.duration[1]?a.duration[1]:this.defaultData.duration[1];a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial: this.defaultData.reltypeSpecial;a.contextSpecial[0]=null!=a.contextSpecial[0]?a.contextSpecial[0]:this.defaultData.contextSpecial[0];a.contextSpecial[1]=null!=a.contextSpecial[1]?a.contextSpecial[1]:this.defaultData.contextSpecial[1];a.contextSpecial[2]=null!=a.contextSpecial[2]?a.contextSpecial[2]:this.defaultData.contextSpecial[2];a.connectSpecial[0]=null!=a.connectSpecial[0]?a.connectSpecial[0]:this.defaultData.connectSpecial[0];a.connectSpecial[1]=null!=a.connectSpecial[1]?a.connectSpecial[1]: this.defaultData.connectSpecial[1];a.job=null!=a.job?a.job:this.defaultData.job;a.studies=null!=a.studies?a.studies:this.defaultData.studies;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.famsit=null!=a.famsit?a.famsit:this.defaultData.famsit;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.loc=null!=a.loc?a.loc:this.defaultData.loc;a.context=null!=a.context?a.context:this.defaultData.context;a.freq=null!=a.freq?a.freq:this.defaultData.freq; a.connect=null!=a.connect?a.connect:this.defaultData.connect;var b=lsi.get("contacts",a.contact);if(!1===b)return!1;this.container.innerHTML+=ficheBuilder.build({name:readableName(b.username,b.firstname,b.lastname),countcall:b.countcall,countsms:b.countsms,uid:a.uid,contact:a.contact,city:a.city,quartier:a.quartier,cp:a.cp,duration0:a.duration[0],duration1:a.duration[1],reltypespecial:a.reltypeSpecial,contextspecial0:a.contextSpecial[0],contextspecial1:a.contextSpecial[1],contextspecial2:a.contextSpecial[2], -connectspecial0:a.connectSpecial[0],connectspecial1:a.connectSpecial[1]});b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+a.job+'"]');null!=b&&b.setAttribute("selected","selected");b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=b&&b.setAttribute("selected","selected");b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+ -'"] ~ h5>span>select[data-name="age"]>option[value="'+a.age+'"]');null!=b&&b.setAttribute("selected","selected");for(var c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;binput[type="radio"][data-name="famsit"]');for(b=0;binput[type="radio"][data-name="reltype"]');for(b=0;binput[type="radio"][data-name="loc"]');for(b=0;binput[type="radio"][data-name="context"]');for(b=0;binput[type="radio"][data-name="freq"]');for(b=0;binput[type="radio"][data-name="connect"]');for(b=0;bspan>select[data-name="job"]>option[value="'+a.job+'"]');null!=b&&b.setAttribute("selected","selected");b=$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=b&&b.setAttribute("selected","selected");b=$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+ +a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+a.age+'"]');null!=b&&b.setAttribute("selected","selected");for(var c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;binput[type="radio"][data-name="famsit"]'); +for(b=0;binput[type="radio"][data-name="reltype"]');for(b=0;binput[type="radio"][data-name="loc"]'); +for(b=0;binput[type="radio"][data-name="context"]');for(b=0;binput[type="radio"][data-name="freq"]'); +for(b=0;binput[type="radio"][data-name="connect"]');for(b=0;blsi.keys("contacts").length?lsi.keys("contacts").length:20;if(b.length=e)break}for(var f in d)b=lsi.get("contacts",d[f].contact),null!=b&&-1!=b.sms&&-1!=b.call&&(b=10>parseInt(f)?10+b.sms:b.call,b=d[b],b.timestamp>=d[f].timestamp||(c=d[f],c.uid=b.uid,lsi.set("fiches",b.uid,c)))}; -inputPhoneFiche.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"nav-fiche"!=a.parentNode.id)return!1;for(var b=$$("#nav-fiche > span.active"),c=0;c span.active'),c=0;cAPPELS");10>e&&c'+(e%10+1)+"  ":(10==e&&(this.nav_container.innerHTML+='SMS'),this.nav_container.innerHTML+=''+(e%10+1)+"")}for(var d in a)b= -$('#nav-fiche [data-n="'+a[d].uid+'"]'),null!=b&&(!0===a[d].valid?b.addClass("done"):b.remClass("done"));this.nav($('#nav-fiche [data-n="'+this.selected+'"]'))}; +$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[d].uid+'"]'),null!=b&&(!0===a[d].valid?b.addClass("done"):b.remClass("done"));this.nav($('[data-sublink="phone"] #p_nav-fiche [data-n="'+this.selected+'"]'))}; inputPhoneFiche.prototype.check=function(a){if(2>a.city.length||isNaN(parseInt(a.duration[0]))&&0a.reltypeSpecial.length|| "11"==a.context&&2>a.contextSpecial[0].length||"12"==a.context&&2>a.contextSpecial[1].length||"13"==a.context&&2>a.contextSpecial[2].length?!1:!0};inputPhoneFiche.prototype.attach=function(a){console.log("FICHE: ATTACH");lsi.createDataset("fiches");this.storageToFields();this.handler=a;var b=this,b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)}; diff --git a/js/includes/input-phone-fiche.js b/js/includes/input-phone-fiche.js index e158a01..a53e305 100644 --- a/js/includes/input-phone-fiche.js +++ b/js/includes/input-phone-fiche.js @@ -1,113 +1,113 @@ /* [0] Constructeur -> définit le conteneur et le bouton d'ajout =========================================================*/ function inputPhoneFiche(container, navContainer){ - this.container = container; - this.nav_container = navContainer; + this.container = container; + this.nav_container = navContainer; } /* [1] Attributs =========================================================*/ inputPhoneFiche.prototype = { - container: this.container, // Conteneur des fiche fiches relation - nav_container: this.nav_container, // Conteneur de la navigation entre les fiches - selected: 0, // UID de la FICHE sélectionnée - handler: null, // Fonction pour l'enregistrement et la synchronisation des données - defaultData: { // Valeurs par défaut - sexe: '0', - age: '.', - job: '.', - famsit: '0', // Choix 1 à 3 - studies: '.', - reltype: '0', // Choix 1 à 9 - reltypeSpecial: '', - city: '', - quartier: '', - cp: '', - loc: '0', - duration: ['', ''], - context: '0', // Choix 1 à 14 - contextSpecial: ['', '', ''], - freq: ['4', '9', '14', '19', '24'], // 1er choix des 4 pour chaque question - connect: ['1', '3', '5', '7', '9', '11'], // Le deuxième choix (Oui/Non) donc 'Non' par défaut pour chaque question - connectSpecial: ['', ''], - timestamp: 0, - valid: false - } + container: this.container, // Conteneur des fiche fiches relation + nav_container: this.nav_container, // Conteneur de la navigation entre les fiches + selected: 0, // UID de la FICHE sélectionnée + handler: null, // Fonction pour l'enregistrement et la synchronisation des données + defaultData: { // Valeurs par défaut + sexe: '0', + age: '.', + job: '.', + famsit: '0', // Choix 1 à 3 + studies: '.', + reltype: '0', // Choix 1 à 9 + reltypeSpecial: '', + city: '', + quartier: '', + cp: '', + loc: '0', + duration: ['', ''], + context: '0', // Choix 1 à 14 + contextSpecial: ['', '', ''], + freq: ['4', '9', '14', '19', '24'], // 1er choix des 4 pour chaque question + connect: ['1', '3', '5', '7', '9', '11'], // Le deuxième choix (Oui/Non) donc 'Non' par défaut pour chaque question + connectSpecial: ['', ''], + timestamp: 0, + valid: false + } }; /* [2] Gestion de l'enregistrement des formulaires fiche fiches relation =========================================================*/ inputPhoneFiche.prototype.fieldsToStorage = function(){ - console.log('FICHE: FIELDS TO STORAGE'); + console.log('FICHE: FIELDS TO STORAGE'); - // {1} Pour chaque formulaire de contact présent // - var existingFiches = $$('article.relation-panel .fiche-relation'); - for( var i = 0 ; i < existingFiches.length ; i++ ){ + // {1} Pour chaque formulaire de contact présent // + var existingFiches = $$('[data-sublink="phone"] article.relation-panel .fiche-relation'); + for( var i = 0 ; i < existingFiches.length ; i++ ){ - // {2} On initialise notre deflater pour récupérer les valeurs // - var deflater = new FormDeflater(existingFiches[i], ['input', 'select'], ['data-name']); + // {2} On initialise notre deflater pour récupérer les valeurs // + var deflater = new FormDeflater(existingFiches[i], ['input', 'select'], ['data-name']); - // {3} On enregistre ce contact si le numéro n'est pas vide et soit pseudo/prénom/nom // - var deflated = deflater.deflate(); - // On crée le hash - var deflatedHash = crc32(JSON.stringify(deflated)); + // {3} On enregistre ce contact si le numéro n'est pas vide et soit pseudo/prénom/nom // + var deflated = deflater.deflate(); + // On crée le hash + var deflatedHash = crc32(JSON.stringify(deflated)); - // console.log( deflated ); + // console.log( deflated ); - // {4} On récupère les données du LSI si elles existent // - var existingData = lsi.get('fiches', deflated.uid); + // {4} On récupère les données du LSI si elles existent // + var existingData = lsi.get('fiches', deflated.uid); - // Si n'existe pas, on passe au suivant - if( existingData === false ) - continue; + // Si n'existe pas, on passe au suivant + if( existingData === false ) + continue; - // {5} On récupère et met en forme les valeurs du deflater // - // Si le hash est le même, on ne fait rien - if( existingData.hash != null && existingData.hash == deflatedHash ) - return; + // {5} On récupère et met en forme les valeurs du deflater // + // Si le hash est le même, on ne fait rien + if( existingData.hash != null && existingData.hash == deflatedHash ) + return; - var obj = { - contact: parseInt(deflated.contact), - uid: parseInt(deflated.uid), - sexe: deflated.sexe, - age: deflated.age, - job: deflated.job, - famsit: deflated.famsit, - studies: deflated.studies, - reltype: deflated.reltype, - reltypeSpecial: deflated.reltypeSpecial, - city: deflated.city, - quartier: deflated.quartier, - cp: deflated.cp, - loc: deflated.loc, - duration: deflated.duration, - context: deflated.context, - contextSpecial: deflated.contextSpecial, - freq: deflated.freq, - connect: deflated.connect, - connectSpecial: deflated.connectSpecial, - hash: deflatedHash - }; + var obj = { + contact: parseInt(deflated.contact), + uid: parseInt(deflated.uid), + sexe: deflated.sexe, + age: deflated.age, + job: deflated.job, + famsit: deflated.famsit, + studies: deflated.studies, + reltype: deflated.reltype, + reltypeSpecial: deflated.reltypeSpecial, + city: deflated.city, + quartier: deflated.quartier, + cp: deflated.cp, + loc: deflated.loc, + duration: deflated.duration, + context: deflated.context, + contextSpecial: deflated.contextSpecial, + freq: deflated.freq, + connect: deflated.connect, + connectSpecial: deflated.connectSpecial, + hash: deflatedHash + }; - /* (6) On vérifie la validité des données et on l'enregistre dans l'objet avec la date de modification */ - obj.valid = this.check(obj); + /* (6) On vérifie la validité des données et on l'enregistre dans l'objet avec la date de modification */ + obj.valid = this.check(obj); - // On met à jour la date de modification, si on a pas qu'@uid de différent - if( diff(existingData, obj, ['hash', 'valid', 'timestamp']).length > 0 ){ - console.log( diff(existingData, obj, ['hash', 'valid', 'timestamp']) ); - console.warn('> FICHE UPDATE'); - obj.timestamp = Date.now(); - } + // On met à jour la date de modification, si on a pas qu'@uid de différent + if( diff(existingData, obj, ['hash', 'valid', 'timestamp']).length > 0 ){ + console.log( diff(existingData, obj, ['hash', 'valid', 'timestamp']) ); + console.warn('> FICHE UPDATE'); + obj.timestamp = Date.now(); + } - /* (7) On enregistre les données dans le 'localStorage' */ - lsi.set('fiches', obj.uid, obj); - } + /* (7) On enregistre les données dans le 'localStorage' */ + lsi.set('fiches', obj.uid, obj); + } }; @@ -126,133 +126,133 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){ * */ inputPhoneFiche.prototype.add = function(objectData){ - console.log('FICHE: ADD'); + console.log('FICHE: ADD'); - // Si pas d'UID ou d'UID de contact, on retourne une erreur - if( objectData.uid == null || isNaN(objectData.uid) || objectData.contact == null || isNaN(objectData.contact) ) - return false; + // Si pas d'UID ou d'UID de contact, on retourne une erreur + if( objectData.uid == null || isNaN(objectData.uid) || objectData.contact == null || isNaN(objectData.contact) ) + return false; - /* (0) Gestion du formattage des valeur */ - // {1} Champs de texte // - objectData.city = (objectData.city != null) ? objectData.city : this.defaultData.city; - objectData.quartier = (objectData.quartier != null) ? objectData.quartier : this.defaultData.quartier; - objectData.cp = (objectData.cp != null) ? objectData.cp : this.defaultData.cp; - objectData.duration[0] = (objectData.duration[0] != null) ? objectData.duration[0] : this.defaultData.duration[0]; - objectData.duration[1] = (objectData.duration[1] != null) ? objectData.duration[1] : this.defaultData.duration[1]; - objectData.reltypeSpecial = (objectData.reltypeSpecial != null) ? objectData.reltypeSpecial : this.defaultData.reltypeSpecial; - objectData.contextSpecial[0] = (objectData.contextSpecial[0] != null) ? objectData.contextSpecial[0] : this.defaultData.contextSpecial[0]; - objectData.contextSpecial[1] = (objectData.contextSpecial[1] != null) ? objectData.contextSpecial[1] : this.defaultData.contextSpecial[1]; - objectData.contextSpecial[2] = (objectData.contextSpecial[2] != null) ? objectData.contextSpecial[2] : this.defaultData.contextSpecial[2]; - objectData.connectSpecial[0] = (objectData.connectSpecial[0] != null) ? objectData.connectSpecial[0] : this.defaultData.connectSpecial[0]; - objectData.connectSpecial[1] = (objectData.connectSpecial[1] != null) ? objectData.connectSpecial[1] : this.defaultData.connectSpecial[1]; + /* (0) Gestion du formattage des valeur */ + // {1} Champs de texte // + objectData.city = (objectData.city != null) ? objectData.city : this.defaultData.city; + objectData.quartier = (objectData.quartier != null) ? objectData.quartier : this.defaultData.quartier; + objectData.cp = (objectData.cp != null) ? objectData.cp : this.defaultData.cp; + objectData.duration[0] = (objectData.duration[0] != null) ? objectData.duration[0] : this.defaultData.duration[0]; + objectData.duration[1] = (objectData.duration[1] != null) ? objectData.duration[1] : this.defaultData.duration[1]; + objectData.reltypeSpecial = (objectData.reltypeSpecial != null) ? objectData.reltypeSpecial : this.defaultData.reltypeSpecial; + objectData.contextSpecial[0] = (objectData.contextSpecial[0] != null) ? objectData.contextSpecial[0] : this.defaultData.contextSpecial[0]; + objectData.contextSpecial[1] = (objectData.contextSpecial[1] != null) ? objectData.contextSpecial[1] : this.defaultData.contextSpecial[1]; + objectData.contextSpecial[2] = (objectData.contextSpecial[2] != null) ? objectData.contextSpecial[2] : this.defaultData.contextSpecial[2]; + objectData.connectSpecial[0] = (objectData.connectSpecial[0] != null) ? objectData.connectSpecial[0] : this.defaultData.connectSpecial[0]; + objectData.connectSpecial[1] = (objectData.connectSpecial[1] != null) ? objectData.connectSpecial[1] : this.defaultData.connectSpecial[1]; - // {2} Champs // + objectData.job = (objectData.job != null) ? objectData.job : this.defaultData.job; + objectData.studies = (objectData.studies != null) ? objectData.studies : this.defaultData.studies; + objectData.age = (objectData.age != null) ? objectData.age : this.defaultData.age; - // {3} Champs // - objectData.sexe = (objectData.sexe != null) ? objectData.sexe : this.defaultData.sexe; - objectData.famsit = (objectData.famsit != null) ? objectData.famsit : this.defaultData.famsit; - objectData.reltype = (objectData.reltype != null) ? objectData.reltype : this.defaultData.reltype; - objectData.loc = (objectData.loc != null) ? objectData.loc : this.defaultData.loc; - objectData.context = (objectData.context != null) ? objectData.context : this.defaultData.context; - objectData.freq = (objectData.freq != null) ? objectData.freq : this.defaultData.freq; - objectData.connect = (objectData.connect != null) ? objectData.connect : this.defaultData.connect; + // {3} Champs // + objectData.sexe = (objectData.sexe != null) ? objectData.sexe : this.defaultData.sexe; + objectData.famsit = (objectData.famsit != null) ? objectData.famsit : this.defaultData.famsit; + objectData.reltype = (objectData.reltype != null) ? objectData.reltype : this.defaultData.reltype; + objectData.loc = (objectData.loc != null) ? objectData.loc : this.defaultData.loc; + objectData.context = (objectData.context != null) ? objectData.context : this.defaultData.context; + objectData.freq = (objectData.freq != null) ? objectData.freq : this.defaultData.freq; + objectData.connect = (objectData.connect != null) ? objectData.connect : this.defaultData.connect; - // {4} On récupère username/firstname/lastname du contact associé // - var associatedContact = lsi.get('contacts', objectData.contact); + // {4} On récupère username/firstname/lastname du contact associé // + var associatedContact = lsi.get('contacts', objectData.contact); - // Si on ne trouve pas le contact, on ne fais rien - if( associatedContact === false ) - return false; + // Si on ne trouve pas le contact, on ne fais rien + if( associatedContact === false ) + return false; - // {5} Création physique // - this.container.innerHTML += ficheBuilder.build({ - name: readableName(associatedContact.username, associatedContact.firstname, associatedContact.lastname), - countcall: associatedContact.countcall, - countsms: associatedContact.countsms, - uid: objectData.uid, - contact: objectData.contact, // uid du contact associé - city: objectData.city, - quartier: objectData.quartier, - cp: objectData.cp, - duration0: objectData.duration[0], - duration1: objectData.duration[1], - reltypespecial: objectData.reltypeSpecial, - contextspecial0: objectData.contextSpecial[0], - contextspecial1: objectData.contextSpecial[1], - contextspecial2: objectData.contextSpecial[2], - connectspecial0: objectData.connectSpecial[0], - connectspecial1: objectData.connectSpecial[1] - }); + // {5} Création physique // + this.container.innerHTML += ficheBuilder.build({ + name: readableName(associatedContact.username, associatedContact.firstname, associatedContact.lastname), + countcall: associatedContact.countcall, + countsms: associatedContact.countsms, + uid: objectData.uid, + contact: objectData.contact, // uid du contact associé + city: objectData.city, + quartier: objectData.quartier, + cp: objectData.cp, + duration0: objectData.duration[0], + duration1: objectData.duration[1], + reltypespecial: objectData.reltypeSpecial, + contextspecial0: objectData.contextSpecial[0], + contextspecial1: objectData.contextSpecial[1], + contextspecial2: objectData.contextSpecial[2], + connectspecial0: objectData.connectSpecial[0], + connectspecial1: objectData.connectSpecial[1] + }); - /* {6} On sélectionne la valeur dans le select (manuellement) de la PROFESSION */ - var selectedOption = $('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+objectData.job+'"]'); - if( selectedOption != null ) - selectedOption.setAttribute('selected', 'selected'); + /* {6} On sélectionne la valeur dans le select (manuellement) de la PROFESSION */ + var selectedOption = $('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+objectData.job+'"]'); + if( selectedOption != null ) + selectedOption.setAttribute('selected', 'selected'); - /* {7} On sélectionne la valeur dans le select (manuellement) des ETUDES */ - selectedOption = $('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+objectData.studies+'"]'); - if( selectedOption != null ) - selectedOption.setAttribute('selected', 'selected'); + /* {7} On sélectionne la valeur dans le select (manuellement) des ETUDES */ + selectedOption = $('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+objectData.studies+'"]'); + if( selectedOption != null ) + selectedOption.setAttribute('selected', 'selected'); - /* {8} On sélectionne la valeur dans le select (manuellement) de l'AGE */ - selectedOption = $('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+objectData.age+'"]'); - if( selectedOption != null ) - selectedOption.setAttribute('selected', 'selected'); + /* {8} On sélectionne la valeur dans le select (manuellement) de l'AGE */ + selectedOption = $('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+objectData.age+'"]'); + if( selectedOption != null ) + selectedOption.setAttribute('selected', 'selected'); - /* {9} On sélectionna la valeur des boutons pour le SEXE */ - var sexeCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'); - for( var i = 0 ; i < sexeCreated.length ; i++ ) - if( sexeCreated[i].value == objectData.sexe ) sexeCreated[i].setAttribute('checked', 'checked'); - else sexeCreated[i].removeAttribute('checked'); + /* {9} On sélectionna la valeur des boutons pour le SEXE */ + var sexeCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'); + for( var i = 0 ; i < sexeCreated.length ; i++ ) + if( sexeCreated[i].value == objectData.sexe ) sexeCreated[i].setAttribute('checked', 'checked'); + else sexeCreated[i].removeAttribute('checked'); - /* {10} On sélectionna la valeur des boutons pour la SITUATION FAMILIALE */ - var famsitCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]'); - for( var i = 0 ; i < famsitCreated.length ; i++ ) - if( famsitCreated[i].value == objectData.famsit ) famsitCreated[i].setAttribute('checked', 'checked'); - else famsitCreated[i].removeAttribute('checked'); + /* {10} On sélectionna la valeur des boutons pour la SITUATION FAMILIALE */ + var famsitCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]'); + for( var i = 0 ; i < famsitCreated.length ; i++ ) + if( famsitCreated[i].value == objectData.famsit ) famsitCreated[i].setAttribute('checked', 'checked'); + else famsitCreated[i].removeAttribute('checked'); - /* {11} On sélectionna la valeur des boutons pour le TYPE DE RELATION */ - var reltypeCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]'); - for( var i = 0 ; i < reltypeCreated.length ; i++ ) - if( reltypeCreated[i].value == objectData.reltype ) reltypeCreated[i].setAttribute('checked', 'checked'); - else reltypeCreated[i].removeAttribute('checked'); + /* {11} On sélectionna la valeur des boutons pour le TYPE DE RELATION */ + var reltypeCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]'); + for( var i = 0 ; i < reltypeCreated.length ; i++ ) + if( reltypeCreated[i].value == objectData.reltype ) reltypeCreated[i].setAttribute('checked', 'checked'); + else reltypeCreated[i].removeAttribute('checked'); - /* {12} On sélectionna la valeur des boutons pour la LOCATION */ - var locCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]'); - for( var i = 0 ; i < locCreated.length ; i++ ) - if( locCreated[i].value == objectData.loc ) locCreated[i].setAttribute('checked', 'checked'); - else locCreated[i].removeAttribute('checked'); + /* {12} On sélectionna la valeur des boutons pour la LOCATION */ + var locCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]'); + for( var i = 0 ; i < locCreated.length ; i++ ) + if( locCreated[i].value == objectData.loc ) locCreated[i].setAttribute('checked', 'checked'); + else locCreated[i].removeAttribute('checked'); - /* {13} On sélectionna la valeur des boutons pour le CONTEXTE DE RENCONTRE */ - var contextCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="context"]'); - for( var i = 0 ; i < contextCreated.length ; i++ ) - if( contextCreated[i].value == objectData.context ) contextCreated[i].setAttribute('checked', 'checked'); - else contextCreated[i].removeAttribute('checked'); + /* {13} On sélectionna la valeur des boutons pour le CONTEXTE DE RENCONTRE */ + var contextCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="context"]'); + for( var i = 0 ; i < contextCreated.length ; i++ ) + if( contextCreated[i].value == objectData.context ) contextCreated[i].setAttribute('checked', 'checked'); + else contextCreated[i].removeAttribute('checked'); - /* {14} On sélectionna la valeur des boutons pour les FREQUENCES */ - var freqCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="freq"]'); - for( var i = 0 ; i < freqCreated.length ; i++ ) - if( objectData.freq.indexOf(freqCreated[i].value) > -1 ) freqCreated[i].setAttribute('checked', 'checked'); - else freqCreated[i].removeAttribute('checked'); + /* {14} On sélectionna la valeur des boutons pour les FREQUENCES */ + var freqCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="freq"]'); + for( var i = 0 ; i < freqCreated.length ; i++ ) + if( objectData.freq.indexOf(freqCreated[i].value) > -1 ) freqCreated[i].setAttribute('checked', 'checked'); + else freqCreated[i].removeAttribute('checked'); - /* {15} On sélectionna la valeur des boutons pour les CONNECTIONS */ - var connectCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="connect"]'); - for( var i = 0 ; i < connectCreated.length ; i++ ) - if( objectData.connect.indexOf(connectCreated[i].value) > -1 ) connectCreated[i].setAttribute('checked', 'checked'); - else connectCreated[i].removeAttribute('checked'); + /* {15} On sélectionna la valeur des boutons pour les CONNECTIONS */ + var connectCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="connect"]'); + for( var i = 0 ; i < connectCreated.length ; i++ ) + if( objectData.connect.indexOf(connectCreated[i].value) > -1 ) connectCreated[i].setAttribute('checked', 'checked'); + else connectCreated[i].removeAttribute('checked'); @@ -270,21 +270,21 @@ inputPhoneFiche.prototype.add = function(objectData){ /* [4] Gestion de l'affichage depuis le 'localStorage' =========================================================*/ inputPhoneFiche.prototype.storageToFields = function(){ - console.log('FICHE: STORAGE TO FIELDS'); + console.log('FICHE: STORAGE TO FIELDS'); - // {1} Pour chaque contact du 'localStorage' // - var ficheData = lsi.export('fiches'); + // {1} Pour chaque contact du 'localStorage' // + var ficheData = lsi.export('fiches'); - // On réinitialise le HTML - this.container.innerHTML = ''; + // On réinitialise le HTML + this.container.innerHTML = ''; - for( var key in ficheData ) - if( ficheData[key].uid == this.selected ) - this.add(ficheData[key]); + for( var key in ficheData ) + if( ficheData[key].uid == this.selected ) + this.add(ficheData[key]); - // {4} On met à jour la navigation // - this.updateNavBar(); + // {4} On met à jour la navigation // + this.updateNavBar(); }; @@ -301,137 +301,137 @@ inputPhoneFiche.prototype.storageToFields = function(){ /* [5] Synchronisation des CONTACT vers les MINI fiches =========================================================*/ inputPhoneFiche.prototype.sync = function(){ - console.log('FICHE: SYNC'); + console.log('FICHE: SYNC'); - /* (1) Mise à jour en fonction des contacts APRÈS IMPORT - ---------------------------------------------------------*/ - /* (1) On récupère tous les CONTACTS */ - var contacts = lsi.export('contacts'); - var addedFicheUids = []; // Contiendra les uids des fiches qui seront crées + /* (1) Mise à jour en fonction des contacts APRÈS IMPORT + ---------------------------------------------------------*/ + /* (1) On récupère tous les CONTACTS */ + var contacts = lsi.export('contacts'); + var addedFicheUids = []; // Contiendra les uids des fiches qui seront crées - /* (2) Pour chaque CONTACT, on met à jour/crée la FICHE associée, si dans le TOP 10 des APPELS ou des SMS */ - for( var uid in contacts ){ + /* (2) Pour chaque CONTACT, on met à jour/crée la FICHE associée, si dans le TOP 10 des APPELS ou des SMS */ + for( var uid in contacts ){ - var inCallTop10 = false; + var inCallTop10 = false; - /* (3) Indice de 0 à 9 si dans le TOP 10 des APPELS */ - if( contacts[uid].call > -1 ){ - // On calcule le rang de la fiche en fonction du classement - var ficheIndex = contacts[uid].call; - addedFicheUids.push(ficheIndex); + /* (3) Indice de 0 à 9 si dans le TOP 10 des APPELS */ + if( contacts[uid].call > -1 ){ + // On calcule le rang de la fiche en fonction du classement + var ficheIndex = contacts[uid].call; + addedFicheUids.push(ficheIndex); - // On récupère les informations de la FICHE (si elle existe) */ - var ficheData = lsi.get('fiches', ficheIndex); + // On récupère les informations de la FICHE (si elle existe) */ + var ficheData = lsi.get('fiches', ficheIndex); - // Si la fiche n'existe pas, on la crée avec les valeurs par défaut - if( ficheData == null ) - ficheData = this.defaultData; + // Si la fiche n'existe pas, on la crée avec les valeurs par défaut + if( ficheData == null ) + ficheData = this.defaultData; - // On met à jour la fiche ET on l'enregistre - ficheData.uid = ficheIndex; - ficheData.contact = parseInt(uid); - lsi.set('fiches', ficheIndex, ficheData); - } + // On met à jour la fiche ET on l'enregistre + ficheData.uid = ficheIndex; + ficheData.contact = parseInt(uid); + lsi.set('fiches', ficheIndex, ficheData); + } - /* (4) Indice de 10 à 19 si dans le TOP 10 des SMS */ - if( contacts[uid].sms > -1 ){ - // On calcule le rang de la fiche en fonction du classement - var ficheIndex = 10+contacts[uid].sms; - addedFicheUids.push(ficheIndex); + /* (4) Indice de 10 à 19 si dans le TOP 10 des SMS */ + if( contacts[uid].sms > -1 ){ + // On calcule le rang de la fiche en fonction du classement + var ficheIndex = 10+contacts[uid].sms; + addedFicheUids.push(ficheIndex); - // On récupère les informations de la FICHE (si elle existe) */ - var ficheData = lsi.get('fiches', ficheIndex); + // On récupère les informations de la FICHE (si elle existe) */ + var ficheData = lsi.get('fiches', ficheIndex); - // Si la fiche n'existe pas, on la crée avec les valeurs par défaut - if( ficheData == null ) - ficheData = this.defaultData; + // Si la fiche n'existe pas, on la crée avec les valeurs par défaut + if( ficheData == null ) + ficheData = this.defaultData; - // On met à jour la fiche ET on l'enregistre - ficheData.uid = ficheIndex; - ficheData.contact = parseInt(uid); - lsi.set('fiches', ficheIndex, ficheData); + // On met à jour la fiche ET on l'enregistre + ficheData.uid = ficheIndex; + ficheData.contact = parseInt(uid); + lsi.set('fiches', ficheIndex, ficheData); - } + } - } + } - /* (2) Mise à jour en fonction des contacts APRÈS SAISIE MANUELLE - ---------------------------------------------------------*/ - // Nombre maximum de fiches (20, sauf si moins de 20 contacts, dans ce cas, le nombre de contacts); - var nbMaxFiche = lsi.keys('contacts').length < 20 ? lsi.keys('contacts').length : 20; + /* (2) Mise à jour en fonction des contacts APRÈS SAISIE MANUELLE + ---------------------------------------------------------*/ + // Nombre maximum de fiches (20, sauf si moins de 20 contacts, dans ce cas, le nombre de contacts); + var nbMaxFiche = lsi.keys('contacts').length < 20 ? lsi.keys('contacts').length : 20; - // Si moins de 10+10 contacts crées, on les complètes en fonction des contacts séquentiellement - if( addedFicheUids.length < nbMaxFiche ){ + // Si moins de 10+10 contacts crées, on les complètes en fonction des contacts séquentiellement + if( addedFicheUids.length < nbMaxFiche ){ - /* (1) Pour chaque CONTACT, on met à jour/crée la FICHE associée*/ - for( var uid in contacts ){ + /* (1) Pour chaque CONTACT, on met à jour/crée la FICHE associée*/ + for( var uid in contacts ){ - /* (2) On cherche un uid de fiche non existant dans l'intervalle 0-19 */ - var ficheUid = 0; - while( addedFicheUids.indexOf(ficheUid) > -1 && ficheUid < nbMaxFiche ) - ficheUid++; + /* (2) On cherche un uid de fiche non existant dans l'intervalle 0-19 */ + var ficheUid = 0; + while( addedFicheUids.indexOf(ficheUid) > -1 && ficheUid < nbMaxFiche ) + ficheUid++; - // On enregistre le nouvel UID dans les uid crées - addedFicheUids.push(ficheUid); + // On enregistre le nouvel UID dans les uid crées + addedFicheUids.push(ficheUid); - /* (3) On récupère les informations de la FICHE (si elle existe) */ - var ficheData = lsi.get('fiches', ficheUid); + /* (3) On récupère les informations de la FICHE (si elle existe) */ + var ficheData = lsi.get('fiches', ficheUid); - // Si la fiche n'existe pas, on la crée avec les valeurs par défaut - if( ficheData == null ) - ficheData = this.defaultData; + // Si la fiche n'existe pas, on la crée avec les valeurs par défaut + if( ficheData == null ) + ficheData = this.defaultData; - /* (4) On met à jour la fiche ET on l'enregistre */ - ficheData.uid = ficheUid; - ficheData.contact = parseInt(uid); - lsi.set('fiches', ficheUid, ficheData); + /* (4) On met à jour la fiche ET on l'enregistre */ + ficheData.uid = ficheUid; + ficheData.contact = parseInt(uid); + lsi.set('fiches', ficheUid, ficheData); - /* (5) Si on a déja crée 10+10 fiches, on arrête */ - if( addedFicheUids.length >= nbMaxFiche ) - break; - } + /* (5) Si on a déja crée 10+10 fiches, on arrête */ + if( addedFicheUids.length >= nbMaxFiche ) + break; + } - } + } - /* (3) Mise à jour des fiches dupliquées entre le top 10 des APPELS et celui des SMS - ---------------------------------------------------------*/ - for( var key in ficheData ){ - /* (1) On récupère le contact associé */ - var associatedContact = lsi.get('contacts', ficheData[key].contact); + /* (3) Mise à jour des fiches dupliquées entre le top 10 des APPELS et celui des SMS + ---------------------------------------------------------*/ + for( var key in ficheData ){ + /* (1) On récupère le contact associé */ + var associatedContact = lsi.get('contacts', ficheData[key].contact); - // Si erreur, on passe au suivant - if( associatedContact == null ) - continue; + // Si erreur, on passe au suivant + if( associatedContact == null ) + continue; - /* (2) Si la fiche n'est pas dans les 2 top 10 (APPELS et SMS) */ - if( associatedContact.sms == -1 || associatedContact.call == -1 ) - continue; // On passe au suivant + /* (2) Si la fiche n'est pas dans les 2 top 10 (APPELS et SMS) */ + if( associatedContact.sms == -1 || associatedContact.call == -1 ) + continue; // On passe au suivant - /* (3) On récupère l'autre fiche (clone) */ - var inCall = parseInt(key) < 10; // Si on est dans le top 10 des APPELS, sinon dans celui des SMS - var cloneIndex = inCall ? 10+associatedContact.sms : associatedContact.call; // Contient l'index du clone dans l'autre top (APPELS ou SMS) + /* (3) On récupère l'autre fiche (clone) */ + var inCall = parseInt(key) < 10; // Si on est dans le top 10 des APPELS, sinon dans celui des SMS + var cloneIndex = inCall ? 10+associatedContact.sms : associatedContact.call; // Contient l'index du clone dans l'autre top (APPELS ou SMS) - var clone = ficheData[cloneIndex]; + var clone = ficheData[cloneIndex]; - /* (4) Si le clone a été modifié en dernier, on ne fait rien */ - if( clone.timestamp >= ficheData[key].timestamp ) - continue; + /* (4) Si le clone a été modifié en dernier, on ne fait rien */ + if( clone.timestamp >= ficheData[key].timestamp ) + continue; - /* (5) On copie les données de la FICHE dans le clone (cas ou la fiche est modifiée en dernier) */ - var obj = ficheData[key]; - obj.uid = clone.uid; - lsi.set('fiches', clone.uid, obj); + /* (5) On copie les données de la FICHE dans le clone (cas ou la fiche est modifiée en dernier) */ + var obj = ficheData[key]; + obj.uid = clone.uid; + lsi.set('fiches', clone.uid, obj); - } + } }; @@ -444,21 +444,21 @@ inputPhoneFiche.prototype.sync = function(){ /* [6] Gestion de la navigation entre les fiches =========================================================*/ inputPhoneFiche.prototype.nav = function(element){ - /* (1) On vérifie que l'élément contient un nombre et existe */ - if( element == null ) - return false; + /* (1) On vérifie que l'élément contient un nombre et existe */ + if( element == null ) + return false; - if( element.getData('n') === false || isNaN(element.getData('n')) || element.parentNode.id != 'nav-fiche' ) - return false; + if( element.getData('n') === false || isNaN(element.getData('n')) || element.parentNode.id != 'nav-fiche' ) + return false; - /* (2) On désactive tous les éléments actifs */ - var activeElements = $$('#nav-fiche > span.active'); - for( var i = 0 ; i < activeElements.length ; i++ ) - activeElements[i].remClass('active'); + /* (2) On désactive tous les éléments actifs */ + var activeElements = $$('[data-sublink="phone"] #p_nav-fiche > span.active'); + for( var i = 0 ; i < activeElements.length ; i++ ) + activeElements[i].remClass('active'); - /* (3) On active l'élément courant */ - element.addClass('active'); - this.selected = parseInt(element.getData('n')); + /* (3) On active l'élément courant */ + element.addClass('active'); + this.selected = parseInt(element.getData('n')); }; @@ -471,55 +471,55 @@ inputPhoneFiche.prototype.nav = function(element){ /* [7] Mise à jour de la navigation =========================================================*/ inputPhoneFiche.prototype.updateNavBar = function(){ - var ficheData = lsi.export('fiches'); + var ficheData = lsi.export('fiches'); - /* (2) On vide et remplit la barre de nav, si elle n'est pas à jour */ - this.nav_container.innerHTML = ''; + /* (2) On vide et remplit la barre de nav, si elle n'est pas à jour */ + this.nav_container.innerHTML = ''; - var keys = Object.keys(ficheData); - for( var k = 0 ; k < keys.length ; k++ ){ - var i = parseInt( keys[k] ); + var keys = Object.keys(ficheData); + for( var k = 0 ; k < keys.length ; k++ ){ + var i = parseInt( keys[k] ); - // Si 1ère valeur du top 10 des APPELS, on ajoute le bandeau "APPELS" - if( i == 0 ) - this.nav_container.innerHTML += 'APPELS'; + // Si 1ère valeur du top 10 des APPELS, on ajoute le bandeau "APPELS" + if( i == 0 ) + this.nav_container.innerHTML += 'APPELS'; - // Si fin du top 10 des APPELS, on met un espace et un border-right - if( i < 10 && k < keys.length-1 && keys[k+1] >= 10 ) - this.nav_container.innerHTML += ''+(i%10 + 1)+'  '; + // Si fin du top 10 des APPELS, on met un espace et un border-right + if( i < 10 && k < keys.length-1 && keys[k+1] >= 10 ) + this.nav_container.innerHTML += ''+(i%10 + 1)+'  '; - // Si début du top 10 des SMS, on met le label 'SMS' et un border-left - else if( i == 10 ){ - this.nav_container.innerHTML += 'SMS'; - this.nav_container.innerHTML += ''+(i%10 + 1)+''; + // Si début du top 10 des SMS, on met le label 'SMS' et un border-left + else if( i == 10 ){ + this.nav_container.innerHTML += 'SMS'; + this.nav_container.innerHTML += ''+(i%10 + 1)+''; - // Sinon, on ajoute juste le bouton - }else - this.nav_container.innerHTML += ''+(i%10 + 1)+''; - } + // Sinon, on ajoute juste le bouton + }else + this.nav_container.innerHTML += ''+(i%10 + 1)+''; + } - /* (3) On montre les FICHES qui sont correctes */ - for( var key in ficheData ){ + /* (3) On montre les FICHES qui sont correctes */ + for( var key in ficheData ){ - var currentElement = $('#nav-fiche [data-n="'+ficheData[key].uid+'"]'); + var currentElement = $('[data-sublink="phone"] #p_nav-fiche [data-n="'+ficheData[key].uid+'"]'); - if( currentElement == null ) - continue; + if( currentElement == null ) + continue; - // Si on ne trouve pas le bouton + // Si on ne trouve pas le bouton - // Si la FICHE est valide - if( ficheData[key].valid === true ) currentElement.addClass('done'); - // Si elle est invalide - else currentElement.remClass('done'); + // Si la FICHE est valide + if( ficheData[key].valid === true ) currentElement.addClass('done'); + // Si elle est invalide + else currentElement.remClass('done'); - } + } - /* (4) On séléctionne par défaut le dernier sélectionné */ - this.nav( $('#nav-fiche [data-n="'+this.selected+'"]') ); + /* (4) On séléctionne par défaut le dernier sélectionné */ + this.nav( $('[data-sublink="phone"] #p_nav-fiche [data-n="'+this.selected+'"]') ); }; @@ -529,76 +529,76 @@ inputPhoneFiche.prototype.updateNavBar = function(){ =========================================================*/ inputPhoneFiche.prototype.check = function(ficheData){ - // {1} Vérification des // - // 1. La ville a au moins 2 caractères - if( ficheData.city.length < 2 ) - return false; - // 3. La durée de la relation en mois est vide ou un nombre - if( isNaN(parseInt(ficheData.duration[0])) && ficheData.duration[0].length > 0 ) - return false; - // 4. La durée de la relation en année est vide ou un nombre - if( isNaN(parseInt(ficheData.duration[1])) && ficheData.duration[1].length > 0 ) - return false; - // 5. Pour la durée de la relation, au moins un des 2 n'est pas vide - if( ficheData.duration[0].length+ficheData.duration[1].length == 0 ) - return false; + // {1} Vérification des // + // 1. La ville a au moins 2 caractères + if( ficheData.city.length < 2 ) + return false; + // 3. La durée de la relation en mois est vide ou un nombre + if( isNaN(parseInt(ficheData.duration[0])) && ficheData.duration[0].length > 0 ) + return false; + // 4. La durée de la relation en année est vide ou un nombre + if( isNaN(parseInt(ficheData.duration[1])) && ficheData.duration[1].length > 0 ) + return false; + // 5. Pour la durée de la relation, au moins un des 2 n'est pas vide + if( ficheData.duration[0].length+ficheData.duration[1].length == 0 ) + return false; - // {2} Vérification des pour la profession n'est pas indéfini - if( ficheData.job == '.' ) - return false; - // 7. Le pour l'AGE n'est pas indéfini - if( ficheData.age == '.' ) - return false; + // {2} Vérification des pour la profession n'est pas indéfini + if( ficheData.job == '.' ) + return false; + // 7. Le pour l'AGE n'est pas indéfini + if( ficheData.age == '.' ) + return false; - // {3} Vérification des radio // - // 9. Le SEXE a un et un seul choix - if( ficheData.sexe == '' ) - return false; - // 10. La SITUATION FAMILIALE a un et un seul choix - if( ficheData.famsit == '' ) - return false; - // 11. Le TYPE DE RELATION a un et un seul choix - if( ficheData.reltype == '' ) - return false; - // 12. La DISTANCE DE DOMICILE (location) a un et un seul choix - if( ficheData.loc == '' ) - return false; - // 13. Le CONTEXTE DE RENCONTRE a un et un seul choix - if( ficheData.context == '' ) - return false; - // 14. Les FRÉQUENCES ont un et un seul choix (par question de fréquence) - for( var i = 0 ; i < ficheData.freq.length ; i++ ) - if( ficheData.freq[i] == '' ) - return false; - // 15. Les CONNECTION ont un et un seul choix (par question de connection) - for( var i = 0 ; i < ficheData.connect.length ; i++ ) - if( ficheData.connect[i] == '' ) - return false; + // {3} Vérification des radio // + // 9. Le SEXE a un et un seul choix + if( ficheData.sexe == '' ) + return false; + // 10. La SITUATION FAMILIALE a un et un seul choix + if( ficheData.famsit == '' ) + return false; + // 11. Le TYPE DE RELATION a un et un seul choix + if( ficheData.reltype == '' ) + return false; + // 12. La DISTANCE DE DOMICILE (location) a un et un seul choix + if( ficheData.loc == '' ) + return false; + // 13. Le CONTEXTE DE RENCONTRE a un et un seul choix + if( ficheData.context == '' ) + return false; + // 14. Les FRÉQUENCES ont un et un seul choix (par question de fréquence) + for( var i = 0 ; i < ficheData.freq.length ; i++ ) + if( ficheData.freq[i] == '' ) + return false; + // 15. Les CONNECTION ont un et un seul choix (par question de connection) + for( var i = 0 ; i < ficheData.connect.length ; i++ ) + if( ficheData.connect[i] == '' ) + return false; - // {4} dépendant d'un choix d'un radio // - // 16. TYPE DE RELATION si autre est coché (indice 8), reltypeSpecial doit avoir au moins 2 caractère - if( ficheData.reltype == '10' && ficheData.reltypeSpecial.length < 2 ) - return false; - // 17. CONTEXTE DE RELATION si est coché indice 11, contactSpecial[0] doit avoir au moins 2 caractères - if( ficheData.context == '11' && ficheData.contextSpecial[0].length < 2 ) - return false; + // {4} dépendant d'un choix d'un radio // + // 16. TYPE DE RELATION si autre est coché (indice 8), reltypeSpecial doit avoir au moins 2 caractère + if( ficheData.reltype == '10' && ficheData.reltypeSpecial.length < 2 ) + return false; + // 17. CONTEXTE DE RELATION si est coché indice 11, contactSpecial[0] doit avoir au moins 2 caractères + if( ficheData.context == '11' && ficheData.contextSpecial[0].length < 2 ) + return false; - // 18. CONTEXTE DE RELATION si est coché indice 12, contextSpecial[1] doit avoir au moins 2 caractères - if( ficheData.context == '12' && ficheData.contextSpecial[1].length < 2 ) - return false; + // 18. CONTEXTE DE RELATION si est coché indice 12, contextSpecial[1] doit avoir au moins 2 caractères + if( ficheData.context == '12' && ficheData.contextSpecial[1].length < 2 ) + return false; - // 19. CONTEXTE DE RELATION si est coché indice 13, contextSpecial[2] doit avoir au moins 2 caractères - if( ficheData.context == '13' && ficheData.contextSpecial[2].length < 2 ) - return false; + // 19. CONTEXTE DE RELATION si est coché indice 13, contextSpecial[2] doit avoir au moins 2 caractères + if( ficheData.context == '13' && ficheData.contextSpecial[2].length < 2 ) + return false; - // 20. Si tout s'est bien passé, on retourne TRUE - return true; + // 20. Si tout s'est bien passé, on retourne TRUE + return true; }; @@ -608,26 +608,26 @@ inputPhoneFiche.prototype.check = function(ficheData){ /* [9] Point d'amorçage de la gestion des contacts =========================================================*/ inputPhoneFiche.prototype.attach = function(handler){ - console.log('FICHE: ATTACH'); + console.log('FICHE: ATTACH'); - /* (1) On initialise le jeu de données */ - lsi.createDataset('fiches'); + /* (1) On initialise le jeu de données */ + lsi.createDataset('fiches'); - /* (2) On charge les fiche fiches depuis la mémoire ('localStorage') */ - this.storageToFields(); + /* (2) On charge les fiche fiches depuis la mémoire ('localStorage') */ + this.storageToFields(); - /* (3) On attache la barre de navigation à une fonction */ - // On enregistre le handler - this.handler = handler; - var ptr = this; + /* (3) On attache la barre de navigation à une fonction */ + // On enregistre le handler + this.handler = handler; + var ptr = this; - /* (2) On attache l'évènement sur le bouton d'ajout de contact */ - var ptr = this; - this.nav_container.addEventListener('click', function(e){ - // 1. On gère la navigation - ptr.nav(e.target); - // 2. On gere le chargement dynamique - ptr.handler(e.target); - }, false); + /* (2) On attache l'évènement sur le bouton d'ajout de contact */ + var ptr = this; + this.nav_container.addEventListener('click', function(e){ + // 1. On gère la navigation + ptr.nav(e.target); + // 2. On gere le chargement dynamique + ptr.handler(e.target); + }, false); }; diff --git a/js/includes/input-phone-mini-min.js b/js/includes/input-phone-mini-min.js index 74ee89c..0cb7101 100644 --- a/js/includes/input-phone-mini-min.js +++ b/js/includes/input-phone-mini-min.js @@ -1,11 +1,12 @@ function inputPhoneMini(a,b){this.container=a;this.nav_container=b}inputPhoneMini.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{sexe:"0",age:".",studies:".",loc:"0",reltype:"0",reltypeSpecial:"",timestamp:0,valid:!1}}; -inputPhoneMini.prototype.fieldsToStorage=function(){console.log("MINI FICHE: FIELDS TO STORAGE");for(var a=$$("article.mini-relation-panel .mini-fiche-relation"),b=0;b MINI UPDATE");c={uid:parseInt(c.uid),sexe:c.sexe,age:c.age,studies:c.studies,reltype:c.reltype,reltypeSpecial:c.reltypeSpecial, -loc:c.loc,hash:e};c.valid=this.check(c);0 FICHE UPDATE"),c.timestamp=Date.now());lsi.set("mini-fiches",c.uid,c)}}}; +inputPhoneMini.prototype.fieldsToStorage=function(){console.log("MINI FICHE: FIELDS TO STORAGE");for(var a=$$('[data-sublink="phone"] article.mini-relation-panel .mini-fiche-relation'),b=0;b MINI UPDATE");c={uid:parseInt(c.uid),sexe:c.sexe,age:c.age,studies:c.studies,reltype:c.reltype, +reltypeSpecial:c.reltypeSpecial,loc:c.loc,hash:e};c.valid=this.check(c);0 FICHE UPDATE"),c.timestamp=Date.now());lsi.set("mini-fiches",c.uid,c)}}}; inputPhoneMini.prototype.add=function(a){console.log("MINI FICHE: ADD");if(null==a||null==a.uid)return!1;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.studies=null!=a.studies?a.studies:this.defaultData.studies;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;a.loc=null!=a.loc?a.loc:this.defaultData.loc;var b=lsi.get("contacts",a.uid);if(!1===b)return!1; -this.container.innerHTML+=miniFicheBuilder.build({name:readableName(b.username,b.firstname,b.lastname),countcall:b.countcall,countsms:b.countsms,uid:a.uid,reltypespecial:a.reltypeSpecial});b=$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=b&&b.setAttribute("selected","selected");b=$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+ -a.age+'"]');null!=b&&b.setAttribute("selected","selected");for(var c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;binput[type="radio"][data-name="reltype"]');for(b=0;binput[type="radio"][data-name="loc"]');for(b=0;bspan>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=b&&b.setAttribute("selected","selected");b=$('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+ +a.age+'"]');null!=b&&b.setAttribute("selected","selected");for(var c=$$('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;binput[type="radio"][data-name="reltype"]');for(b=0;binput[type="radio"][data-name="loc"]');for(b=0;b span.active"),c=0;c'+ ++b+"");for(c in a)isNaN(c)||(b=$('#nav-mini [data-n="'+a[c].uid+'"]'),null!=b&&(!0===a[c].valid?b.addClass("done"):b.remClass("done")));this.nav($('#nav-mini [data-n="'+this.selected+'"]'))}; +if(null==e[this.selected])for(d in e)if(!isNaN(d)){this.selected=parseInt(d);break}};inputPhoneMini.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"nav-mini"!=a.parentNode.id)return!1;for(var b=$$('[data-sublink="phone"] #p_nav-mini > span.active'),c=0;c'+ ++b+"");for(c in a)isNaN(c)||(b=$('[data-sublink="phone"] #p_nav-mini [data-n="'+a[c].uid+'"]'),null!=b&&(!0===a[c].valid?b.addClass("done"):b.remClass("done")));this.nav($('[data-sublink="phone"] #p_nav-mini [data-n="'+this.selected+'"]'))}; inputPhoneMini.prototype.check=function(a){return""==a.sexe||"."==a.studies||"."==a.age||""==a.loc||""==a.reltype||"10"==a.reltype&&2>a.reltypeSpecial.length?!1:!0};inputPhoneMini.prototype.attach=function(a){console.log("MINI FICHE: ATTACH");lsi.createDataset("mini-fiches");this.storageToFields();this.handler=a;var b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)}; diff --git a/js/includes/input-phone-mini.js b/js/includes/input-phone-mini.js index c1c3faa..9146b9c 100644 --- a/js/includes/input-phone-mini.js +++ b/js/includes/input-phone-mini.js @@ -1,92 +1,92 @@ /* [0] Constructeur -> définit le conteneur et le bouton d'ajout =========================================================*/ function inputPhoneMini(container, navContainer){ - this.container = container; - this.nav_container = navContainer; + this.container = container; + this.nav_container = navContainer; } /* [1] Attributs =========================================================*/ inputPhoneMini.prototype = { - container: this.container, // Conteneur des mini fiches relation - nav_container: this.nav_container, // Conteneur de la navigation entre les MINI fiches - selected: 0, // UID de la MINI fiche sélectionnée - handler: null, // Fonction pour l'enregistrement et la synchronisation des données - defaultData: { // Valeur par défaut - sexe: '0', - age: '.', - studies: '.', - loc: '0', - reltype: '0', - reltypeSpecial: '', - timestamp: 0, - valid: false - } + container: this.container, // Conteneur des mini fiches relation + nav_container: this.nav_container, // Conteneur de la navigation entre les MINI fiches + selected: 0, // UID de la MINI fiche sélectionnée + handler: null, // Fonction pour l'enregistrement et la synchronisation des données + defaultData: { // Valeur par défaut + sexe: '0', + age: '.', + studies: '.', + loc: '0', + reltype: '0', + reltypeSpecial: '', + timestamp: 0, + valid: false + } }; /* [2] Gestion de l'enregistrement des formulaires mini fiches relation =========================================================*/ inputPhoneMini.prototype.fieldsToStorage = function(){ - console.log('MINI FICHE: FIELDS TO STORAGE'); + console.log('MINI FICHE: FIELDS TO STORAGE'); - // {1} Pour chaque formulaire de MINI fiche à l'écran // - var existingMiniFiches = $$('article.mini-relation-panel .mini-fiche-relation'); - for( var i = 0 ; i < existingMiniFiches.length ; i++ ){ - // {2} On initialise notre deflater pour récupérer les valeurs // - var deflater = new FormDeflater(existingMiniFiches[i], ['input', 'select'], ['data-name']); + // {1} Pour chaque formulaire de MINI fiche à l'écran // + var existingMiniFiches = $$('[data-sublink="phone"] article.mini-relation-panel .mini-fiche-relation'); + for( var i = 0 ; i < existingMiniFiches.length ; i++ ){ + // {2} On initialise notre deflater pour récupérer les valeurs // + var deflater = new FormDeflater(existingMiniFiches[i], ['input', 'select'], ['data-name']); - // {3} On enregistre ce contact si le numéro n'est pas vide et soit pseudo/prénom/nom // - var deflated = deflater.deflate(); - // On crée le hash - var deflatedHash = crc32(JSON.stringify(deflated)); + // {3} On enregistre ce contact si le numéro n'est pas vide et soit pseudo/prénom/nom // + var deflated = deflater.deflate(); + // On crée le hash + var deflatedHash = crc32(JSON.stringify(deflated)); - // console.log(deflated); + // console.log(deflated); - // {4} On récupère les données du LSI si elles existent // - var existingData = lsi.get('mini-fiches', deflated.uid); + // {4} On récupère les données du LSI si elles existent // + var existingData = lsi.get('mini-fiches', deflated.uid); - // Si n'existe pas, on passe à la suivante - if( existingData === false ) - continue; + // Si n'existe pas, on passe à la suivante + if( existingData === false ) + continue; - // {5} On récupère et met en forme les valeurs du deflater // - // Si le hash est le même, on ne fait rien - if( existingData != null && existingData.hash != null && existingData.hash == deflatedHash ) - return; + // {5} On récupère et met en forme les valeurs du deflater // + // Si le hash est le même, on ne fait rien + if( existingData != null && existingData.hash != null && existingData.hash == deflatedHash ) + return; - console.warn('> MINI UPDATE'); + console.warn('> MINI UPDATE'); - var obj = { - uid: parseInt(deflated.uid), - sexe: deflated.sexe, // [0] Homme, [1] Femme - age: deflated.age, - studies: deflated.studies, - reltype: deflated.reltype, // [0] ... - reltypeSpecial: deflated.reltypeSpecial, - loc: deflated.loc, // [0] Choix 1 -> [3] Choix 4 - hash: deflatedHash - }; + var obj = { + uid: parseInt(deflated.uid), + sexe: deflated.sexe, // [0] Homme, [1] Femme + age: deflated.age, + studies: deflated.studies, + reltype: deflated.reltype, // [0] ... + reltypeSpecial: deflated.reltypeSpecial, + loc: deflated.loc, // [0] Choix 1 -> [3] Choix 4 + hash: deflatedHash + }; - /* (8) On vérifie la validité des données et on l'enregistre dans l'objet avec la date de modification */ - obj.valid = this.check(obj); + /* (8) On vérifie la validité des données et on l'enregistre dans l'objet avec la date de modification */ + obj.valid = this.check(obj); - // On met à jour la date de modification, si on a pas qu'@uid de différent - if( diff(existingData, obj, ['hash', 'valid', 'timestamp']).length > 0 ){ - console.log( diff(existingData, obj, ['hash', 'valid', 'timestamp']) ); - console.warn('> FICHE UPDATE'); - obj.timestamp = Date.now(); - } + // On met à jour la date de modification, si on a pas qu'@uid de différent + if( diff(existingData, obj, ['hash', 'valid', 'timestamp']).length > 0 ){ + console.log( diff(existingData, obj, ['hash', 'valid', 'timestamp']) ); + console.warn('> FICHE UPDATE'); + obj.timestamp = Date.now(); + } - /* (9) On enregistre les données dans le 'localStorage' */ - lsi.set('mini-fiches', obj.uid, obj); + /* (9) On enregistre les données dans le 'localStorage' */ + lsi.set('mini-fiches', obj.uid, obj); - } + } }; @@ -105,66 +105,66 @@ inputPhoneMini.prototype.fieldsToStorage = function(){ * */ inputPhoneMini.prototype.add = function(objectData){ - console.log('MINI FICHE: ADD'); + console.log('MINI FICHE: ADD'); - // Si pas d'UID, on retourne une erreur - if( objectData == null || objectData.uid == null ) - return false; + // Si pas d'UID, on retourne une erreur + if( objectData == null || objectData.uid == null ) + return false; - /* (0) Gestion du formattage des valeur */ - objectData.age = (objectData.age != null) ? objectData.age : this.defaultData.age; - objectData.sexe = (objectData.sexe != null) ? objectData.sexe : this.defaultData.sexe; - objectData.studies = (objectData.studies != null) ? objectData.studies : this.defaultData.studies; - objectData.reltype = (objectData.reltype != null) ? objectData.reltype : this.defaultData.reltype; - objectData.reltypeSpecial = (objectData.reltypeSpecial != null) ? objectData.reltypeSpecial : this.defaultData.reltypeSpecial; - objectData.loc = (objectData.loc != null) ? objectData.loc : this.defaultData.loc; + /* (0) Gestion du formattage des valeur */ + objectData.age = (objectData.age != null) ? objectData.age : this.defaultData.age; + objectData.sexe = (objectData.sexe != null) ? objectData.sexe : this.defaultData.sexe; + objectData.studies = (objectData.studies != null) ? objectData.studies : this.defaultData.studies; + objectData.reltype = (objectData.reltype != null) ? objectData.reltype : this.defaultData.reltype; + objectData.reltypeSpecial = (objectData.reltypeSpecial != null) ? objectData.reltypeSpecial : this.defaultData.reltypeSpecial; + objectData.loc = (objectData.loc != null) ? objectData.loc : this.defaultData.loc; - // {1} On récupère username/firstname/lastname du contact associé // - var associatedContact = lsi.get('contacts', objectData.uid); + // {1} On récupère username/firstname/lastname du contact associé // + var associatedContact = lsi.get('contacts', objectData.uid); - // Si on ne trouve pas le contact, on ne fais rien - if( associatedContact === false ) - return false; + // Si on ne trouve pas le contact, on ne fais rien + if( associatedContact === false ) + return false; - // {2} Création physique // - this.container.innerHTML += miniFicheBuilder.build({ - name: readableName(associatedContact.username, associatedContact.firstname, associatedContact.lastname), - countcall: associatedContact.countcall, - countsms: associatedContact.countsms, - uid: objectData.uid, - reltypespecial: objectData.reltypeSpecial - }); + // {2} Création physique // + this.container.innerHTML += miniFicheBuilder.build({ + name: readableName(associatedContact.username, associatedContact.firstname, associatedContact.lastname), + countcall: associatedContact.countcall, + countsms: associatedContact.countsms, + uid: objectData.uid, + reltypespecial: objectData.reltypeSpecial + }); - /* {3} On sélectionne la valeur dans le select (manuellement) de la PROFESSION */ - var selectedOption = $('article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+objectData.studies+'"]'); - if( selectedOption != null ) - selectedOption.setAttribute('selected', 'selected'); + /* {3} On sélectionne la valeur dans le select (manuellement) de la PROFESSION */ + var selectedOption = $('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+objectData.studies+'"]'); + if( selectedOption != null ) + selectedOption.setAttribute('selected', 'selected'); - /* {4} On sélectionne la valeur dans le select (manuellement) de l'AGE */ - selectedOption = $('article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+objectData.age+'"]'); - if( selectedOption != null ) - selectedOption.setAttribute('selected', 'selected'); + /* {4} On sélectionne la valeur dans le select (manuellement) de l'AGE */ + selectedOption = $('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+objectData.age+'"]'); + if( selectedOption != null ) + selectedOption.setAttribute('selected', 'selected'); - /* {5} On sélectionna la valeur des boutons pour le SEXE */ - var sexeCreated = $$('article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'); - for( var i = 0 ; i < sexeCreated.length ; i++ ) - if( sexeCreated[i].value == objectData.sexe ) sexeCreated[i].setAttribute('checked', 'checked'); - else sexeCreated[i].removeAttribute('checked'); + /* {5} On sélectionna la valeur des boutons pour le SEXE */ + var sexeCreated = $$('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'); + for( var i = 0 ; i < sexeCreated.length ; i++ ) + if( sexeCreated[i].value == objectData.sexe ) sexeCreated[i].setAttribute('checked', 'checked'); + else sexeCreated[i].removeAttribute('checked'); - /* {6} On sélectionna la valeur des boutons pour le TYPE DE RELATION */ - var reltypeCreated = $$('article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]'); - for( var i = 0 ; i < reltypeCreated.length ; i++ ) - if( reltypeCreated[i].value == objectData.reltype ) reltypeCreated[i].setAttribute('checked', 'checked'); - else reltypeCreated[i].removeAttribute('checked'); + /* {6} On sélectionna la valeur des boutons pour le TYPE DE RELATION */ + var reltypeCreated = $$('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]'); + for( var i = 0 ; i < reltypeCreated.length ; i++ ) + if( reltypeCreated[i].value == objectData.reltype ) reltypeCreated[i].setAttribute('checked', 'checked'); + else reltypeCreated[i].removeAttribute('checked'); - /* {7} On sélectionna la valeur des boutons pour la LOCATION */ - var locCreated = $$('article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]'); - for( var i = 0 ; i < locCreated.length ; i++ ) - if( locCreated[i].value == objectData.loc ) locCreated[i].setAttribute('checked', 'checked'); - else locCreated[i].removeAttribute('checked'); + /* {7} On sélectionna la valeur des boutons pour la LOCATION */ + var locCreated = $$('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]'); + for( var i = 0 ; i < locCreated.length ; i++ ) + if( locCreated[i].value == objectData.loc ) locCreated[i].setAttribute('checked', 'checked'); + else locCreated[i].removeAttribute('checked'); }; @@ -180,25 +180,25 @@ inputPhoneMini.prototype.add = function(objectData){ /* [4] Gestion de l'affichage depuis le 'localStorage' =========================================================*/ inputPhoneMini.prototype.storageToFields = function(){ - console.log('MINI FICHE: STORAGE TO FIELDS'); + console.log('MINI FICHE: STORAGE TO FIELDS'); - // {1} Pour chaque contact du 'localStorage' // - var miniData = lsi.get('mini-fiches', this.selected); + // {1} Pour chaque contact du 'localStorage' // + var miniData = lsi.get('mini-fiches', this.selected); - // Si on a rien trouvé, on ne fait rien - if( miniData == null ){ - this.updateNavBar(); - return false; - } + // Si on a rien trouvé, on ne fait rien + if( miniData == null ){ + this.updateNavBar(); + return false; + } - // On réinitialise le HTML - this.container.innerHTML = ''; + // On réinitialise le HTML + this.container.innerHTML = ''; - // {2} On affiche la MINI fiche sélectionnée // - this.add(miniData); + // {2} On affiche la MINI fiche sélectionnée // + this.add(miniData); - // {3} On met à jour la navigation // - this.updateNavBar(); + // {3} On met à jour la navigation // + this.updateNavBar(); }; @@ -215,73 +215,73 @@ inputPhoneMini.prototype.storageToFields = function(){ /* [5] Synchronisation des CONTACT vers les MINI fiches =========================================================*/ inputPhoneMini.prototype.sync = function(){ - console.log('MINI FICHE: SYNC'); + console.log('MINI FICHE: SYNC'); - /* (1) On récupère les clés de tous les CONTACTS */ - var contactData = lsi.export('contacts'); + /* (1) On récupère les clés de tous les CONTACTS */ + var contactData = lsi.export('contacts'); - /* (2) On enregistre les contacts qui sont déja dans les FICHES */ - var fiches = lsi.export('fiches'); - var ignoredContacts = []; - for( var id in fiches ) - if( ignoredContacts.indexOf( fiches[id].contact ) == -1 ) - ignoredContacts.push( fiches[id].contact ); + /* (2) On enregistre les contacts qui sont déja dans les FICHES */ + var fiches = lsi.export('fiches'); + var ignoredContacts = []; + for( var id in fiches ) + if( ignoredContacts.indexOf( fiches[id].contact ) == -1 ) + ignoredContacts.push( fiches[id].contact ); - /* (3) Pour chaque CONTACT, on met à jour/crée la MINI fiche associée */ - for( var key in contactData ){ + /* (3) Pour chaque CONTACT, on met à jour/crée la MINI fiche associée */ + for( var key in contactData ){ - /* (4) Si le contact est déja dans une fiche, on le retire */ - if( ignoredContacts.indexOf(parseInt(key)) > -1 ){ - // On supprime au cas ou - lsi.del('mini-fiches', key); - continue; - } + /* (4) Si le contact est déja dans une fiche, on le retire */ + if( ignoredContacts.indexOf(parseInt(key)) > -1 ){ + // On supprime au cas ou + lsi.del('mini-fiches', key); + continue; + } - /* (5) Si le contact n'a aucun nominatif, on met inconnu par défaut, mais on ne l'affiche pas */ - var noName = contactData[key].username.length+contactData[key].firstname.length+contactData[key].lastname.length == 0; + /* (5) Si le contact n'a aucun nominatif, on met inconnu par défaut, mais on ne l'affiche pas */ + var noName = contactData[key].username.length+contactData[key].firstname.length+contactData[key].lastname.length == 0; - // On rajoute un '.' après pour dire qu'on affichera pas - var uid = noName ? key.toString()+'-' : key; + // On rajoute un '.' après pour dire qu'on affichera pas + var uid = noName ? key.toString()+'-' : key; - /* (5) On récupère les informations de la MINI (si elle existe) */ - var miniData = lsi.get('mini-fiches', uid); + /* (5) On récupère les informations de la MINI (si elle existe) */ + var miniData = lsi.get('mini-fiches', uid); - /* (6) Si la MINI fiche n'exise pas, on la crée avec les valeurs par défaut */ - if( miniData == null ){ - miniData = this.defaultData; - miniData.valid = false; + /* (6) Si la MINI fiche n'exise pas, on la crée avec les valeurs par défaut */ + if( miniData == null ){ + miniData = this.defaultData; + miniData.valid = false; - // Si aucun nom, on met 'inconnu' par défaut pour la fiche de relation - if( isNaN(uid) ) - miniData.reltype = '9'; - } + // Si aucun nom, on met 'inconnu' par défaut pour la fiche de relation + if( isNaN(uid) ) + miniData.reltype = '9'; + } - /* (7) On met à jour la MINI fiche */ - miniData.uid = parseInt(key); + /* (7) On met à jour la MINI fiche */ + miniData.uid = parseInt(key); - /* (8) On enregistre les modification */ - lsi.set('mini-fiches', uid, miniData); + /* (8) On enregistre les modification */ + lsi.set('mini-fiches', uid, miniData); - } + } - /* (9) On met à jour la mini-fiche en cours */ - var miniData = lsi.export('mini-fiches'); + /* (9) On met à jour la mini-fiche en cours */ + var miniData = lsi.export('mini-fiches'); - // Si la clé n'existe plus - if( miniData[this.selected] == null ){ + // Si la clé n'existe plus + if( miniData[this.selected] == null ){ - // On cherche la première clé numérique - for( var key in miniData ) - if( !isNaN(key) ){ // La première qu'on trouve, on la définit - this.selected = parseInt(key); - break; - } + // On cherche la première clé numérique + for( var key in miniData ) + if( !isNaN(key) ){ // La première qu'on trouve, on la définit + this.selected = parseInt(key); + break; + } - } + } }; @@ -294,21 +294,21 @@ inputPhoneMini.prototype.sync = function(){ /* [6] Gestion de la navigation entre les fiches =========================================================*/ inputPhoneMini.prototype.nav = function(element){ - /* (1) On vérifie que l'élément contient un nombre et existe */ - if( element == null ) - return false; + /* (1) On vérifie que l'élément contient un nombre et existe */ + if( element == null ) + return false; - if( element.getData('n') === false || isNaN(element.getData('n')) || element.parentNode.id != 'nav-mini' ) - return false; + if( element.getData('n') === false || isNaN(element.getData('n')) || element.parentNode.id != 'nav-mini' ) + return false; - /* (2) On désactive tous les éléments actifs */ - var activeElements = $$('#nav-mini > span.active'); - for( var i = 0 ; i < activeElements.length ; i++ ) - activeElements[i].remClass('active'); + /* (2) On désactive tous les éléments actifs */ + var activeElements = $$('[data-sublink="phone"] #p_nav-mini > span.active'); + for( var i = 0 ; i < activeElements.length ; i++ ) + activeElements[i].remClass('active'); - /* (3) On active l'élément courant */ - element.addClass('active'); - this.selected = parseInt(element.getData('n')); + /* (3) On active l'élément courant */ + element.addClass('active'); + this.selected = parseInt(element.getData('n')); }; @@ -320,45 +320,45 @@ inputPhoneMini.prototype.nav = function(element){ /* [7] Mise à jour de la navigation =========================================================*/ inputPhoneMini.prototype.updateNavBar = function(){ - var miniData = lsi.export('mini-fiches'); + var miniData = lsi.export('mini-fiches'); - /* (1) On vide et remplit la barre de nav, si elle n'est pas à jour */ - this.nav_container.innerHTML = ''; - var i = 0; + /* (1) On vide et remplit la barre de nav, si elle n'est pas à jour */ + this.nav_container.innerHTML = ''; + var i = 0; - for( var key in miniData ) - if( !isNaN(key) ) // On affiche que les clés numériques - this.nav_container.innerHTML += ''+(++i)+''; + for( var key in miniData ) + if( !isNaN(key) ) // On affiche que les clés numériques + this.nav_container.innerHTML += ''+(++i)+''; - /* (2) On montre les MINI fiches qui sont correctes dans la navbar */ - for( var key in miniData ){ + /* (2) On montre les MINI fiches qui sont correctes dans la navbar */ + for( var key in miniData ){ - // Si la clé n'est pas numérique, on ne gère pas - if( isNaN(key) ) - continue; + // Si la clé n'est pas numérique, on ne gère pas + if( isNaN(key) ) + continue; - var currentElement = $('#nav-mini [data-n="'+miniData[key].uid+'"]'); + var currentElement = $('[data-sublink="phone"] #p_nav-mini [data-n="'+miniData[key].uid+'"]'); - if( currentElement == null ) - continue; + if( currentElement == null ) + continue; - // On remplit avec le numéro de la MINI fiche - // currentElement.setAttribute('data-n', miniData[key].uid); - // currentElement.innerHTML = miniData[key].uid + 1; + // On remplit avec le numéro de la MINI fiche + // currentElement.setAttribute('data-n', miniData[key].uid); + // currentElement.innerHTML = miniData[key].uid + 1; - // Si la MINI fiche est valide - if( miniData[key].valid === true ) currentElement.addClass('done'); - // Si elle est invalide - else currentElement.remClass('done'); + // Si la MINI fiche est valide + if( miniData[key].valid === true ) currentElement.addClass('done'); + // Si elle est invalide + else currentElement.remClass('done'); - } + } - /* (3) On séléctionne par défaut la dernière MINI fiche sélectionnée */ - this.nav( $('#nav-mini [data-n="'+this.selected+'"]') ); + /* (3) On séléctionne par défaut la dernière MINI fiche sélectionnée */ + this.nav( $('[data-sublink="phone"] #p_nav-mini [data-n="'+this.selected+'"]') ); }; @@ -368,28 +368,28 @@ inputPhoneMini.prototype.updateNavBar = function(){ =========================================================*/ inputPhoneMini.prototype.check = function(miniData){ - // 1. Le sexe est défini - if( miniData.sexe == '' ) - return false; - // 2. Le métier est défini - if( miniData.studies == '.' ) - return false; - // 3. L'age est définie - if( miniData.age == '.' ) - return false; - // 4. La distance de localisation est définie - if( miniData.loc == '' ) - return false; - // 5. Le TYPE DE RELATION a un et un seul choix - if( miniData.reltype == '' ) - return false; - // 6. TYPE DE RELATION si autre est coché (indice 10), reltypeSpecial doit avoir au moins 2 caractère - if( miniData.reltype == '10' && miniData.reltypeSpecial.length < 2 ) - return false; + // 1. Le sexe est défini + if( miniData.sexe == '' ) + return false; + // 2. Le métier est défini + if( miniData.studies == '.' ) + return false; + // 3. L'age est définie + if( miniData.age == '.' ) + return false; + // 4. La distance de localisation est définie + if( miniData.loc == '' ) + return false; + // 5. Le TYPE DE RELATION a un et un seul choix + if( miniData.reltype == '' ) + return false; + // 6. TYPE DE RELATION si autre est coché (indice 10), reltypeSpecial doit avoir au moins 2 caractère + if( miniData.reltype == '10' && miniData.reltypeSpecial.length < 2 ) + return false; - // Si aucune erreur, tout est ok - return true; + // Si aucune erreur, tout est ok + return true; }; @@ -399,25 +399,25 @@ inputPhoneMini.prototype.check = function(miniData){ /* [9] Point d'amorçage de la gestion des contacts =========================================================*/ inputPhoneMini.prototype.attach = function(handler){ - console.log('MINI FICHE: ATTACH'); + console.log('MINI FICHE: ATTACH'); - /* (1) On initialise le jeu de données */ - lsi.createDataset('mini-fiches'); + /* (1) On initialise le jeu de données */ + lsi.createDataset('mini-fiches'); - /* (2) On charge les mini fiches depuis la mémoire ('localStorage') */ - this.storageToFields(); + /* (2) On charge les mini fiches depuis la mémoire ('localStorage') */ + this.storageToFields(); - /* (3) On attache la barre de navigation à une fonction */ - // On enregistre le handler - this.handler = handler; + /* (3) On attache la barre de navigation à une fonction */ + // On enregistre le handler + this.handler = handler; - /* (2) On attache l'évènement sur le conteneur de navigation */ - var ptr = this; - this.nav_container.addEventListener('click', function(e){ - // 1. On gère la navigation - ptr.nav(e.target); - // 2. On gere le chargement dynamique - ptr.handler(e.target); - }, false); + /* (2) On attache l'évènement sur le conteneur de navigation */ + var ptr = this; + this.nav_container.addEventListener('click', function(e){ + // 1. On gère la navigation + ptr.nav(e.target); + // 2. On gere le chargement dynamique + ptr.handler(e.target); + }, false); }; diff --git a/tmp/phone_storage_bcc6892693dc297179ad2b142c66ee6b17aff9f6.json b/tmp/phone_storage_bcc6892693dc297179ad2b142c66ee6b17aff9f6.json new file mode 100644 index 0000000..e3e4508 --- /dev/null +++ b/tmp/phone_storage_bcc6892693dc297179ad2b142c66ee6b17aff9f6.json @@ -0,0 +1 @@ +{"logs":[{"id":0,"direction":1,"type":0,"date":1411426053,"duration":0},{"id":1,"direction":2,"type":0,"date":1411460855,"duration":0},{"id":1,"direction":0,"type":0,"date":1411466586,"duration":104},{"id":2,"direction":2,"type":0,"date":1411471405,"duration":0},{"id":2,"direction":2,"type":0,"date":1411471447,"duration":0},{"id":2,"direction":2,"type":0,"date":1411471496,"duration":0},{"id":2,"direction":2,"type":0,"date":1411471657,"duration":0},{"id":2,"direction":2,"type":0,"date":1411471698,"duration":0},{"id":2,"direction":2,"type":0,"date":1411471734,"duration":0},{"id":2,"direction":2,"type":0,"date":1411472387,"duration":0},{"id":2,"direction":2,"type":0,"date":1411476096,"duration":0},{"id":3,"direction":2,"type":0,"date":1411477179,"duration":0},{"id":2,"direction":2,"type":0,"date":1411479469,"duration":0},{"id":2,"direction":2,"type":0,"date":1411479917,"duration":0},{"id":2,"direction":2,"type":0,"date":1411480317,"duration":0},{"id":2,"direction":2,"type":0,"date":1411482175,"duration":0},{"id":2,"direction":2,"type":0,"date":1411482220,"duration":0},{"id":2,"direction":2,"type":0,"date":1411483191,"duration":0},{"id":2,"direction":2,"type":0,"date":1411483258,"duration":0},{"id":2,"direction":2,"type":0,"date":1411484211,"duration":0},{"id":1,"direction":2,"type":0,"date":1411486709,"duration":0},{"id":4,"direction":1,"type":0,"date":1411542683,"duration":71},{"id":5,"direction":0,"type":0,"date":1411560264,"duration":54},{"id":6,"direction":0,"type":0,"date":1411583444,"duration":258},{"id":1,"direction":0,"type":0,"date":1411588706,"duration":0},{"id":4,"direction":1,"type":0,"date":1411589167,"duration":14},{"id":4,"direction":1,"type":0,"date":1411589230,"duration":6},{"id":1,"direction":0,"type":0,"date":1411589309,"duration":0},{"id":4,"direction":1,"type":0,"date":1411605045,"duration":0},{"id":0,"direction":0,"type":0,"date":1411631558,"duration":123},{"id":1,"direction":2,"type":0,"date":1411646189,"duration":0},{"id":1,"direction":1,"type":0,"date":1411646829,"duration":4},{"id":1,"direction":0,"type":0,"date":1411647189,"duration":115},{"id":1,"direction":0,"type":0,"date":1411654480,"duration":23},{"id":1,"direction":1,"type":0,"date":1411657516,"duration":221},{"id":0,"direction":1,"type":0,"date":1411657759,"duration":30},{"id":7,"direction":0,"type":0,"date":1411667774,"duration":154},{"id":2,"direction":2,"type":0,"date":1411669650,"duration":0},{"id":1,"direction":0,"type":0,"date":1411680552,"duration":232},{"id":1,"direction":1,"type":0,"date":1411681088,"duration":35},{"id":1,"direction":1,"type":0,"date":1411711054,"duration":0},{"id":1,"direction":1,"type":0,"date":1411711060,"duration":3},{"id":1,"direction":1,"type":0,"date":1411711078,"duration":7},{"id":1,"direction":1,"type":0,"date":1411711100,"duration":2},{"id":1,"direction":1,"type":0,"date":1411711763,"duration":2},{"id":8,"direction":1,"type":0,"date":1411711795,"duration":3},{"id":9,"direction":0,"type":0,"date":1411715019,"duration":45},{"id":1,"direction":1,"type":0,"date":1411719925,"duration":2},{"id":1,"direction":1,"type":0,"date":1411725935,"duration":2},{"id":1,"direction":1,"type":0,"date":1411727847,"duration":4},{"id":1,"direction":1,"type":0,"date":1411730412,"duration":2},{"id":1,"direction":0,"type":0,"date":1411730468,"duration":144},{"id":1,"direction":2,"type":0,"date":1411740534,"duration":0},{"id":1,"direction":1,"type":0,"date":1411742715,"duration":98},{"id":1,"direction":2,"type":0,"date":1411744733,"duration":0},{"id":1,"direction":0,"type":0,"date":1411744767,"duration":10},{"id":1,"direction":0,"type":0,"date":1411813232,"duration":134},{"id":10,"direction":1,"type":0,"date":1411813399,"duration":0},{"id":10,"direction":1,"type":0,"date":1411815660,"duration":19},{"id":1,"direction":0,"type":0,"date":1411821847,"duration":116},{"id":1,"direction":0,"type":0,"date":1411828726,"duration":190},{"id":3,"direction":0,"type":0,"date":1411980289,"duration":267},{"id":1,"direction":1,"type":0,"date":1411981001,"duration":297},{"id":4,"direction":1,"type":0,"date":1411987247,"duration":23},{"id":1,"direction":0,"type":0,"date":1411995928,"duration":241},{"id":3,"direction":0,"type":0,"date":1411996982,"duration":186},{"id":7,"direction":0,"type":0,"date":1412000525,"duration":71},{"id":4,"direction":1,"type":0,"date":1412003166,"duration":110},{"id":7,"direction":0,"type":0,"date":1412005512,"duration":4},{"id":7,"direction":1,"type":0,"date":1412005625,"duration":13},{"id":9,"direction":0,"type":0,"date":1412006989,"duration":8},{"id":1,"direction":1,"type":0,"date":1412007642,"duration":258},{"id":7,"direction":0,"type":0,"date":1412008135,"duration":18},{"id":9,"direction":1,"type":0,"date":1412010599,"duration":16},{"id":11,"direction":0,"type":0,"date":1412012130,"duration":760},{"id":1,"direction":0,"type":0,"date":1412025471,"duration":399},{"id":1,"direction":1,"type":0,"date":1412059366,"duration":15},{"id":1,"direction":2,"type":0,"date":1412059755,"duration":0},{"id":1,"direction":1,"type":0,"date":1412060311,"duration":37},{"id":3,"direction":0,"type":0,"date":1412076287,"duration":122},{"id":7,"direction":0,"type":0,"date":1412077012,"duration":35},{"id":1,"direction":0,"type":0,"date":1412088658,"duration":97},{"id":9,"direction":1,"type":0,"date":1412095547,"duration":3},{"id":12,"direction":0,"type":0,"date":1412096125,"duration":96},{"id":7,"direction":2,"type":0,"date":1412155482,"duration":0},{"id":7,"direction":1,"type":0,"date":1412155525,"duration":67},{"id":9,"direction":1,"type":0,"date":1412160520,"duration":3},{"id":1,"direction":0,"type":0,"date":1412161283,"duration":198},{"id":9,"direction":0,"type":0,"date":1412161686,"duration":106},{"id":3,"direction":0,"type":0,"date":1412164577,"duration":361},{"id":13,"direction":0,"type":0,"date":1412172001,"duration":182},{"id":9,"direction":0,"type":0,"date":1412175608,"duration":71},{"id":1,"direction":1,"type":0,"date":1412192993,"duration":2},{"id":1,"direction":1,"type":0,"date":1412193099,"duration":0},{"id":1,"direction":1,"type":0,"date":1412193120,"duration":2},{"id":1,"direction":0,"type":0,"date":1412196763,"duration":320},{"id":1,"direction":2,"type":0,"date":1412232605,"duration":0},{"id":1,"direction":2,"type":0,"date":1412232636,"duration":0},{"id":1,"direction":1,"type":0,"date":1412232673,"duration":26},{"id":3,"direction":1,"type":0,"date":1412241435,"duration":8},{"id":3,"direction":1,"type":0,"date":1412241539,"duration":0},{"id":3,"direction":1,"type":0,"date":1412241762,"duration":0},{"id":14,"direction":0,"type":0,"date":1412243462,"duration":2},{"id":15,"direction":1,"type":0,"date":1412248129,"duration":172},{"id":1,"direction":0,"type":0,"date":1412249101,"duration":26},{"id":16,"direction":1,"type":0,"date":1412259055,"duration":18},{"id":16,"direction":1,"type":0,"date":1412262166,"duration":2},{"id":2,"direction":1,"type":0,"date":1412262207,"duration":1},{"id":16,"direction":1,"type":0,"date":1412262250,"duration":0},{"id":1,"direction":1,"type":0,"date":1412262258,"duration":71},{"id":15,"direction":1,"type":0,"date":1412262347,"duration":0},{"id":4,"direction":1,"type":0,"date":1412262520,"duration":36},{"id":3,"direction":0,"type":0,"date":1412265165,"duration":69},{"id":10,"direction":1,"type":0,"date":1412266117,"duration":4},{"id":17,"direction":1,"type":0,"date":1412266187,"duration":24},{"id":1,"direction":0,"type":0,"date":1412268456,"duration":25},{"id":3,"direction":0,"type":0,"date":1412320424,"duration":10},{"id":4,"direction":1,"type":0,"date":1412324425,"duration":21},{"id":16,"direction":0,"type":0,"date":1412330861,"duration":123},{"id":1,"direction":0,"type":0,"date":1412334007,"duration":16},{"id":18,"direction":0,"type":0,"date":1412335291,"duration":197},{"id":1,"direction":1,"type":0,"date":1412348594,"duration":29},{"id":1,"direction":0,"type":0,"date":1412351577,"duration":42},{"id":1,"direction":0,"type":0,"date":1412357942,"duration":51},{"id":16,"direction":0,"type":0,"date":1412374222,"duration":49},{"id":12,"direction":0,"type":0,"date":1412410201,"duration":49},{"id":12,"direction":0,"type":0,"date":1412416839,"duration":8},{"id":1,"direction":0,"type":0,"date":1412417040,"duration":198},{"id":3,"direction":1,"type":0,"date":1412422292,"duration":4},{"id":3,"direction":0,"type":0,"date":1412422390,"duration":71},{"id":3,"direction":0,"type":0,"date":1412422530,"duration":164},{"id":19,"direction":1,"type":0,"date":1412424078,"duration":24},{"id":19,"direction":0,"type":0,"date":1412426686,"duration":51},{"id":1,"direction":0,"type":0,"date":1412432526,"duration":37},{"id":16,"direction":0,"type":0,"date":1412433711,"duration":51},{"id":1,"direction":1,"type":0,"date":1412439767,"duration":385},{"id":20,"direction":0,"type":0,"date":1412445123,"duration":212},{"id":12,"direction":1,"type":0,"date":1412446464,"duration":46},{"id":1,"direction":0,"type":0,"date":1412505852,"duration":16},{"id":1,"direction":0,"type":0,"date":1412513929,"duration":8},{"id":16,"direction":1,"type":0,"date":1412514032,"duration":47},{"id":16,"direction":0,"type":0,"date":1412527614,"duration":33},{"id":21,"direction":0,"type":0,"date":1412585876,"duration":554},{"id":16,"direction":0,"type":0,"date":1412589911,"duration":76},{"id":0,"direction":0,"type":0,"date":1412597972,"duration":19},{"id":1,"direction":0,"type":0,"date":1412609358,"duration":0},{"id":1,"direction":1,"type":0,"date":1412609376,"duration":291},{"id":22,"direction":1,"type":0,"date":1412611236,"duration":62},{"id":1,"direction":0,"type":0,"date":1412615923,"duration":29},{"id":1,"direction":1,"type":0,"date":1412621860,"duration":276},{"id":1,"direction":1,"type":0,"date":1412662436,"duration":5},{"id":1,"direction":1,"type":0,"date":1412662472,"duration":0},{"id":1,"direction":0,"type":0,"date":1412662477,"duration":13},{"id":16,"direction":0,"type":0,"date":1412663886,"duration":80},{"id":16,"direction":0,"type":0,"date":1412667829,"duration":31},{"id":9,"direction":0,"type":0,"date":1412668116,"duration":375},{"id":16,"direction":0,"type":0,"date":1412668936,"duration":11},{"id":6,"direction":0,"type":0,"date":1412671775,"duration":395},{"id":16,"direction":0,"type":0,"date":1412672769,"duration":118},{"id":16,"direction":0,"type":0,"date":1412672914,"duration":7},{"id":16,"direction":0,"type":0,"date":1412675777,"duration":5},{"id":23,"direction":1,"type":0,"date":1412678571,"duration":770},{"id":1,"direction":0,"type":0,"date":1412680408,"duration":13},{"id":1,"direction":1,"type":0,"date":1412680851,"duration":274},{"id":3,"direction":0,"type":0,"date":1412684947,"duration":213},{"id":1,"direction":0,"type":0,"date":1412702475,"duration":53},{"id":16,"direction":0,"type":0,"date":1412744830,"duration":10},{"id":16,"direction":2,"type":0,"date":1412783611,"duration":0},{"id":24,"direction":1,"type":0,"date":1412784925,"duration":0},{"id":1,"direction":0,"type":0,"date":1412789202,"duration":62},{"id":1,"direction":0,"type":0,"date":1412853466,"duration":496},{"id":25,"direction":1,"type":0,"date":1412858982,"duration":66},{"id":26,"direction":0,"type":0,"date":1412861124,"duration":219},{"id":1,"direction":1,"type":0,"date":1412872008,"duration":232},{"id":4,"direction":1,"type":0,"date":1412873170,"duration":21},{"id":1,"direction":1,"type":0,"date":1412888448,"duration":201},{"id":1,"direction":0,"type":0,"date":1412949700,"duration":180},{"id":27,"direction":2,"type":0,"date":1412968406,"duration":0},{"id":27,"direction":1,"type":0,"date":1412969003,"duration":47},{"id":28,"direction":0,"type":0,"date":1413037002,"duration":84},{"id":0,"direction":1,"type":0,"date":1413037221,"duration":2},{"id":28,"direction":1,"type":0,"date":1413044931,"duration":20},{"id":28,"direction":0,"type":0,"date":1413055181,"duration":38},{"id":1,"direction":0,"type":0,"date":1413059146,"duration":13},{"id":16,"direction":0,"type":0,"date":1413069201,"duration":40},{"id":1,"direction":0,"type":0,"date":1413070099,"duration":208},{"id":1,"direction":0,"type":0,"date":1413108051,"duration":170},{"id":1,"direction":2,"type":0,"date":1413119224,"duration":0},{"id":1,"direction":0,"type":0,"date":1413123964,"duration":216},{"id":1,"direction":0,"type":0,"date":1413131688,"duration":106},{"id":12,"direction":0,"type":0,"date":1413199378,"duration":135},{"id":3,"direction":0,"type":0,"date":1413199532,"duration":44},{"id":29,"direction":1,"type":0,"date":1413201554,"duration":26},{"id":1,"direction":0,"type":0,"date":1413206581,"duration":44},{"id":29,"direction":1,"type":0,"date":1413211514,"duration":100},{"id":1,"direction":0,"type":0,"date":1413213926,"duration":25},{"id":12,"direction":0,"type":0,"date":1413222179,"duration":21},{"id":1,"direction":0,"type":0,"date":1413284444,"duration":15},{"id":30,"direction":1,"type":0,"date":1413289057,"duration":192},{"id":0,"direction":0,"type":0,"date":1413292178,"duration":64},{"id":1,"direction":2,"type":0,"date":1413298114,"duration":0},{"id":1,"direction":1,"type":0,"date":1413298864,"duration":17},{"id":1,"direction":1,"type":0,"date":1413298912,"duration":0},{"id":1,"direction":0,"type":0,"date":1413298913,"duration":105},{"id":1,"direction":0,"type":0,"date":1413300272,"duration":60},{"id":16,"direction":0,"type":0,"date":1413300545,"duration":45},{"id":31,"direction":2,"type":0,"date":1413305382,"duration":0},{"id":31,"direction":1,"type":0,"date":1413308768,"duration":0},{"id":1,"direction":1,"type":0,"date":1413310796,"duration":313},{"id":19,"direction":0,"type":0,"date":1413373269,"duration":44},{"id":1,"direction":0,"type":0,"date":1413382710,"duration":39},{"id":0,"direction":0,"type":0,"date":1413450573,"duration":31},{"id":32,"direction":0,"type":0,"date":1413452058,"duration":43},{"id":1,"direction":0,"type":0,"date":1413456345,"duration":149},{"id":1,"direction":0,"type":0,"date":1413472773,"duration":223},{"id":3,"direction":2,"type":0,"date":1413475391,"duration":0},{"id":3,"direction":1,"type":0,"date":1413475546,"duration":334},{"id":1,"direction":1,"type":0,"date":1413478541,"duration":63},{"id":16,"direction":2,"type":0,"date":1413478818,"duration":0},{"id":33,"direction":2,"type":0,"date":1413484198,"duration":0},{"id":4,"direction":1,"type":0,"date":1413484707,"duration":25},{"id":1,"direction":1,"type":0,"date":1413493588,"duration":35},{"id":32,"direction":0,"type":0,"date":1413537424,"duration":37},{"id":11,"direction":1,"type":0,"date":1413537796,"duration":0},{"id":11,"direction":1,"type":0,"date":1413537861,"duration":250},{"id":11,"direction":0,"type":0,"date":1413537903,"duration":892},{"id":1,"direction":0,"type":0,"date":1413543357,"duration":349},{"id":3,"direction":0,"type":0,"date":1413552183,"duration":241},{"id":9,"direction":2,"type":0,"date":1413555494,"duration":0},{"id":9,"direction":1,"type":0,"date":1413555565,"duration":39},{"id":4,"direction":1,"type":0,"date":1413555632,"duration":27},{"id":1,"direction":0,"type":0,"date":1413556059,"duration":11},{"id":1,"direction":1,"type":0,"date":1413556616,"duration":31},{"id":3,"direction":0,"type":0,"date":1413565432,"duration":181},{"id":34,"direction":0,"type":0,"date":1413566099,"duration":314},{"id":1,"direction":0,"type":0,"date":1413567563,"duration":245},{"id":1,"direction":1,"type":0,"date":1413578255,"duration":172},{"id":1,"direction":1,"type":0,"date":1413580571,"duration":71},{"id":1,"direction":0,"type":0,"date":1413583191,"duration":193},{"id":1,"direction":1,"type":0,"date":1413583426,"duration":28},{"id":34,"direction":1,"type":0,"date":1413623620,"duration":26},{"id":34,"direction":0,"type":0,"date":1413623957,"duration":32},{"id":34,"direction":2,"type":0,"date":1413628109,"duration":0},{"id":1,"direction":2,"type":0,"date":1413628272,"duration":0},{"id":4,"direction":1,"type":0,"date":1413628533,"duration":13},{"id":4,"direction":1,"type":0,"date":1413629787,"duration":0},{"id":1,"direction":1,"type":0,"date":1413629792,"duration":34},{"id":1,"direction":1,"type":0,"date":1413636096,"duration":0},{"id":1,"direction":1,"type":0,"date":1413636114,"duration":0},{"id":1,"direction":1,"type":0,"date":1413636125,"duration":0},{"id":1,"direction":1,"type":0,"date":1413642655,"duration":85},{"id":1,"direction":1,"type":0,"date":1413668553,"duration":64},{"id":4,"direction":1,"type":0,"date":1413673422,"duration":0},{"id":4,"direction":1,"type":0,"date":1413706985,"duration":20},{"id":22,"direction":0,"type":0,"date":1413714793,"duration":48},{"id":1,"direction":0,"type":0,"date":1413715858,"duration":207},{"id":1,"direction":0,"type":0,"date":1413723687,"duration":52},{"id":1,"direction":1,"type":0,"date":1413734326,"duration":227},{"id":1,"direction":0,"type":0,"date":1413745661,"duration":119},{"id":11,"direction":0,"type":0,"date":1413799391,"duration":488},{"id":1,"direction":0,"type":0,"date":1413804083,"duration":126},{"id":1,"direction":0,"type":0,"date":1413817078,"duration":180},{"id":3,"direction":2,"type":0,"date":1413818525,"duration":0},{"id":3,"direction":1,"type":0,"date":1413818582,"duration":11},{"id":3,"direction":1,"type":0,"date":1413818606,"duration":112},{"id":6,"direction":1,"type":0,"date":1413819000,"duration":44},{"id":6,"direction":0,"type":0,"date":1413819255,"duration":111},{"id":32,"direction":1,"type":0,"date":1413819588,"duration":111},{"id":23,"direction":1,"type":0,"date":1413822373,"duration":0},{"id":23,"direction":1,"type":0,"date":1413822385,"duration":0},{"id":23,"direction":1,"type":0,"date":1413822400,"duration":0},{"id":23,"direction":1,"type":0,"date":1413822461,"duration":0},{"id":4,"direction":1,"type":0,"date":1413825277,"duration":32},{"id":23,"direction":0,"type":0,"date":1413834310,"duration":195},{"id":1,"direction":1,"type":0,"date":1413840503,"duration":33},{"id":1,"direction":2,"type":0,"date":1413840681,"duration":0},{"id":1,"direction":2,"type":0,"date":1413840722,"duration":0},{"id":1,"direction":1,"type":0,"date":1413841047,"duration":459},{"id":1,"direction":1,"type":0,"date":1413869031,"duration":2},{"id":1,"direction":1,"type":0,"date":1413869067,"duration":2},{"id":1,"direction":1,"type":0,"date":1413869112,"duration":2},{"id":1,"direction":1,"type":0,"date":1413869152,"duration":15},{"id":32,"direction":0,"type":0,"date":1413886555,"duration":14},{"id":0,"direction":1,"type":0,"date":1413895251,"duration":47},{"id":1,"direction":0,"type":0,"date":1413896540,"duration":50},{"id":1,"direction":0,"type":0,"date":1413902957,"duration":14},{"id":3,"direction":1,"type":0,"date":1413906644,"duration":0},{"id":1,"direction":1,"type":0,"date":1413911672,"duration":37},{"id":1,"direction":0,"type":0,"date":1413978047,"duration":73},{"id":3,"direction":0,"type":0,"date":1413980681,"duration":269},{"id":1,"direction":0,"type":0,"date":1413985779,"duration":45},{"id":8,"direction":2,"type":0,"date":1414054927,"duration":0},{"id":35,"direction":1,"type":0,"date":1414058398,"duration":18},{"id":4,"direction":1,"type":0,"date":1414060593,"duration":29},{"id":1,"direction":1,"type":0,"date":1414060775,"duration":2},{"id":1,"direction":1,"type":0,"date":1414061054,"duration":2},{"id":1,"direction":1,"type":0,"date":1414061267,"duration":2},{"id":1,"direction":0,"type":0,"date":1414061404,"duration":29},{"id":6,"direction":1,"type":0,"date":1414065919,"duration":21},{"id":6,"direction":1,"type":0,"date":1414068934,"duration":109},{"id":26,"direction":2,"type":0,"date":1414069268,"duration":0},{"id":0,"direction":0,"type":0,"date":1414084141,"duration":163},{"id":4,"direction":1,"type":0,"date":1414085120,"duration":171},{"id":26,"direction":2,"type":0,"date":1414085123,"duration":0},{"id":0,"direction":1,"type":0,"date":1414085299,"duration":32},{"id":4,"direction":1,"type":0,"date":1414085358,"duration":13},{"id":0,"direction":2,"type":0,"date":1414151512,"duration":0},{"id":16,"direction":2,"type":0,"date":1414163456,"duration":0},{"id":16,"direction":2,"type":0,"date":1414163487,"duration":0},{"id":4,"direction":1,"type":0,"date":1414164239,"duration":25},{"id":16,"direction":1,"type":0,"date":1414166586,"duration":5},{"id":4,"direction":1,"type":0,"date":1414167086,"duration":20},{"id":4,"direction":1,"type":0,"date":1414167920,"duration":15},{"id":16,"direction":1,"type":0,"date":1414167941,"duration":44},{"id":16,"direction":0,"type":0,"date":1414168308,"duration":67},{"id":16,"direction":0,"type":0,"date":1414178415,"duration":16},{"id":1,"direction":0,"type":0,"date":1414241289,"duration":116},{"id":23,"direction":0,"type":0,"date":1414247087,"duration":36},{"id":16,"direction":0,"type":0,"date":1414247951,"duration":76},{"id":1,"direction":2,"type":0,"date":1414248948,"duration":0},{"id":1,"direction":1,"type":0,"date":1414250412,"duration":68},{"id":1,"direction":1,"type":0,"date":1414254050,"duration":11},{"id":1,"direction":1,"type":0,"date":1414254095,"duration":0},{"id":1,"direction":0,"type":0,"date":1414328136,"duration":136},{"id":11,"direction":0,"type":0,"date":1414345298,"duration":915},{"id":26,"direction":2,"type":0,"date":1414350078,"duration":0},{"id":36,"direction":0,"type":0,"date":1414410319,"duration":99},{"id":3,"direction":0,"type":0,"date":1414426841,"duration":7},{"id":3,"direction":0,"type":0,"date":1414426871,"duration":70},{"id":36,"direction":1,"type":0,"date":1414429203,"duration":42},{"id":1,"direction":1,"type":0,"date":1414495520,"duration":107},{"id":36,"direction":0,"type":0,"date":1414500978,"duration":13},{"id":1,"direction":0,"type":0,"date":1414508884,"duration":108},{"id":0,"direction":0,"type":0,"date":1414510123,"duration":35},{"id":37,"direction":0,"type":0,"date":1414528786,"duration":406},{"id":3,"direction":0,"type":0,"date":1414575100,"duration":143},{"id":1,"direction":0,"type":0,"date":1414583990,"duration":231},{"id":38,"direction":1,"type":0,"date":1414590100,"duration":59},{"id":0,"direction":1,"type":0,"date":1414590646,"duration":54},{"id":1,"direction":0,"type":0,"date":1414596132,"duration":36},{"id":4,"direction":1,"type":0,"date":1414598048,"duration":0},{"id":1,"direction":0,"type":0,"date":1414664446,"duration":64},{"id":1,"direction":1,"type":0,"date":1414687087,"duration":100},{"id":1,"direction":0,"type":0,"date":1414688261,"duration":55},{"id":4,"direction":1,"type":0,"date":1414745571,"duration":0},{"id":16,"direction":1,"type":0,"date":1414747705,"duration":3},{"id":0,"direction":1,"type":0,"date":1414747718,"duration":158},{"id":23,"direction":1,"type":0,"date":1414759073,"duration":693},{"id":1,"direction":1,"type":0,"date":1414771728,"duration":104},{"id":0,"direction":1,"type":0,"date":1414771905,"duration":39},{"id":1,"direction":1,"type":0,"date":1414778662,"duration":116},{"id":26,"direction":0,"type":0,"date":1414788758,"duration":56},{"id":26,"direction":2,"type":0,"date":1414790981,"duration":0},{"id":19,"direction":2,"type":0,"date":1414833500,"duration":0},{"id":4,"direction":1,"type":0,"date":1414833732,"duration":36},{"id":1,"direction":0,"type":0,"date":1414957087,"duration":365},{"id":1,"direction":1,"type":0,"date":1414993912,"duration":2},{"id":1,"direction":1,"type":0,"date":1414993984,"duration":2},{"id":1,"direction":1,"type":0,"date":1414994141,"duration":25},{"id":39,"direction":1,"type":0,"date":1415016543,"duration":0},{"id":3,"direction":0,"type":0,"date":1415016993,"duration":181},{"id":1,"direction":0,"type":0,"date":1415018002,"duration":326},{"id":15,"direction":1,"type":0,"date":1415103183,"duration":8},{"id":3,"direction":0,"type":0,"date":1415103600,"duration":38},{"id":4,"direction":1,"type":0,"date":1415104805,"duration":16},{"id":32,"direction":1,"type":0,"date":1415104851,"duration":50},{"id":15,"direction":0,"type":0,"date":1415104884,"duration":26},{"id":37,"direction":0,"type":0,"date":1415105205,"duration":48},{"id":1,"direction":0,"type":0,"date":1415108449,"duration":202},{"id":22,"direction":1,"type":0,"date":1415110842,"duration":106},{"id":22,"direction":1,"type":0,"date":1415110963,"duration":0},{"id":3,"direction":1,"type":0,"date":1415110973,"duration":4},{"id":3,"direction":0,"type":0,"date":1415111322,"duration":341},{"id":1,"direction":0,"type":0,"date":1415118683,"duration":75},{"id":26,"direction":0,"type":0,"date":1415124925,"duration":73},{"id":1,"direction":1,"type":0,"date":1415126903,"duration":217},{"id":3,"direction":0,"type":0,"date":1415186301,"duration":154},{"id":1,"direction":1,"type":0,"date":1415190426,"duration":0},{"id":15,"direction":1,"type":0,"date":1415190439,"duration":2},{"id":1,"direction":2,"type":0,"date":1415191083,"duration":0},{"id":1,"direction":1,"type":0,"date":1415191311,"duration":229},{"id":15,"direction":0,"type":0,"date":1415192249,"duration":37},{"id":3,"direction":2,"type":0,"date":1415196418,"duration":0},{"id":3,"direction":1,"type":0,"date":1415196601,"duration":120},{"id":40,"direction":2,"type":0,"date":1415198197,"duration":0},{"id":15,"direction":0,"type":0,"date":1415198336,"duration":129},{"id":1,"direction":2,"type":0,"date":1415205006,"duration":0},{"id":1,"direction":0,"type":0,"date":1415205561,"duration":16},{"id":1,"direction":1,"type":0,"date":1415208499,"duration":2},{"id":1,"direction":1,"type":0,"date":1415209341,"duration":12},{"id":1,"direction":0,"type":0,"date":1415209387,"duration":37},{"id":4,"direction":1,"type":0,"date":1415210851,"duration":37},{"id":0,"direction":0,"type":0,"date":1415211445,"duration":35},{"id":3,"direction":0,"type":0,"date":1415272093,"duration":61},{"id":3,"direction":1,"type":0,"date":1415272646,"duration":14},{"id":3,"direction":1,"type":0,"date":1415272723,"duration":115},{"id":2,"direction":0,"type":0,"date":1415280278,"duration":64},{"id":1,"direction":0,"type":0,"date":1415280634,"duration":40},{"id":1,"direction":1,"type":0,"date":1415287213,"duration":67},{"id":41,"direction":1,"type":0,"date":1415289742,"duration":0},{"id":41,"direction":1,"type":0,"date":1415289763,"duration":79},{"id":41,"direction":1,"type":0,"date":1415291255,"duration":29},{"id":1,"direction":1,"type":0,"date":1415295056,"duration":26},{"id":2,"direction":1,"type":0,"date":1415295347,"duration":0},{"id":1,"direction":1,"type":0,"date":1415295355,"duration":122},{"id":3,"direction":0,"type":0,"date":1415354323,"duration":24},{"id":1,"direction":0,"type":0,"date":1415364493,"duration":8},{"id":1,"direction":1,"type":0,"date":1415366709,"duration":2},{"id":1,"direction":0,"type":0,"date":1415369705,"duration":81},{"id":1,"direction":0,"type":0,"date":1415382822,"duration":10},{"id":1,"direction":1,"type":0,"date":1415387955,"duration":113},{"id":4,"direction":1,"type":0,"date":1415389593,"duration":26},{"id":23,"direction":1,"type":0,"date":1415389655,"duration":321},{"id":1,"direction":2,"type":0,"date":1415446107,"duration":0},{"id":1,"direction":2,"type":0,"date":1415450432,"duration":0},{"id":1,"direction":2,"type":0,"date":1415456676,"duration":0},{"id":1,"direction":1,"type":0,"date":1415457013,"duration":231},{"id":1,"direction":1,"type":0,"date":1415460835,"duration":44},{"id":42,"direction":1,"type":0,"date":1415468284,"duration":3},{"id":18,"direction":0,"type":0,"date":1415471589,"duration":32},{"id":1,"direction":0,"type":0,"date":1415481966,"duration":79},{"id":1,"direction":0,"type":0,"date":1415540328,"duration":291},{"id":1,"direction":0,"type":0,"date":1415545637,"duration":190},{"id":1,"direction":1,"type":0,"date":1415550795,"duration":37},{"id":23,"direction":0,"type":0,"date":1415563926,"duration":325},{"id":0,"direction":1,"type":0,"date":1415609677,"duration":0},{"id":11,"direction":0,"type":0,"date":1415613648,"duration":47},{"id":11,"direction":1,"type":0,"date":1415613718,"duration":337},{"id":35,"direction":1,"type":0,"date":1415614600,"duration":0},{"id":35,"direction":1,"type":0,"date":1415614641,"duration":19},{"id":16,"direction":2,"type":0,"date":1415728277,"duration":0},{"id":16,"direction":1,"type":0,"date":1415728891,"duration":81},{"id":23,"direction":0,"type":0,"date":1415794537,"duration":364},{"id":1,"direction":0,"type":0,"date":1415795551,"duration":324},{"id":16,"direction":0,"type":0,"date":1415795861,"duration":0},{"id":0,"direction":0,"type":0,"date":1415796369,"duration":42},{"id":43,"direction":1,"type":0,"date":1415798005,"duration":47},{"id":43,"direction":1,"type":0,"date":1415798067,"duration":45},{"id":43,"direction":1,"type":0,"date":1415798175,"duration":69},{"id":43,"direction":1,"type":0,"date":1415798258,"duration":391},{"id":16,"direction":0,"type":0,"date":1415802451,"duration":37},{"id":44,"direction":0,"type":0,"date":1415803000,"duration":329},{"id":1,"direction":0,"type":0,"date":1415805666,"duration":25},{"id":45,"direction":0,"type":0,"date":1415810549,"duration":112},{"id":46,"direction":0,"type":0,"date":1415867202,"duration":27},{"id":1,"direction":1,"type":0,"date":1415867969,"duration":0},{"id":1,"direction":2,"type":0,"date":1415868093,"duration":0},{"id":1,"direction":0,"type":0,"date":1415881768,"duration":294},{"id":47,"direction":2,"type":0,"date":1415894775,"duration":0},{"id":47,"direction":1,"type":0,"date":1415896115,"duration":24},{"id":1,"direction":0,"type":0,"date":1415897526,"duration":10},{"id":3,"direction":0,"type":0,"date":1415955360,"duration":26},{"id":45,"direction":1,"type":0,"date":1415961232,"duration":32},{"id":1,"direction":0,"type":0,"date":1415970249,"duration":226},{"id":48,"direction":0,"type":0,"date":1415974138,"duration":68},{"id":1,"direction":2,"type":0,"date":1415979691,"duration":0},{"id":1,"direction":1,"type":0,"date":1415980636,"duration":2},{"id":1,"direction":0,"type":0,"date":1415980680,"duration":115},{"id":1,"direction":0,"type":0,"date":1415992366,"duration":542},{"id":1,"direction":0,"type":0,"date":1416051116,"duration":284},{"id":1,"direction":2,"type":0,"date":1416060668,"duration":0},{"id":1,"direction":2,"type":0,"date":1416060788,"duration":0},{"id":4,"direction":1,"type":0,"date":1416060964,"duration":38},{"id":4,"direction":1,"type":0,"date":1416068198,"duration":34},{"id":15,"direction":0,"type":0,"date":1416150916,"duration":90},{"id":49,"direction":1,"type":0,"date":1416151061,"duration":44},{"id":1,"direction":0,"type":0,"date":1416215905,"duration":142},{"id":16,"direction":0,"type":0,"date":1416233024,"duration":47},{"id":1,"direction":2,"type":0,"date":1416237600,"duration":0},{"id":1,"direction":0,"type":0,"date":1416238040,"duration":93},{"id":1,"direction":1,"type":0,"date":1416241763,"duration":47},{"id":23,"direction":0,"type":0,"date":1416306058,"duration":52},{"id":2,"direction":1,"type":0,"date":1416306257,"duration":2},{"id":1,"direction":0,"type":0,"date":1416318110,"duration":301},{"id":0,"direction":0,"type":0,"date":1416325497,"duration":27},{"id":1,"direction":1,"type":0,"date":1416329168,"duration":9},{"id":1,"direction":1,"type":0,"date":1416331027,"duration":28},{"id":1,"direction":0,"type":0,"date":1416332418,"duration":411},{"id":1,"direction":2,"type":0,"date":1416384646,"duration":0},{"id":3,"direction":1,"type":0,"date":1416393129,"duration":4},{"id":45,"direction":1,"type":0,"date":1416393215,"duration":0},{"id":4,"direction":1,"type":0,"date":1416393242,"duration":1},{"id":45,"direction":1,"type":0,"date":1416393250,"duration":23},{"id":1,"direction":1,"type":0,"date":1416400267,"duration":2},{"id":1,"direction":0,"type":0,"date":1416400479,"duration":220},{"id":15,"direction":0,"type":0,"date":1416402034,"duration":98},{"id":15,"direction":2,"type":0,"date":1416402371,"duration":0},{"id":15,"direction":2,"type":0,"date":1416402437,"duration":0},{"id":15,"direction":0,"type":0,"date":1416402913,"duration":25},{"id":4,"direction":1,"type":0,"date":1416402947,"duration":48},{"id":0,"direction":1,"type":0,"date":1416405343,"duration":35},{"id":1,"direction":0,"type":0,"date":1416487128,"duration":51},{"id":16,"direction":0,"type":0,"date":1416495762,"duration":49},{"id":15,"direction":2,"type":0,"date":1416496361,"duration":0},{"id":15,"direction":2,"type":0,"date":1416496854,"duration":0},{"id":15,"direction":2,"type":0,"date":1416497258,"duration":0},{"id":1,"direction":0,"type":0,"date":1416498803,"duration":45},{"id":15,"direction":1,"type":0,"date":1416499263,"duration":20},{"id":1,"direction":1,"type":0,"date":1416499480,"duration":73},{"id":15,"direction":2,"type":0,"date":1416502090,"duration":0},{"id":3,"direction":0,"type":1,"date":1415016937,"duration":0},{"id":3,"direction":1,"type":1,"date":1415016967,"duration":0},{"id":3,"direction":0,"type":1,"date":1415089894,"duration":0},{"id":3,"direction":1,"type":1,"date":1415090384,"duration":0},{"id":3,"direction":1,"type":1,"date":1415090434,"duration":0},{"id":3,"direction":0,"type":1,"date":1415110791,"duration":0},{"id":3,"direction":1,"type":1,"date":1415132548,"duration":0},{"id":3,"direction":0,"type":1,"date":1415132624,"duration":0},{"id":3,"direction":0,"type":1,"date":1415132748,"duration":0},{"id":3,"direction":1,"type":1,"date":1415133139,"duration":0},{"id":3,"direction":0,"type":1,"date":1415133244,"duration":0},{"id":3,"direction":1,"type":1,"date":1415138012,"duration":0},{"id":3,"direction":0,"type":1,"date":1415138135,"duration":0},{"id":3,"direction":1,"type":1,"date":1415138161,"duration":0},{"id":3,"direction":0,"type":1,"date":1415173529,"duration":0},{"id":3,"direction":1,"type":1,"date":1415186249,"duration":0},{"id":3,"direction":0,"type":1,"date":1415186533,"duration":0},{"id":3,"direction":1,"type":1,"date":1415186586,"duration":0},{"id":3,"direction":1,"type":1,"date":1415271778,"duration":0},{"id":3,"direction":1,"type":1,"date":1415609759,"duration":0},{"id":3,"direction":0,"type":1,"date":1415609828,"duration":0},{"id":45,"direction":0,"type":1,"date":1415961172,"duration":0},{"id":3,"direction":1,"type":1,"date":1416050169,"duration":0},{"id":3,"direction":0,"type":1,"date":1416062311,"duration":0},{"id":3,"direction":1,"type":1,"date":1416063833,"duration":0},{"id":3,"direction":0,"type":1,"date":1416068116,"duration":0},{"id":3,"direction":1,"type":1,"date":1416068169,"duration":0},{"id":3,"direction":0,"type":1,"date":1416068294,"duration":0},{"id":3,"direction":1,"type":1,"date":1416068320,"duration":0},{"id":3,"direction":0,"type":1,"date":1416069591,"duration":0},{"id":3,"direction":1,"type":1,"date":1416072621,"duration":0},{"id":3,"direction":0,"type":1,"date":1416212474,"duration":0},{"id":3,"direction":1,"type":1,"date":1416212772,"duration":0},{"id":3,"direction":0,"type":1,"date":1416213002,"duration":0},{"id":3,"direction":1,"type":1,"date":1416331472,"duration":0},{"id":45,"direction":1,"type":1,"date":1416331561,"duration":0},{"id":45,"direction":0,"type":1,"date":1416331675,"duration":0},{"id":45,"direction":1,"type":1,"date":1416331698,"duration":0},{"id":3,"direction":0,"type":1,"date":1416335845,"duration":0},{"id":3,"direction":1,"type":1,"date":1416335875,"duration":0},{"id":45,"direction":1,"type":1,"date":1416412634,"duration":0},{"id":45,"direction":0,"type":1,"date":1416412684,"duration":0},{"id":3,"direction":1,"type":1,"date":1416472162,"duration":0},{"id":26,"direction":1,"type":0,"date":1416511357,"duration":0},{"id":1,"direction":1,"type":1,"date":1416524426,"duration":0},{"id":1,"direction":0,"type":1,"date":1416524491,"duration":0},{"id":1,"direction":1,"type":1,"date":1416524525,"duration":0},{"id":1,"direction":0,"type":1,"date":1416524545,"duration":0},{"id":1,"direction":1,"type":1,"date":1416524598,"duration":0},{"id":1,"direction":0,"type":1,"date":1416524674,"duration":0},{"id":1,"direction":0,"type":1,"date":1416528576,"duration":0},{"id":1,"direction":1,"type":1,"date":1416553622,"duration":0},{"id":1,"direction":1,"type":0,"date":1416553689,"duration":8},{"id":45,"direction":1,"type":1,"date":1416557566,"duration":0},{"id":45,"direction":0,"type":1,"date":1416559375,"duration":0},{"id":45,"direction":1,"type":1,"date":1416559589,"duration":0},{"id":50,"direction":1,"type":0,"date":1416560996,"duration":160},{"id":1,"direction":1,"type":0,"date":1416567729,"duration":2},{"id":1,"direction":0,"type":0,"date":1416567895,"duration":49},{"id":51,"direction":0,"type":0,"date":1416576513,"duration":8},{"id":16,"direction":0,"type":0,"date":1416577532,"duration":28},{"id":41,"direction":1,"type":0,"date":1416585090,"duration":20},{"id":1,"direction":0,"type":1,"date":1416585353,"duration":0},{"id":1,"direction":1,"type":1,"date":1416587020,"duration":0},{"id":0,"direction":0,"type":0,"date":1416590363,"duration":33},{"id":15,"direction":0,"type":0,"date":1416590496,"duration":79},{"id":0,"direction":0,"type":1,"date":1416597202,"duration":0},{"id":0,"direction":1,"type":1,"date":1416597227,"duration":0},{"id":16,"direction":0,"type":0,"date":1416600714,"duration":34},{"id":37,"direction":0,"type":0,"date":1416602768,"duration":145},{"id":1,"direction":0,"type":1,"date":1416611315,"duration":0},{"id":1,"direction":1,"type":1,"date":1416612036,"duration":0},{"id":1,"direction":0,"type":1,"date":1416612085,"duration":0},{"id":1,"direction":1,"type":1,"date":1416612941,"duration":0},{"id":1,"direction":0,"type":1,"date":1416613007,"duration":0},{"id":1,"direction":1,"type":0,"date":1416613446,"duration":518},{"id":16,"direction":0,"type":0,"date":1416615841,"duration":75},{"id":1,"direction":0,"type":1,"date":1416616206,"duration":0},{"id":3,"direction":1,"type":1,"date":1416645040,"duration":0},{"id":1,"direction":1,"type":0,"date":1416654588,"duration":2},{"id":1,"direction":0,"type":0,"date":1416654643,"duration":19},{"id":52,"direction":0,"type":1,"date":1416656610,"duration":0},{"id":52,"direction":1,"type":1,"date":1416656652,"duration":0},{"id":52,"direction":0,"type":1,"date":1416656686,"duration":0},{"id":52,"direction":1,"type":1,"date":1416656732,"duration":0},{"id":3,"direction":2,"type":0,"date":1416666989,"duration":0},{"id":3,"direction":1,"type":0,"date":1416668308,"duration":0},{"id":4,"direction":1,"type":0,"date":1416668334,"duration":71},{"id":3,"direction":1,"type":1,"date":1416668494,"duration":0},{"id":2,"direction":1,"type":0,"date":1416668738,"duration":29},{"id":2,"direction":0,"type":0,"date":1416669698,"duration":30},{"id":16,"direction":0,"type":0,"date":1416673656,"duration":78},{"id":16,"direction":0,"type":0,"date":1416674047,"duration":80},{"id":2,"direction":1,"type":0,"date":1416676744,"duration":1},{"id":16,"direction":1,"type":0,"date":1416676789,"duration":3},{"id":2,"direction":1,"type":0,"date":1416676847,"duration":1},{"id":16,"direction":0,"type":0,"date":1416676904,"duration":43},{"id":4,"direction":1,"type":0,"date":1416676900,"duration":55},{"id":19,"direction":0,"type":0,"date":1416677028,"duration":29},{"id":53,"direction":0,"type":1,"date":1416680159,"duration":0},{"id":53,"direction":1,"type":1,"date":1416680196,"duration":0},{"id":53,"direction":0,"type":1,"date":1416680230,"duration":0},{"id":1,"direction":0,"type":1,"date":1416680260,"duration":0},{"id":1,"direction":1,"type":1,"date":1416686905,"duration":0},{"id":1,"direction":0,"type":1,"date":1416686951,"duration":0},{"id":1,"direction":1,"type":1,"date":1416686983,"duration":0},{"id":11,"direction":2,"type":0,"date":1416738321,"duration":0},{"id":11,"direction":1,"type":1,"date":1416738608,"duration":0},{"id":11,"direction":0,"type":1,"date":1416738787,"duration":0},{"id":11,"direction":1,"type":1,"date":1416738812,"duration":0},{"id":1,"direction":1,"type":1,"date":1416746999,"duration":0},{"id":1,"direction":0,"type":1,"date":1416747026,"duration":0},{"id":1,"direction":1,"type":1,"date":1416747038,"duration":0},{"id":1,"direction":0,"type":1,"date":1416747088,"duration":0},{"id":1,"direction":1,"type":0,"date":1416747081,"duration":158},{"id":1,"direction":2,"type":0,"date":1416760949,"duration":0},{"id":1,"direction":1,"type":0,"date":1416760985,"duration":34},{"id":11,"direction":0,"type":0,"date":1416762959,"duration":4},{"id":11,"direction":1,"type":0,"date":1416762983,"duration":549},{"id":1,"direction":0,"type":1,"date":1416764674,"duration":0},{"id":1,"direction":1,"type":1,"date":1416764895,"duration":0},{"id":1,"direction":0,"type":1,"date":1416764961,"duration":0},{"id":1,"direction":1,"type":1,"date":1416764979,"duration":0},{"id":1,"direction":0,"type":1,"date":1416765004,"duration":0},{"id":1,"direction":2,"type":0,"date":1416765124,"duration":0},{"id":1,"direction":0,"type":0,"date":1416767055,"duration":22},{"id":1,"direction":1,"type":1,"date":1416815535,"duration":0},{"id":3,"direction":1,"type":1,"date":1416823508,"duration":0},{"id":3,"direction":0,"type":1,"date":1416824926,"duration":0},{"id":1,"direction":0,"type":1,"date":1416830359,"duration":0},{"id":1,"direction":1,"type":0,"date":1416831523,"duration":2},{"id":41,"direction":1,"type":0,"date":1416839307,"duration":35},{"id":1,"direction":1,"type":1,"date":1416845390,"duration":0},{"id":1,"direction":0,"type":1,"date":1416847320,"duration":0},{"id":1,"direction":1,"type":1,"date":1416847341,"duration":0},{"id":1,"direction":0,"type":1,"date":1416847407,"duration":0},{"id":1,"direction":1,"type":1,"date":1416847426,"duration":0},{"id":0,"direction":0,"type":0,"date":1416849095,"duration":53},{"id":1,"direction":1,"type":0,"date":1416853886,"duration":72},{"id":54,"direction":2,"type":0,"date":1416864680,"duration":0},{"id":4,"direction":1,"type":0,"date":1416901870,"duration":47},{"id":54,"direction":1,"type":1,"date":1416901982,"duration":0},{"id":3,"direction":1,"type":0,"date":1416913241,"duration":4},{"id":1,"direction":0,"type":1,"date":1416914388,"duration":0},{"id":1,"direction":1,"type":1,"date":1416914442,"duration":0},{"id":1,"direction":0,"type":0,"date":1416914467,"duration":104},{"id":3,"direction":0,"type":0,"date":1416915236,"duration":123},{"id":55,"direction":1,"type":0,"date":1416916711,"duration":23},{"id":55,"direction":1,"type":0,"date":1416917799,"duration":3},{"id":55,"direction":1,"type":0,"date":1416918868,"duration":43},{"id":3,"direction":0,"type":1,"date":1416919943,"duration":0},{"id":3,"direction":1,"type":1,"date":1416920486,"duration":0},{"id":16,"direction":0,"type":0,"date":1416924290,"duration":0},{"id":16,"direction":1,"type":1,"date":1416924343,"duration":0},{"id":55,"direction":1,"type":0,"date":1416924813,"duration":3},{"id":55,"direction":1,"type":0,"date":1416924847,"duration":2},{"id":55,"direction":1,"type":0,"date":1416924894,"duration":0},{"id":16,"direction":1,"type":0,"date":1416924901,"duration":19},{"id":55,"direction":1,"type":0,"date":1416924940,"duration":0},{"id":55,"direction":1,"type":0,"date":1416925209,"duration":0},{"id":1,"direction":1,"type":0,"date":1416929983,"duration":86},{"id":4,"direction":1,"type":0,"date":1416931930,"duration":145},{"id":3,"direction":1,"type":1,"date":1416935411,"duration":0},{"id":3,"direction":0,"type":1,"date":1416935611,"duration":0},{"id":1,"direction":0,"type":0,"date":1416936961,"duration":351},{"id":1,"direction":1,"type":1,"date":1416949208,"duration":0},{"id":1,"direction":0,"type":1,"date":1416949499,"duration":0},{"id":1,"direction":1,"type":1,"date":1416949536,"duration":0},{"id":1,"direction":0,"type":1,"date":1416949569,"duration":0},{"id":1,"direction":1,"type":1,"date":1416949620,"duration":0},{"id":1,"direction":0,"type":1,"date":1416949644,"duration":0},{"id":1,"direction":1,"type":1,"date":1416949838,"duration":0},{"id":1,"direction":1,"type":1,"date":1416949861,"duration":0},{"id":1,"direction":0,"type":1,"date":1416949921,"duration":0},{"id":1,"direction":1,"type":1,"date":1416949945,"duration":0},{"id":1,"direction":1,"type":1,"date":1416949963,"duration":0},{"id":1,"direction":0,"type":1,"date":1416949995,"duration":0},{"id":1,"direction":1,"type":1,"date":1416950109,"duration":0},{"id":1,"direction":0,"type":1,"date":1416950200,"duration":0},{"id":1,"direction":1,"type":1,"date":1416950414,"duration":0},{"id":1,"direction":1,"type":1,"date":1416952260,"duration":0},{"id":1,"direction":0,"type":0,"date":1416952328,"duration":88},{"id":1,"direction":1,"type":1,"date":1416952597,"duration":0},{"id":1,"direction":0,"type":1,"date":1416952643,"duration":0},{"id":1,"direction":1,"type":1,"date":1416952658,"duration":0},{"id":1,"direction":1,"type":1,"date":1416954993,"duration":0},{"id":1,"direction":0,"type":1,"date":1416955037,"duration":0},{"id":1,"direction":1,"type":1,"date":1416955051,"duration":0},{"id":1,"direction":0,"type":1,"date":1416960503,"duration":0},{"id":1,"direction":1,"type":1,"date":1416978195,"duration":0},{"id":1,"direction":1,"type":0,"date":1416978324,"duration":0},{"id":1,"direction":1,"type":1,"date":1416978482,"duration":0},{"id":55,"direction":1,"type":0,"date":1416991044,"duration":4},{"id":1,"direction":1,"type":1,"date":1416992245,"duration":0},{"id":3,"direction":1,"type":1,"date":1416993172,"duration":0},{"id":3,"direction":0,"type":1,"date":1416993466,"duration":0},{"id":3,"direction":1,"type":1,"date":1416993518,"duration":0},{"id":3,"direction":0,"type":1,"date":1416993580,"duration":0},{"id":16,"direction":2,"type":0,"date":1417000988,"duration":0},{"id":4,"direction":1,"type":0,"date":1417001420,"duration":30},{"id":2,"direction":1,"type":0,"date":1417001471,"duration":15},{"id":4,"direction":1,"type":0,"date":1417001770,"duration":17},{"id":1,"direction":1,"type":1,"date":1417007924,"duration":0},{"id":1,"direction":0,"type":1,"date":1417008002,"duration":0},{"id":56,"direction":0,"type":1,"date":1417012046,"duration":0},{"id":56,"direction":1,"type":1,"date":1417012326,"duration":0},{"id":56,"direction":0,"type":1,"date":1417012390,"duration":0},{"id":56,"direction":1,"type":1,"date":1417013556,"duration":0},{"id":56,"direction":0,"type":1,"date":1417013595,"duration":0},{"id":56,"direction":0,"type":1,"date":1417013639,"duration":0},{"id":56,"direction":0,"type":1,"date":1417013723,"duration":0},{"id":56,"direction":1,"type":1,"date":1417014481,"duration":0},{"id":56,"direction":0,"type":1,"date":1417014611,"duration":0},{"id":56,"direction":1,"type":1,"date":1417014780,"duration":0},{"id":56,"direction":0,"type":1,"date":1417014878,"duration":0},{"id":1,"direction":0,"type":0,"date":1417014879,"duration":0},{"id":56,"direction":1,"type":1,"date":1417014905,"duration":0},{"id":56,"direction":1,"type":1,"date":1417014912,"duration":0},{"id":56,"direction":0,"type":1,"date":1417014985,"duration":0},{"id":56,"direction":0,"type":1,"date":1417015029,"duration":0},{"id":56,"direction":1,"type":1,"date":1417015511,"duration":0},{"id":56,"direction":0,"type":1,"date":1417015874,"duration":0},{"id":56,"direction":1,"type":1,"date":1417015986,"duration":0},{"id":1,"direction":1,"type":0,"date":1417016568,"duration":66},{"id":6,"direction":1,"type":0,"date":1417023111,"duration":849},{"id":1,"direction":0,"type":0,"date":1417035510,"duration":17},{"id":1,"direction":0,"type":0,"date":1417035545,"duration":797},{"id":0,"direction":1,"type":0,"date":1417044819,"duration":0},{"id":57,"direction":1,"type":0,"date":1417079622,"duration":0},{"id":58,"direction":1,"type":0,"date":1417079737,"duration":0},{"id":58,"direction":1,"type":0,"date":1417079789,"duration":0},{"id":58,"direction":1,"type":0,"date":1417079837,"duration":0},{"id":57,"direction":1,"type":0,"date":1417079861,"duration":0},{"id":58,"direction":1,"type":0,"date":1417079968,"duration":0},{"id":58,"direction":1,"type":0,"date":1417080040,"duration":0},{"id":1,"direction":1,"type":1,"date":1417080118,"duration":0},{"id":1,"direction":0,"type":1,"date":1417080185,"duration":0},{"id":1,"direction":1,"type":1,"date":1417084948,"duration":0},{"id":3,"direction":0,"type":1,"date":1417088949,"duration":0},{"id":3,"direction":1,"type":1,"date":1417089020,"duration":0},{"id":3,"direction":0,"type":1,"date":1417089251,"duration":0},{"id":59,"direction":1,"type":0,"date":1417090250,"duration":52},{"id":60,"direction":1,"type":0,"date":1417091590,"duration":405},{"id":1,"direction":0,"type":1,"date":1417094670,"duration":0},{"id":1,"direction":1,"type":1,"date":1417094760,"duration":0},{"id":1,"direction":0,"type":1,"date":1417094809,"duration":0},{"id":1,"direction":1,"type":1,"date":1417094964,"duration":0},{"id":1,"direction":1,"type":0,"date":1417101987,"duration":21},{"id":1,"direction":2,"type":0,"date":1417102922,"duration":0},{"id":3,"direction":0,"type":0,"date":1417107632,"duration":79},{"id":58,"direction":1,"type":0,"date":1417171005,"duration":0},{"id":58,"direction":1,"type":0,"date":1417171038,"duration":0},{"id":57,"direction":1,"type":0,"date":1417171045,"duration":0},{"id":58,"direction":1,"type":0,"date":1417171152,"duration":0},{"id":58,"direction":1,"type":0,"date":1417171260,"duration":0},{"id":61,"direction":1,"type":0,"date":1417171306,"duration":88},{"id":62,"direction":1,"type":0,"date":1417171414,"duration":132},{"id":1,"direction":0,"type":0,"date":1417183836,"duration":135},{"id":1,"direction":1,"type":0,"date":1417190382,"duration":21},{"id":63,"direction":0,"type":1,"date":1417191841,"duration":0},{"id":63,"direction":1,"type":1,"date":1417195095,"duration":0},{"id":0,"direction":1,"type":1,"date":1417195872,"duration":0},{"id":45,"direction":1,"type":1,"date":1417196888,"duration":0},{"id":45,"direction":0,"type":1,"date":1417197089,"duration":0},{"id":45,"direction":1,"type":1,"date":1417197214,"duration":0},{"id":45,"direction":0,"type":1,"date":1417197261,"duration":0},{"id":45,"direction":1,"type":1,"date":1417197629,"duration":0},{"id":45,"direction":0,"type":1,"date":1417197661,"duration":0},{"id":0,"direction":1,"type":0,"date":1417197647,"duration":1},{"id":27,"direction":1,"type":1,"date":1417200280,"duration":0},{"id":27,"direction":0,"type":1,"date":1417200387,"duration":0},{"id":0,"direction":0,"type":1,"date":1417200553,"duration":0},{"id":0,"direction":0,"type":1,"date":1417200578,"duration":0},{"id":0,"direction":1,"type":1,"date":1417200633,"duration":0},{"id":0,"direction":0,"type":0,"date":1417200690,"duration":49},{"id":27,"direction":0,"type":1,"date":1417201409,"duration":0},{"id":27,"direction":1,"type":0,"date":1417201714,"duration":48},{"id":11,"direction":1,"type":1,"date":1417202149,"duration":0},{"id":1,"direction":0,"type":0,"date":1417203591,"duration":206},{"id":11,"direction":0,"type":1,"date":1417203887,"duration":0},{"id":0,"direction":1,"type":1,"date":1417206619,"duration":0},{"id":0,"direction":0,"type":1,"date":1417206676,"duration":0},{"id":0,"direction":1,"type":1,"date":1417206690,"duration":0},{"id":0,"direction":0,"type":1,"date":1417206914,"duration":0},{"id":0,"direction":0,"type":0,"date":1417206933,"duration":45},{"id":0,"direction":0,"type":0,"date":1417208042,"duration":18},{"id":27,"direction":1,"type":1,"date":1417210547,"duration":0},{"id":64,"direction":2,"type":0,"date":1417211215,"duration":0},{"id":63,"direction":0,"type":1,"date":1417251261,"duration":0},{"id":63,"direction":1,"type":1,"date":1417258076,"duration":0},{"id":1,"direction":0,"type":0,"date":1417266292,"duration":204},{"id":65,"direction":0,"type":0,"date":1417274763,"duration":18},{"id":31,"direction":1,"type":0,"date":1417276265,"duration":1},{"id":31,"direction":1,"type":0,"date":1417276689,"duration":1},{"id":31,"direction":1,"type":1,"date":1417276842,"duration":0},{"id":31,"direction":0,"type":0,"date":1417278054,"duration":97},{"id":2,"direction":1,"type":0,"date":1417278186,"duration":1},{"id":2,"direction":1,"type":0,"date":1417278239,"duration":1},{"id":1,"direction":1,"type":0,"date":1417278281,"duration":0},{"id":1,"direction":1,"type":0,"date":1417278286,"duration":0},{"id":2,"direction":1,"type":0,"date":1417278293,"duration":0},{"id":16,"direction":1,"type":0,"date":1417278355,"duration":2},{"id":16,"direction":0,"type":0,"date":1417278395,"duration":33},{"id":16,"direction":1,"type":0,"date":1417278438,"duration":51},{"id":31,"direction":1,"type":0,"date":1417281594,"duration":1},{"id":28,"direction":0,"type":0,"date":1417282336,"duration":53},{"id":1,"direction":0,"type":0,"date":1417295530,"duration":534},{"id":22,"direction":1,"type":0,"date":1417335890,"duration":0},{"id":22,"direction":1,"type":0,"date":1417340097,"duration":54},{"id":22,"direction":0,"type":0,"date":1417341619,"duration":79},{"id":1,"direction":1,"type":1,"date":1417352791,"duration":0},{"id":1,"direction":0,"type":1,"date":1417352844,"duration":0},{"id":1,"direction":1,"type":1,"date":1417361696,"duration":0},{"id":1,"direction":0,"type":0,"date":1417362047,"duration":152},{"id":1,"direction":0,"type":1,"date":1417369939,"duration":0},{"id":1,"direction":1,"type":1,"date":1417369955,"duration":0},{"id":1,"direction":0,"type":0,"date":1417370651,"duration":39},{"id":1,"direction":0,"type":1,"date":1417393900,"duration":0},{"id":3,"direction":0,"type":1,"date":1417420982,"duration":0},{"id":3,"direction":1,"type":1,"date":1417421035,"duration":0},{"id":1,"direction":0,"type":1,"date":1417429954,"duration":0},{"id":1,"direction":1,"type":1,"date":1417430003,"duration":0},{"id":28,"direction":0,"type":1,"date":1417435020,"duration":0},{"id":28,"direction":1,"type":1,"date":1417435062,"duration":0},{"id":16,"direction":0,"type":0,"date":1417440439,"duration":147},{"id":61,"direction":1,"type":0,"date":1417442368,"duration":22},{"id":60,"direction":1,"type":0,"date":1417442403,"duration":400},{"id":1,"direction":0,"type":0,"date":1417446898,"duration":150},{"id":66,"direction":1,"type":0,"date":1417452757,"duration":113},{"id":1,"direction":1,"type":1,"date":1417510732,"duration":0},{"id":1,"direction":0,"type":1,"date":1417511566,"duration":0},{"id":3,"direction":0,"type":0,"date":1417511541,"duration":31},{"id":66,"direction":1,"type":0,"date":1417511926,"duration":134},{"id":16,"direction":0,"type":0,"date":1417524557,"duration":80},{"id":1,"direction":0,"type":0,"date":1417540634,"duration":79},{"id":1,"direction":1,"type":0,"date":1417543301,"duration":633},{"id":16,"direction":1,"type":0,"date":1417547651,"duration":27},{"id":1,"direction":1,"type":1,"date":1417555112,"duration":0},{"id":1,"direction":0,"type":1,"date":1417555165,"duration":0},{"id":1,"direction":1,"type":1,"date":1417555201,"duration":0},{"id":1,"direction":0,"type":1,"date":1417555285,"duration":0},{"id":1,"direction":1,"type":1,"date":1417555323,"duration":0},{"id":1,"direction":0,"type":1,"date":1417555346,"duration":0},{"id":1,"direction":1,"type":1,"date":1417555398,"duration":0},{"id":1,"direction":0,"type":1,"date":1417555417,"duration":0},{"id":1,"direction":1,"type":1,"date":1417555465,"duration":0},{"id":1,"direction":1,"type":1,"date":1417556403,"duration":0},{"id":1,"direction":1,"type":1,"date":1417592264,"duration":0},{"id":1,"direction":0,"type":1,"date":1417592894,"duration":0},{"id":1,"direction":1,"type":1,"date":1417592950,"duration":0},{"id":2,"direction":1,"type":0,"date":1417596286,"duration":15},{"id":0,"direction":0,"type":0,"date":1417599245,"duration":60},{"id":45,"direction":0,"type":1,"date":1417599408,"duration":0},{"id":45,"direction":1,"type":1,"date":1417599458,"duration":0},{"id":45,"direction":0,"type":1,"date":1417599483,"duration":0},{"id":1,"direction":1,"type":0,"date":1417610615,"duration":210},{"id":0,"direction":0,"type":1,"date":1417616219,"duration":0},{"id":0,"direction":1,"type":1,"date":1417616282,"duration":0},{"id":45,"direction":1,"type":1,"date":1417622785,"duration":0},{"id":45,"direction":0,"type":1,"date":1417622822,"duration":0},{"id":19,"direction":0,"type":0,"date":1417624319,"duration":23},{"id":45,"direction":1,"type":1,"date":1417625024,"duration":0},{"id":45,"direction":0,"type":1,"date":1417625051,"duration":0}],"subject":"","contacts":[]} \ No newline at end of file diff --git a/view/input.php b/view/input.php index 4f0af0d..289b08e 100755 --- a/view/input.php +++ b/view/input.php @@ -39,17 +39,17 @@

Effacer les données de la dernière enquête

- -
+ +

- -
+ +

- +

@@ -61,7 +61,7 @@

- + @@ -75,7 +75,7 @@

- + Importer un journal d'appels

@@ -92,7 +92,7 @@
- +
@@ -105,7 +105,7 @@

Remplir les fiches relations rapides pour tous les contacts

- +
@@ -117,7 +117,7 @@

Remplir les fiches relations complètes des contacts les plus contactés

- +
@@ -133,7 +133,7 @@

Envoi des données

- +

@@ -146,8 +146,111 @@ - Donnees de Messenger + + + + + + + + + + Donnees Facebook =========================================================*/ -?>
- Messenger +?>
+ +
+ +

Effacer les données de la dernière enquête

+ +

+ +
+

+ +

+ +
+

+ +

+ +

+ + + + +

Identifier l'enquêté

+ +
+
+

+ + + + +

+
+ + +

Saisir manuellement les amis

+ + + + + + + + +
+ + +
+ +
+
+ + + + + + +

Remplir les fiches relations rapides pour tous les amis

+ + +
+ +
+ +
+ + + + + +

Remplir les fiches relations complètes des amis les plus proches

+ +
+
+ + + + + +

Saisir les matrices des relations entre les amis les plus proches

+ +
+ + + +

Envoi des données

+
+

+ +

+
+ +
+ +
diff --git a/view/js/input-min.js b/view/js/input-min.js index bc45a02..fa0f722 100644 --- a/view/js/input-min.js +++ b/view/js/input-min.js @@ -1,15 +1,26 @@ -var subjectManager,contactManager,miniManager,ficheManager,matriceManager; -function dynamicUpdate(a){var f=a instanceof Element,b=f&&"SPAN"==a.tagName&&"switch-left"==a.className,e=f&&"SPAN"==a.tagName&&"switch-both"==a.className,c=f&&"INPUT"==a.tagName&&"submit"==a.type,d=f&&"SPAN"==a.tagName&&("nav-mini"==a.parentNode.id||"nav-fiche"==a.parentNode.id),f=f&&"SPAN"==a.tagName&&"nav-contact"==a.parentNode.id;if(!(e||b||c||d||f)&&!0!==a)return!1;if(e)console.log("> switch firstname <-> lastname"),b=a.parentNode,a=b.children[8],b=b.children[10],e=a.value,a.value=b.value,b.value= -e;else if(b){console.log("> switch firstname+lastname -> username");b=a.parentNode;e=b.children[6];a=b.children[8];b=b.children[10];if(0 dynamic update"),miniManager.fieldsToStorage(),ficheManager.fieldsToStorage(),contactManager.fieldsToStorage(),matriceManager.fieldsToStorage(),ficheManager.sync(),miniManager.sync(),miniManager.storageToFields(),ficheManager.storageToFields(), -matriceManager.storageToFields(),(c||f)&&contactManager.storageToFields()}function readableName(a,f,b){var e=f.length,c=b.length;return 0sujet avant d'exporter son journal d'appel"): -Notification.error("Erreur",a.ModuleError);else{b=Notification.info("Info","Chargement du journal d'appel");subjectManager.tmp_id.value=a.tmp_id;subjectManager.fieldsToStorage();subjectManager.storageToFields();for(var e=0;e GATHERING ALL DATA");subjectManager.fieldsToStorage();contactManager.fieldsToStorage(); -miniManager.fieldsToStorage();ficheManager.fieldsToStorage();if(!subjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du sujet"),!1;a=lsi["export"]("mini-fiches");var f=0,b;for(b in a)if(!isNaN(b)&&(f++,!a[b].valid))return Notification.warning("Attention","La fiche rapide "+f+" est incompl\u00e8te et/ou incorrecte"),!1;b={path:"input/phone",subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"), -fiches:lsi["export"]("fiches"),matrice:lsi["export"]("matrice")[0]};api.send(b,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;console.log(a)},!1)},!1)})})})})}); +function readableName(a,c,b){var e=c.length,d=b.length;return 0 switch firstname <-> lastname"),b=a.parentNode, +a=b.children[8],b=b.children[10],e=a.value,a.value=b.value,b.value=e;else if(b){console.log("> switch firstname+lastname -> username");b=a.parentNode;e=b.children[6];a=b.children[8];b=b.children[10];if(0 dynamic update"),cMiniManager.fieldsToStorage(),cFicheManager.fieldsToStorage(),cContactManager.fieldsToStorage(),cMatriceManager.fieldsToStorage(),cFicheManager.sync(), +cMiniManager.sync(),cMiniManager.storageToFields(),cFicheManager.storageToFields(),cMatriceManager.storageToFields(),(d||c)&&cContactManager.storageToFields()};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",function(){cSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'), +$('[data-sublink="phone"] article.subject-panel [data-name="number"]'),$('[data-sublink="phone"] article.subject-panel [data-name="username"]'),$('[data-sublink="phone"] article.subject-panel [data-name="firstname"]'),$('[data-sublink="phone"] article.subject-panel [data-name="lastname"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]'));cSubjectManager.attach();cContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact')); +cContactManager.attach(cDynamicUpdate);cMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini'));cMiniManager.attach(cDynamicUpdate);cFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),$('[data-sublink="phone"] #p_nav-fiche'));cFicheManager.attach(cDynamicUpdate);cMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));cMatriceManager.attach(cDynamicUpdate);$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("click", +function(a){a.target.value=null},!1);$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("change",function(a){a={path:"upload/call_log",phone_number:$('[data-sublink="phone"] #p_subject_phone_number').value,file:a.target.files[0]};api.send(a,function(a){console.log(a);var b=null;if(0!=a.ModuleError)9==a.ModuleError?Notification.error("Erreur","Il est n\u00e9cessaire de saisir les informations du sujet avant d'exporter son journal d'appel"):Notification.error("Erreur", +a.ModuleError);else{b=Notification.info("Info","Chargement du journal d'appel");cSubjectManager.tmp_id.value=a.tmp_id;cSubjectManager.fieldsToStorage();cSubjectManager.storageToFields();for(var e=0;e GATHERING ALL DATA");cSubjectManager.fieldsToStorage();cContactManager.fieldsToStorage();cMiniManager.fieldsToStorage();cFicheManager.fieldsToStorage();if(!cSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du sujet"),!1;a=lsi["export"]("mini-fiches");var c=0,b;for(b in a)if(!isNaN(b)&&(c++,!a[b].valid))return Notification.warning("Attention", +"La fiche rapide "+c+" est incompl\u00e8te et/ou incorrecte"),!1;b={path:"input/phone",subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches"),matrice:lsi["export"]("matrice")[0]};api.send(b,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;console.log(a)},!1)},!1)})})})})})}var fSubjectManager,fContactManager,fMiniManager,fFicheManager,fMatriceManager; +if(null!=pageManager.vars[0]&&"facebook"==pageManager.vars[0]){var fDynamicUpdate=function(a){var c=a instanceof Element,b=c&&"SPAN"==a.tagName&&"switch-left"==a.className,e=c&&"SPAN"==a.tagName&&"switch-both"==a.className,d=c&&"INPUT"==a.tagName&&"submit"==a.type,f=c&&"SPAN"==a.tagName&&("f_nav-mini"==a.parentNode.id||"f_nav-fiche"==a.parentNode.id),c=c&&"SPAN"==a.tagName&&"f_nav-contact"==a.parentNode.id;if(!(e||b||d||f||c)&&!0!==a)return!1;if(e)console.log("> switch firstname <-> lastname"),b= +a.parentNode,a=b.children[8],b=b.children[10],e=a.value,a.value=b.value,b.value=e;else if(b){console.log("> switch firstname+lastname -> username");b=a.parentNode;e=b.children[6];a=b.children[8];b=b.children[10];if(0 dynamic update"),fMiniManager.fieldsToStorage(),fFicheManager.fieldsToStorage(),fContactManager.fieldsToStorage(),fMatriceManager.fieldsToStorage(),fFicheManager.sync(), +fMiniManager.sync(),fMiniManager.storageToFields(),fFicheManager.storageToFields(),fMatriceManager.storageToFields(),(d||c)&&fContactManager.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="username"]'), +$('[data-sublink="facebook"] article.subject-panel [data-name="firstname"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="lastname"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]'));fSubjectManager.attach();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("subject");lsi.clear("contacts"); +lsi.clear("mini-fiches");lsi.clear("fiches");lsi.clear("matrice");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"]("subject")[0], +contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches"),matrice:lsi["export"]("matrice")[0]};var c=$('[data-sublink="facebook"] #f_download-target');c.download="local-facebook-data.json";c.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));c.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("subject",0,a.local_data.subject);lsi["import"]("contacts",a.local_data.contacts);lsi["import"]("mini-fiches",a.local_data.mini);lsi["import"]("fiches",a.local_data.fiches); +lsi.set("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 sujet"), +!1;a=lsi["export"]("mini-fiches");var c=0,b;for(b in a)if(!isNaN(b)&&(c++,!a[b].valid))return Notification.warning("Attention","La fiche rapide "+c+" est incompl\u00e8te et/ou incorrecte"),!1;b={path:"input/phone",subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches"),matrice:lsi["export"]("matrice")[0]};api.send(b,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError), +!1;console.log(a)},!1)},!1)})})})})})}; diff --git a/view/js/input.js b/view/js/input.js index f7c4073..8662628 100644 --- a/view/js/input.js +++ b/view/js/input.js @@ -1,150 +1,572 @@ -// STRUCTURE DU localStorage -// subject -> contient les données du sujet -// contacts -> contient les données de tous les contacts -// mini-fiches -> contient les données de toutes les mini fiches -// fiches -> contient les données de toutes les fiches -// matrice -> contient les relations de la matrice - - -/* [1] Initialisation des utilitaires et variables -=========================================================* -/* (1) Initialisation des managers */ -var subjectManager; -var contactManager; -var miniManager; -var ficheManager; -var matriceManager; - - -/* (2) Fonctions utiles */ -function dynamicUpdate(target){ - - - /* (0) Vérification de la cohérence de la @target - ---------------------------------------------------------*/ - var isElement = target instanceof Element; - var isSwitchLeft = isElement && target.tagName == 'SPAN' && target.className == 'switch-left'; - var isSwitchBoth = isElement && target.tagName == 'SPAN' && target.className == 'switch-both'; - var isSaveButton = isElement && target.tagName == 'INPUT' && target.type == 'submit'; - var isNavButton = isElement && target.tagName == 'SPAN' && (target.parentNode.id == 'nav-mini' || target.parentNode.id == 'nav-fiche'); - var isNavContact = isElement && target.tagName == 'SPAN' && target.parentNode.id == 'nav-contact'; - - // Si erreur, on retourne une erreur - if( !isSwitchBoth && !isSwitchLeft && !isSaveButton && !isNavButton && !isNavContact && target !== true ) - return false; - - /* (1) Gestion de l'échange de nom/prénom - ---------------------------------------------------------*/ - if( isSwitchBoth ){ - console.log('> switch firstname <-> lastname'); - - /* (1) On récupère le formulaire parent */ - var currentForm = target.parentNode; - - /* (2) On récupère Nom et Prénom */ - var firstname = currentForm.children[8]; - var lastname = currentForm.children[10]; - - /* (3) On échange leurs valeurs */ - var tmp = firstname.value; - firstname.value = lastname.value; - lastname.value = tmp; - - }else if( isSwitchLeft ){ - /* (2) Gestion de l'échange Prénom+Nom = Pseudo - ---------------------------------------------------------*/ - console.log('> switch firstname+lastname -> username'); - - /* (1) On récupère le formulaire parent */ - var currentForm = target.parentNode; - - /* (2) On récupère Pseudo, Nom et Prénom */ - var username = currentForm.children[6]; - var firstname = currentForm.children[8]; - var lastname = currentForm.children[10]; - - /* (3) Vérification de la validité */ - // Si pseudo pas vide, ou nom et prenom vide -> on ne fais rien - if( username.value.length > 0 || firstname.value.length == 0 && lastname.value.length == 0 ) - return false; - - /* (4) On attribue à Pseudo, la valeur de Prénom+Nom */ - username.value = firstname.value +' '+ lastname.value; - firstname.value = ''; - lastname.value = ''; - - - /* (3) Gestion de la mise à jour dynamique - ---------------------------------------------------------*/ - }else{ - console.log('> dynamic update'); - - /* (1) On enregistre les MINI fiches relation */ - miniManager.fieldsToStorage(); - - /* (2) On enregister les FICHES relation */ - ficheManager.fieldsToStorage(); - - /* (3) On enregistre les CONTACTS */ - contactManager.fieldsToStorage(); - - /* (4) On enregistre la MATRICE */ - matriceManager.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 - ficheManager.sync(); - - /* (6) On synchronise les MINI avec les CONTACTS */ - // Supprime les contacts déja dans les FICHES - miniManager.sync(); - - /* (7) On affiche le tout */ - miniManager.storageToFields(); - ficheManager.storageToFields(); - matriceManager.storageToFields(); - - /* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */ - if( isSaveButton || isNavContact ) - contactManager.storageToFields(); - } -} - - /* AFFICHE UN NOM EXPLICITE A PARTIR DE @u username, @f firstname, et @l lastname * */ function readableName(u, f, l){ - /* (1) On calcule les tailles des chaines */ - var ul = u.length, - fl = f.length, - ll = l.length; + /* (1) On calcule les tailles des chaines */ + var ul = u.length, + fl = f.length, + ll = l.length; - /* (2) Si @username n'est pas vide */ - if( ul > 0 ){ + /* (2) Si @username n'est pas vide */ + if( ul > 0 ){ - /* (3) Si @username+(@firstname et/ou @lastname) -> username (firstname lastname) */ - if( fl+ll > 0 ) - return u+' ('+(f+' '+l).trim()+')'; + /* (3) Si @username+(@firstname et/ou @lastname) -> username (firstname lastname) */ + if( fl+ll > 0 ) + return u+' ('+(f+' '+l).trim()+')'; - /* (4) Si @username uniquement -> username */ - else - return u; + /* (4) Si @username uniquement -> username */ + else + return u; - /* (5) Si pas @username */ - }else{ + /* (5) Si pas @username */ + }else{ - /* (6) Si @firstname et/ou @lastname -> firstname lastname*/ - if( fl+ll > 0 ) - return (f+' '+l).trim(); + /* (6) Si @firstname et/ou @lastname -> firstname lastname*/ + if( fl+ll > 0 ) + return (f+' '+l).trim(); + + /* (7) Si rien -> Inconnu */ + else + return 'Inconnu'; + + } +} + + + + +/*=========================================================*/ +/*********** Gestion du formulaire téléphonique ************/ +/*=========================================================*/ +/* [1] Initialisation des utilitaires et variables +=========================================================* +/* (1) Initialisation des managers */ +var cSubjectManager; +var cContactManager; +var cMiniManager; +var cFicheManager; +var cMatriceManager; + + +if( pageManager.vars[0] != null && pageManager.vars[0] == 'phone' ){ + + + /* (2) Fonctions utiles */ + function cDynamicUpdate(target){ + + + /* (0) Vérification de la cohérence de la @target + ---------------------------------------------------------*/ + var isElement = target instanceof Element; + var isSwitchLeft = isElement && target.tagName == 'SPAN' && target.className == 'switch-left'; + var isSwitchBoth = isElement && target.tagName == 'SPAN' && target.className == 'switch-both'; + 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( !isSwitchBoth && !isSwitchLeft && !isSaveButton && !isNavButton && !isNavContact && target !== true ) + return false; + + /* (1) Gestion de l'échange de nom/prénom + ---------------------------------------------------------*/ + if( isSwitchBoth ){ + console.log('> switch firstname <-> lastname'); + + /* (1) On récupère le formulaire parent */ + var currentForm = target.parentNode; + + /* (2) On récupère Nom et Prénom */ + var firstname = currentForm.children[8]; + var lastname = currentForm.children[10]; + + /* (3) On échange leurs valeurs */ + var tmp = firstname.value; + firstname.value = lastname.value; + lastname.value = tmp; + + }else if( isSwitchLeft ){ + /* (2) Gestion de l'échange Prénom+Nom = Pseudo + ---------------------------------------------------------*/ + console.log('> switch firstname+lastname -> username'); + + /* (1) On récupère le formulaire parent */ + var currentForm = target.parentNode; + + /* (2) On récupère Pseudo, Nom et Prénom */ + var username = currentForm.children[6]; + var firstname = currentForm.children[8]; + var lastname = currentForm.children[10]; + + /* (3) Vérification de la validité */ + // Si pseudo pas vide, ou nom et prenom vide -> on ne fais rien + if( username.value.length > 0 || firstname.value.length == 0 && lastname.value.length == 0 ) + return false; + + /* (4) On attribue à Pseudo, la valeur de Prénom+Nom */ + username.value = firstname.value +' '+ lastname.value; + firstname.value = ''; + lastname.value = ''; + + + /* (3) Gestion de la mise à jour dynamique + ---------------------------------------------------------*/ + }else{ + console.log('> dynamic update'); + + /* (1) On enregistre les MINI fiches relation */ + cMiniManager.fieldsToStorage(); + + /* (2) On enregister les FICHES relation */ + cFicheManager.fieldsToStorage(); + + /* (3) On enregistre les CONTACTS */ + cContactManager.fieldsToStorage(); + + /* (4) On enregistre la MATRICE */ + cMatriceManager.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 + cFicheManager.sync(); + + /* (6) On synchronise les MINI avec les CONTACTS */ + // Supprime les contacts déja dans les FICHES + cMiniManager.sync(); + + /* (7) On affiche le tout */ + cMiniManager.storageToFields(); + cFicheManager.storageToFields(); + cMatriceManager.storageToFields(); + + /* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */ + if( isSaveButton || isNavContact ) + cContactManager.storageToFields(); + } + } + + + + + + + + + + + + + + /* [2] Inclusion des scripts externes et lancement + =========================================================*/ + // TODO: Mettre les versions minifiées + 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', function(){ + + + /* (1) Gestion du formulaire du sujet + ---------------------------------------------------------*/ + /* (1) On crée une instance du manager du sujet */ + cSubjectManager = new inputPhoneSubject( + $('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'), + $('[data-sublink="phone"] article.subject-panel [data-name="number"]'), + $('[data-sublink="phone"] article.subject-panel [data-name="username"]'), + $('[data-sublink="phone"] article.subject-panel [data-name="firstname"]'), + $('[data-sublink="phone"] article.subject-panel [data-name="lastname"]'), + $('[data-sublink="phone"] article.subject-panel [data-name="submit"]') + ); + + /* (2) On le démarre */ + cSubjectManager.attach(); + + + + + + /* (2) Gestion des formulaires de contact + ---------------------------------------------------------*/ + /* (1) On crée une instance du gestionnaire des CONTACTS */ + cContactManager = new inputPhoneContact( + $('[data-sublink="phone"] article.contact-panel'), + $('[data-sublink="phone"] #p_nav-contact') + ); + + /* (2) On le démarre */ + cContactManager.attach(cDynamicUpdate); + + + + /* (3) Gestion des mini fiches relation + ---------------------------------------------------------*/ + /* (1) On crée une instance du gestionnaire des mini fiches relation */ + cMiniManager = new inputPhoneMini( + $('[data-sublink="phone"] article.mini-relation-panel'), + $('[data-sublink="phone"] #p_nav-mini') + ); + + /* (2) On le démarre */ + cMiniManager.attach(cDynamicUpdate); + + + /* (4) Gestion des fiches relation + ---------------------------------------------------------*/ + /* (1) On crée une instance du gestionnaire des fiches relation */ + cFicheManager = new inputPhoneFiche( + $('[data-sublink="phone"] article.relation-panel'), + $('[data-sublink="phone"] #p_nav-fiche') + ); + + /* (2) On le démarre */ + cFicheManager.attach(cDynamicUpdate); + + + /* (5) Gestion de la matrice de relations + ---------------------------------------------------------*/ + /* (1) On crée une instance du gestionnaire de la matrice */ + cMatriceManager = new inputPhoneMatrice( + $('[data-sublink="phone"] article.matrice-panel') + ); + + /* (2) On le démarre */ + cMatriceManager.attach(cDynamicUpdate); + + + + + + + + + + + + /* (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', + phone_number: $('[data-sublink="phone"] #p_subject_phone_number').value, + 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 sujet 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 */ + cSubjectManager.tmp_id.value = response.tmp_id; + cSubjectManager.fieldsToStorage(); + cSubjectManager.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] ]; + + var splittedName = conData.name.split(' '); + + lsi.set('contacts', conData.id, { + uid: conData.id, + number: conData.number, + username: splittedName.length == 1 ? splittedName[0] : '', // Si un seul mot -> pseudo + firstname: splittedName.length > 1 ? splittedName[0] : '', // Si plusieurs mots -> le 1er est le prénom + lastname: splittedName.length > 1 ? splittedName.splice(1).join(' ') : '', // et les autres sont le 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('contacts', conData.id); + created.sms = i; + lsi.set('contacts', conData.id, created); + continue; + } + + var splittedName = conData.name.split(' '); + + + lsi.set('contacts', conData.id, { + uid: conData.id, + number: conData.number, + username: splittedName.length == 1 ? splittedName[0] : '', // Si un seul mot -> pseudo + firstname: splittedName.length > 1 ? splittedName[0] : '', // Si plusieurs mots -> le 1er est le prénom + lastname: splittedName.length > 1 ? splittedName.splice(1).join(' ') : '', // et les autres sont le 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]; + + // On découpe le nom par espaces + var splittedName = conData.name.split(' '); + + + lsi.set('contacts', conData.id, { + uid: conData.id, + number: conData.number, + username: splittedName.length == 1 ? splittedName[0] : '', // Si un seul mot -> pseudo + firstname: splittedName.length > 1 ? splittedName[0] : '', // Si plusieurs mots -> le 1er est le prénom + lastname: splittedName.length > 1 ? splittedName.splice(1).join(' ') : '', // et les autres sont le nom + countsms: conData.sms, // Nombre de sms + countcall: conData.call, // Nombre d'appels + call: -1, + sms: -1 + }); + } + + /* (8) On met à jour l'affichage */ + cContactManager.storageToFields(); + cDynamicUpdate(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 + ---------------------------------------------------------*/ + $('[data-sublink="phone"] #p_clear-all').addEventListener('click', function(e){ + /* (1) On vide tous les dataset de données */ + lsi.clear('subject'); + lsi.clear('contacts'); + lsi.clear('mini-fiches'); + lsi.clear('fiches'); + lsi.clear('matrice'); + + + /* (2) On met à jour l'affichage */ + cSubjectManager.storageToFields(); + cContactManager.storageToFields(); + cMiniManager.storageToFields(); + cFicheManager.storageToFields(); + cMatriceManager.storageToFields(); + + Notification.success('OK', 'Les données ont été supprimées'); + }, false); + + + + /* (8) Gestion de l'export des données locales + ---------------------------------------------------------*/ + $('[data-sublink="phone"] #p_export-all').addEventListener('click', function(e){ + + Notification.info('INFORMATION', 'Lancement du téléchargement de la sauvegarde'); + + /* (1) On construit les données */ + var data = { + subject: lsi.export('subject')[0], + contacts: lsi.export('contacts'), + mini: lsi.export('mini-fiches'), + fiches: lsi.export('fiches'), + matrice: lsi.export('matrice')[0] + }; + + + /* (2) On lance le téléchargement */ + var downloadTarget = $('[data-sublink="phone"] #p_download-target'); // On récupère le lien () caché qui fera le téléchargement + downloadTarget.download = 'local-phone-data.json'; // Nom du fichier qui sera téléchargé + downloadTarget.href = 'data:application/octet-stream,' + encodeURIComponent(JSON.stringify(data)); // Contenu + downloadTarget.click(); // On lance le téléchargement + + }, false); + + + + + /* (9) Gestion de l'import des données locales + ---------------------------------------------------------*/ + // Le bouton lance l' file + $('[data-sublink="phone"] #p_import-all').addEventListener('click', function(e){ + $('[data-sublink="phone"] #local-upload').click(); + }, false); + + + // 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); + + // 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] + }; + + /* (2) Upload et réponse */ + api.send(request, function(response){ + console.log(response); + + // Si erreur, on quitte + if( response.ModuleError != 0 ){ + Notification.error('Erreur', response.ModuleError); + return false; + } + + /* (3) On enregistre les données dans le 'localStorage' */ + lsi.set('subject', 0, response.local_data.subject); + lsi.import('contacts', response.local_data.contacts); + lsi.import('mini-fiches', response.local_data.mini); + lsi.import('fiches', response.local_data.fiches); + lsi.set('matrice', 0, response.local_data.matrice); + + /* (3) On met à jour l'affichage */ + cSubjectManager.storageToFields(); + cContactManager.storageToFields(); + cMatriceManager.storageToFields(); + cDynamicUpdate(true); + + }); + + }, false); + + + + + /* (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'); + + /* (1) On met dans la mémoire tout les champs non enregistrés */ + cSubjectManager.fieldsToStorage(); + cContactManager.fieldsToStorage(); + cMiniManager.fieldsToStorage(); + cFicheManager.fieldsToStorage(); + + /* (2) Vérification de la validité de toutes les données */ + // {1} Vérification du sujet // + if( !cSubjectManager.check() ){ + Notification.warning('Attention', 'Vous devez saisir les informations du sujet'); + return false; + } + // {2} Vérification des mini-fiches // + var mini = lsi.export('mini-fiches'); + var i = 0; + for( var id in mini ){ if( !isNaN(id) ){ + + i++ + + if( !mini[id].valid ){ + Notification.warning('Attention', 'La fiche rapide '+i+' est incomplète et/ou incorrecte'); + return false; + } + + }} + // {3} Vérification des fiches // + //TODO: Remettre la vérification des fiches + // var fiches = lsi.export('fiches'); + // for( var id in fiches ) + // if( !fiches[id].valid ){ + // Notification.warning('Attention', 'La fiche complète '+(parseInt(id)+1)+' est incomplète et/ou incorrecte'); + // return false; + // } + + + + /* (3) On prépare la requête avec toutes les données */ + var request = { + path: 'input/phone', + + subject: lsi.export('subject')[0], + contacts: lsi.export('contacts'), + mini: lsi.export('mini-fiches'), + fiches: lsi.export('fiches'), + matrice: lsi.export('matrice')[0] + }; + + /* (4) On envoie la requête et traite la réponse */ + api.send(request, function(response){ + console.log(response); + + // Si erreur, on la notifie + if( response.ModuleError != 0 ){ + Notification.error('ERREUR', response.ModuleError); + return false; + } + + console.log(response); + + }, false); + + + }, false); + + + }); }); }); }); }); - /* (7) Si rien -> Inconnu */ - else - return 'Inconnu'; - } } @@ -159,81 +581,25 @@ function readableName(u, f, l){ -/* [2] Inclusion des scripts externes et lancement -=========================================================*/ -// TODO: Mettre les versions minifiées -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', function(){ - /* (1) Gestion du formulaire du sujet - ---------------------------------------------------------*/ - /* (1) On crée une instance du manager du sujet */ - subjectManager = new inputPhoneSubject( - $('article.subject-panel [data-name="tmp_id"]'), - $('article.subject-panel [data-name="number"]'), - $('article.subject-panel [data-name="username"]'), - $('article.subject-panel [data-name="firstname"]'), - $('article.subject-panel [data-name="lastname"]'), - $('article.subject-panel [data-name="submit"]') - ); - /* (2) On le démarre */ - subjectManager.attach(); - /* (2) Gestion des formulaires de contact - ---------------------------------------------------------*/ - /* (1) On crée une instance du gestionnaire des CONTACTS */ - contactManager = new inputPhoneContact( - $('article.contact-panel'), - $('#nav-contact') - ); - /* (2) On le démarre */ - contactManager.attach(dynamicUpdate); - /* (3) Gestion des mini fiches relation - ---------------------------------------------------------*/ - /* (1) On crée une instance du gestionnaire des mini fiches relation */ - miniManager = new inputPhoneMini( - $('article.mini-relation-panel'), - $('#nav-mini') - ); - /* (2) On le démarre */ - miniManager.attach(dynamicUpdate); - /* (4) Gestion des fiches relation - ---------------------------------------------------------*/ - /* (1) On crée une instance du gestionnaire des fiches relation */ - ficheManager = new inputPhoneFiche( - $('article.relation-panel'), - $('#nav-fiche') - ); - /* (2) On le démarre */ - ficheManager.attach(dynamicUpdate); - /* (5) Gestion de la matrice de relations - ---------------------------------------------------------*/ - /* (1) On crée une instance du gestionnaire de la matrice */ - matriceManager = new inputPhoneMatrice( - $('article.matrice-panel') - ); - /* (2) On le démarre */ - matriceManager.attach(dynamicUpdate); @@ -245,323 +611,417 @@ include('/js/includes/input-phone-matrice.js', function(){ - /* (6) Gestion de l'import du fichier - ---------------------------------------------------------*/ - // On vide l'input de type 'file' quand on clique - $('input#call_log-import[type="file"]').addEventListener('click', function(e){ - e.target.value = null; - }, false); - // Gestion de l'upload - $('input#call_log-import[type="file"]').addEventListener('change', function(e){ - /* (1) On rédige la requête */ - var request = { - path: 'upload/call_log', - phone_number: $('#subject_phone_number').value, - 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 sujet 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 */ - subjectManager.tmp_id.value = response.tmp_id; - subjectManager.fieldsToStorage(); - subjectManager.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] ]; - var splittedName = conData.name.split(' '); - lsi.set('contacts', conData.id, { - uid: conData.id, - number: conData.number, - username: splittedName.length == 1 ? splittedName[0] : '', // Si un seul mot -> pseudo - firstname: splittedName.length > 1 ? splittedName[0] : '', // Si plusieurs mots -> le 1er est le prénom - lastname: splittedName.length > 1 ? splittedName.splice(1).join(' ') : '', // et les autres sont le 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('contacts', conData.id); - created.sms = i; - lsi.set('contacts', conData.id, created); - continue; - } - var splittedName = conData.name.split(' '); - lsi.set('contacts', conData.id, { - uid: conData.id, - number: conData.number, - username: splittedName.length == 1 ? splittedName[0] : '', // Si un seul mot -> pseudo - firstname: splittedName.length > 1 ? splittedName[0] : '', // Si plusieurs mots -> le 1er est le prénom - lastname: splittedName.length > 1 ? splittedName.splice(1).join(' ') : '', // et les autres sont le 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]; - // On découpe le nom par espaces - var splittedName = conData.name.split(' '); - lsi.set('contacts', conData.id, { - uid: conData.id, - number: conData.number, - username: splittedName.length == 1 ? splittedName[0] : '', // Si un seul mot -> pseudo - firstname: splittedName.length > 1 ? splittedName[0] : '', // Si plusieurs mots -> le 1er est le prénom - lastname: splittedName.length > 1 ? splittedName.splice(1).join(' ') : '', // et les autres sont le nom - countsms: conData.sms, // Nombre de sms - countcall: conData.call, // Nombre d'appels - call: -1, - sms: -1 - }); - } - /* (8) On met à jour l'affichage */ - contactManager.storageToFields(); - dynamicUpdate(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 - ---------------------------------------------------------*/ - $('#clear-all').addEventListener('click', function(e){ - /* (1) On vide tous les dataset de données */ - lsi.clear('subject'); - lsi.clear('contacts'); - lsi.clear('mini-fiches'); - lsi.clear('fiches'); - lsi.clear('matrice'); +/*=========================================================*/ +/************ Gestion du formulaire facebook ***************/ +/*=========================================================*/ +/* [1] Initialisation des utilitaires et variables +=========================================================* +/* (1) Initialisation des managers */ +var fSubjectManager; +var fContactManager; +var fMiniManager; +var fFicheManager; +var fMatriceManager; - /* (2) On met à jour l'affichage */ - subjectManager.storageToFields(); - contactManager.storageToFields(); - miniManager.storageToFields(); - ficheManager.storageToFields(); - matriceManager.storageToFields(); +if( pageManager.vars[0] != null && pageManager.vars[0] == 'facebook' ){ - Notification.success('OK', 'Les données ont été supprimées'); - }, false); + /* (2) Fonctions utiles */ + function fDynamicUpdate(target){ - /* (8) Gestion de l'export des données locales - ---------------------------------------------------------*/ - $('#export-all').addEventListener('click', function(e){ - Notification.info('INFORMATION', 'Lancement du téléchargement de la sauvegarde'); + /* (0) Vérification de la cohérence de la @target + ---------------------------------------------------------*/ + var isElement = target instanceof Element; + var isSwitchLeft = isElement && target.tagName == 'SPAN' && target.className == 'switch-left'; + var isSwitchBoth = isElement && target.tagName == 'SPAN' && target.className == 'switch-both'; + 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'; - /* (1) On construit les données */ - var data = { - subject: lsi.export('subject')[0], - contacts: lsi.export('contacts'), - mini: lsi.export('mini-fiches'), - fiches: lsi.export('fiches'), - matrice: lsi.export('matrice')[0] - }; + // Si erreur, on retourne une erreur + if( !isSwitchBoth && !isSwitchLeft && !isSaveButton && !isNavButton && !isNavContact && target !== true ) + return false; + /* (1) Gestion de l'échange de nom/prénom + ---------------------------------------------------------*/ + if( isSwitchBoth ){ + console.log('> switch firstname <-> lastname'); - /* (2) On lance le téléchargement */ - var downloadTarget = $('#download-target'); // On récupère le lien () caché qui fera le téléchargement - downloadTarget.download = 'local-data.json'; // Nom du fichier qui sera téléchargé - downloadTarget.href = 'data:application/octet-stream,' + encodeURIComponent(JSON.stringify(data)); // Contenu - downloadTarget.click(); // On lance le téléchargement + /* (1) On récupère le formulaire parent */ + var currentForm = target.parentNode; - }, false); + /* (2) On récupère Nom et Prénom */ + var firstname = currentForm.children[8]; + var lastname = currentForm.children[10]; + /* (3) On échange leurs valeurs */ + var tmp = firstname.value; + firstname.value = lastname.value; + lastname.value = tmp; + }else if( isSwitchLeft ){ + /* (2) Gestion de l'échange Prénom+Nom = Pseudo + ---------------------------------------------------------*/ + console.log('> switch firstname+lastname -> username'); + /* (1) On récupère le formulaire parent */ + var currentForm = target.parentNode; - /* (9) Gestion de l'import des données locales - ---------------------------------------------------------*/ - // Le bouton lance l' file - $('#import-all').addEventListener('click', function(e){ - $('#local-upload').click(); - }, false); + /* (2) On récupère Pseudo, Nom et Prénom */ + var username = currentForm.children[6]; + var firstname = currentForm.children[8]; + var lastname = currentForm.children[10]; + /* (3) Vérification de la validité */ + // Si pseudo pas vide, ou nom et prenom vide -> on ne fais rien + if( username.value.length > 0 || firstname.value.length == 0 && lastname.value.length == 0 ) + return false; - // On vide l'input de type 'file' quand on clique - $('#local-upload').addEventListener('click', function(e){ - e.target.value = null; - }, false); + /* (4) On attribue à Pseudo, la valeur de Prénom+Nom */ + username.value = firstname.value +' '+ lastname.value; + firstname.value = ''; + lastname.value = ''; - // Gestion de l'upload d'une sauvegarde de formulaire local - $('#local-upload').addEventListener('change', function(e){ - /* (1) Rédaction de la requête d'upload */ - var request = { - path: 'upload/local_data', - file: $('#local-upload').files[0] - }; - /* (2) Upload et réponse */ - api.send(request, function(response){ - console.log(response); + /* (3) Gestion de la mise à jour dynamique + ---------------------------------------------------------*/ + }else{ + console.log('> dynamic update'); - // Si erreur, on quitte - if( response.ModuleError != 0 ){ - Notification.error('Erreur', response.ModuleError); - return false; - } + /* (1) On enregistre les MINI fiches relation */ + fMiniManager.fieldsToStorage(); - /* (3) On enregistre les données dans le 'localStorage' */ - lsi.set('subject', 0, response.local_data.subject); - lsi.import('contacts', response.local_data.contacts); - lsi.import('mini-fiches', response.local_data.mini); - lsi.import('fiches', response.local_data.fiches); - lsi.set('matrice', 0, response.local_data.matrice); + /* (2) On enregister les FICHES relation */ + fFicheManager.fieldsToStorage(); - /* (3) On met à jour l'affichage */ - subjectManager.storageToFields(); - contactManager.storageToFields(); - matriceManager.storageToFields(); - dynamicUpdate(true); + /* (3) On enregistre les CONTACTS */ + fContactManager.fieldsToStorage(); - }); + /* (4) On enregistre la MATRICE */ + fMatriceManager.fieldsToStorage(); - }, false); + /* (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 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(); + } + } - /* (10) Gestion de la validation et de l'envoi des données - ---------------------------------------------------------*/ - $('#submit-all').addEventListener('click', function(e){ - console.log('> GATHERING ALL DATA'); - /* (1) On met dans la mémoire tout les champs non enregistrés */ - subjectManager.fieldsToStorage(); - contactManager.fieldsToStorage(); - miniManager.fieldsToStorage(); - ficheManager.fieldsToStorage(); - /* (2) Vérification de la validité de toutes les données */ - // {1} Vérification du sujet // - if( !subjectManager.check() ){ - Notification.warning('Attention', 'Vous devez saisir les informations du sujet'); - return false; - } - // {2} Vérification des mini-fiches // - var mini = lsi.export('mini-fiches'); - var i = 0; - for( var id in mini ){ if( !isNaN(id) ){ - i++ - if( !mini[id].valid ){ - Notification.warning('Attention', 'La fiche rapide '+i+' est incomplète et/ou incorrecte'); - return false; - } - }} - // {3} Vérification des fiches // - //TODO: Remettre la vérification des fiches - // var fiches = lsi.export('fiches'); - // for( var id in fiches ) - // if( !fiches[id].valid ){ - // Notification.warning('Attention', 'La fiche complète '+(parseInt(id)+1)+' est incomplète et/ou incorrecte'); - // return false; - // } - /* (3) On prépare la requête avec toutes les données */ - var request = { - path: 'input/phone', - subject: lsi.export('subject')[0], - contacts: lsi.export('contacts'), - mini: lsi.export('mini-fiches'), - fiches: lsi.export('fiches'), - matrice: lsi.export('matrice')[0] - }; - /* (4) On envoie la requête et traite la réponse */ - api.send(request, function(response){ - console.log(response); - // Si erreur, on la notifie - if( response.ModuleError != 0 ){ - Notification.error('ERREUR', response.ModuleError); - return false; - } - console.log(response); + /* [2] Inclusion des scripts externes et lancement + =========================================================*/ + // TODO: Mettre les versions minifiées + 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(){ - }, false); + /* (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="username"]'), + $('[data-sublink="facebook"] article.subject-panel [data-name="firstname"]'), + $('[data-sublink="facebook"] article.subject-panel [data-name="lastname"]'), + $('[data-sublink="facebook"] article.subject-panel [data-name="submit"]') + ); - }, false); + /* (2) On le démarre */ + fSubjectManager.attach(); -}); }); }); }); }); + + + + /* (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') + ); + + /* (2) On le démarre */ + fContactManager.attach(fDynamicUpdate); + + + + /* (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') + ); + + /* (2) On le démarre */ + fMiniManager.attach(fDynamicUpdate); + + + /* (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') + ); + + /* (2) On le démarre */ + fFicheManager.attach(fDynamicUpdate); + + + /* (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') + ); + + /* (2) On le démarre */ + fMatriceManager.attach(fDynamicUpdate); + + + + + + /* (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('subject'); + lsi.clear('contacts'); + lsi.clear('mini-fiches'); + lsi.clear('fiches'); + lsi.clear('matrice'); + + + /* (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); + + + + /* (8) Gestion de l'export des données locales + ---------------------------------------------------------*/ + $('[data-sublink="facebook"] #f_export-all').addEventListener('click', function(e){ + + Notification.info('INFORMATION', 'Lancement du téléchargement de la sauvegarde'); + + /* (1) On construit les données */ + var data = { + subject: lsi.export('subject')[0], + contacts: lsi.export('contacts'), + mini: lsi.export('mini-fiches'), + fiches: lsi.export('fiches'), + matrice: lsi.export('matrice')[0] + }; + + + /* (2) On lance le téléchargement */ + var downloadTarget = $('[data-sublink="facebook"] #f_download-target'); // On récupère le lien () caché qui fera le téléchargement + downloadTarget.download = 'local-facebook-data.json'; // Nom du fichier qui sera téléchargé + downloadTarget.href = 'data:application/octet-stream,' + encodeURIComponent(JSON.stringify(data)); // Contenu + downloadTarget.click(); // On lance le téléchargement + + }, false); + + + + + /* (9) Gestion de l'import des données locales + ---------------------------------------------------------*/ + // Le bouton lance l' file + $('[data-sublink="facebook"] #f_import-all').addEventListener('click', function(e){ + $('[data-sublink="facebook"] #f_local-upload').click(); + }, false); + + + // 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); + + // 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] + }; + + /* (2) Upload et réponse */ + api.send(request, function(response){ + console.log(response); + + // Si erreur, on quitte + if( response.ModuleError != 0 ){ + Notification.error('Erreur', response.ModuleError); + return false; + } + + /* (3) On enregistre les données dans le 'localStorage' */ + lsi.set('subject', 0, response.local_data.subject); + lsi.import('contacts', response.local_data.contacts); + lsi.import('mini-fiches', response.local_data.mini); + lsi.import('fiches', response.local_data.fiches); + lsi.set('matrice', 0, response.local_data.matrice); + + /* (3) On met à jour l'affichage */ + fSubjectManager.storageToFields(); + fContactManager.storageToFields(); + fMatriceManager.storageToFields(); + fDynamicUpdate(true); + + }); + + }, false); + + + + + /* (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'); + + /* (1) On met dans la mémoire tout les champs non enregistrés */ + fSubjectManager.fieldsToStorage(); + fContactManager.fieldsToStorage(); + fMiniManager.fieldsToStorage(); + fFicheManager.fieldsToStorage(); + + /* (2) Vérification de la validité de toutes les données */ + // {1} Vérification du sujet // + if( !fSubjectManager.check() ){ + Notification.warning('Attention', 'Vous devez saisir les informations du sujet'); + return false; + } + // {2} Vérification des mini-fiches // + var mini = lsi.export('mini-fiches'); + var i = 0; + for( var id in mini ){ if( !isNaN(id) ){ + + i++ + + if( !mini[id].valid ){ + Notification.warning('Attention', 'La fiche rapide '+i+' est incomplète et/ou incorrecte'); + return false; + } + + }} + // {3} Vérification des fiches // + //TODO: Remettre la vérification des fiches + // var fiches = lsi.export('fiches'); + // for( var id in fiches ) + // if( !fiches[id].valid ){ + // Notification.warning('Attention', 'La fiche complète '+(parseInt(id)+1)+' est incomplète et/ou incorrecte'); + // return false; + // } + + + + /* (3) On prépare la requête avec toutes les données */ + var request = { + path: 'input/phone', + + subject: lsi.export('subject')[0], + contacts: lsi.export('contacts'), + mini: lsi.export('mini-fiches'), + fiches: lsi.export('fiches'), + matrice: lsi.export('matrice')[0] + }; + + /* (4) On envoie la requête et traite la réponse */ + api.send(request, function(response){ + console.log(response); + + // Si erreur, on la notifie + if( response.ModuleError != 0 ){ + Notification.error('ERREUR', response.ModuleError); + return false; + } + + console.log(response); + + }, false); + + + }, false); + + + }); }); }); }); }); + +}