Portage de phone->facebook en cours : 1) Modification de 'input.js' et gestion de la différenciation des pages (mais pas dynamique pour l'instant) 2) Modification de input-*-subject.js pour facebook 3) Modification de input-*-contact.js pour facebook 4) Modification du html (copie+modification id's)
This commit is contained in:
parent
621b1cbb57
commit
a158970eeb
|
@ -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.number.length;return b=b&&0<a.username.length+a.firstname.length+a.lastname.length};
|
||||
inputFacebookContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$('[data-sublink="facebook"] article.contact-panel .new-contact'),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input"],["data-name"])).deflate();if(this.check(c)){var d={uid:parseInt(c.uid),number:c.number,username:c.username,firstname:c.firstname,lastname:c.lastname,call:parseInt(c.call),sms:parseInt(c.sms),countcall:parseInt(c.countcall),countsms:parseInt(c.countsms)};d.hash=crc32(JSON.stringify(d));
|
||||
lsi.set("contacts",parseInt(c.uid),d)}}};
|
||||
inputFacebookContact.prototype.add=function(a){console.log("CONTACTS: ADD");if(null==a||null==a.uid||isNaN(a.uid))return!1;a.number=null!=a.number?a.number:"";a.username=null!=a.username?a.username:"";a.firstname=null!=a.firstname?a.firstname:"";a.lastname=null!=a.lastname?a.lastname:"";a.call=null!=a.call?a.call:-1;a.sms=null!=a.sms?a.sms:-1;a.countcall=null!=a.countcall?a.countcall:0;a.countsms=null!=a.countsms?a.countsms:0;this.container.innerHTML+=contactBuilder.build(a);a=$$('[data-sublink="facebook"] article.contact-panel .new-contact');
|
||||
for(var b=this,c=0;c<a.length;c++)a[c].removeEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1),a[c].addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)};inputFacebookContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi.keys("contacts");this.container.innerHTML="";for(var b=this.selected+10,c=this.selected;c<b&&c<a.length;c++)this.add(lsi.get("contacts",a[c]));b>=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<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
|
||||
inputFacebookContact.prototype.updateNavBar=function(){var a=lsi.keys("contacts").length;if(this.nav_container.children.length!=a){this.nav_container.innerHTML="";for(var b=0;b<a;b+=10)this.nav_container.innerHTML+='<span data-n="'+b+'">'+(1+b/10)+"</span>"}this.nav($('[data-sublink="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)};
|
|
@ -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<Object> 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 += '<span data-n="'+i+'">'+ (1+i/10) +'</span>';
|
||||
}
|
||||
|
||||
|
||||
/* (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);
|
||||
|
||||
};
|
|
@ -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<this.username.value.length+this.firstname.value.length+this.lastname.value.length};
|
||||
inputFacebookSubject.prototype.fieldsToStorage=function(){console.log("SUBJECT: FIELDS TO STORAGE");if(!this.check())return!1;lsi.set("subject",0,{username:this.username.value,firstname:this.firstname.value,lastname:this.lastname.value})};
|
||||
inputFacebookSubject.prototype.storageToFields=function(){console.log("SUBJECT: STORAGE TO FIELDS");var a=lsi.get("subject",0);null==a&&(a={username:"",firstname:"",lastname:""});this.username.value=a.username;this.firstname.value=a.firstname;this.lastname.value=a.lastname};
|
||||
inputFacebookSubject.prototype.attach=function(){function a(a){b.fieldsToStorage()&&b.storageToFields()}console.log("SUBJECT: ATTACH");lsi.createDataset("subject");var b=this;this.store_button.addEventListener("click",a,!1);this.username.addEventListener("blur",a,!1);this.firstname.addEventListener("blur",a,!1);this.lastname.addEventListener("blur",a,!1);this.storageToFields()};
|
|
@ -0,0 +1,96 @@
|
|||
/* [0] Constructeur -> 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 '<input type="text">' */
|
||||
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();
|
||||
};
|
|
@ -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.number.length;return b=b&&0<a.username.length+a.firstname.length+a.lastname.length};
|
||||
inputPhoneContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$("article.contact-panel .new-contact"),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input"],["data-name"])).deflate();if(this.check(c)){var d={uid:parseInt(c.uid),number:c.number,username:c.username,firstname:c.firstname,lastname:c.lastname,call:parseInt(c.call),sms:parseInt(c.sms),countcall:parseInt(c.countcall),countsms:parseInt(c.countsms)};d.hash=crc32(JSON.stringify(d));lsi.set("contacts",
|
||||
parseInt(c.uid),d)}}};
|
||||
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");if(null==a||null==a.uid||isNaN(a.uid))return!1;a.number=null!=a.number?a.number:"";a.username=null!=a.username?a.username:"";a.firstname=null!=a.firstname?a.firstname:"";a.lastname=null!=a.lastname?a.lastname:"";a.call=null!=a.call?a.call:-1;a.sms=null!=a.sms?a.sms:-1;a.countcall=null!=a.countcall?a.countcall:0;a.countsms=null!=a.countsms?a.countsms:0;this.container.innerHTML+=contactBuilder.build(a);a=$$("article.contact-panel .new-contact");
|
||||
inputPhoneContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$('[data-sublink="phone"] article.contact-panel .new-contact'),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input"],["data-name"])).deflate();if(this.check(c)){var d={uid:parseInt(c.uid),number:c.number,username:c.username,firstname:c.firstname,lastname:c.lastname,call:parseInt(c.call),sms:parseInt(c.sms),countcall:parseInt(c.countcall),countsms:parseInt(c.countsms)};d.hash=crc32(JSON.stringify(d));
|
||||
lsi.set("contacts",parseInt(c.uid),d)}}};
|
||||
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");if(null==a||null==a.uid||isNaN(a.uid))return!1;a.number=null!=a.number?a.number:"";a.username=null!=a.username?a.username:"";a.firstname=null!=a.firstname?a.firstname:"";a.lastname=null!=a.lastname?a.lastname:"";a.call=null!=a.call?a.call:-1;a.sms=null!=a.sms?a.sms:-1;a.countcall=null!=a.countcall?a.countcall:0;a.countsms=null!=a.countsms?a.countsms:0;this.container.innerHTML+=contactBuilder.build(a);a=$$('[data-sublink="phone"] article.contact-panel .new-contact');
|
||||
for(var b=this,c=0;c<a.length;c++)a[c].removeEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1),a[c].addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)};inputPhoneContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi.keys("contacts");this.container.innerHTML="";for(var b=this.selected+10,c=this.selected;c<b&&c<a.length;c++)this.add(lsi.get("contacts",a[c]));b>=a.length&&this.add({uid:a.length});this.updateNavBar()};
|
||||
inputPhoneContact.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"nav-contact"!=a.parentNode.id)return!1;for(var b=$$("#nav-contact > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
|
||||
inputPhoneContact.prototype.updateNavBar=function(){var a=lsi.keys("contacts").length;if(this.nav_container.children.length!=a){this.nav_container.innerHTML="";for(var b=0;b<a;b+=10)this.nav_container.innerHTML+='<span data-n="'+b+'">'+(1+b/10)+"</span>"}this.nav($('#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<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
|
||||
inputPhoneContact.prototype.updateNavBar=function(){var a=lsi.keys("contacts").length;if(this.nav_container.children.length!=a){this.nav_container.innerHTML="";for(var b=0;b<a;b+=10)this.nav_container.innerHTML+='<span data-n="'+b+'">'+(1+b/10)+"</span>"}this.nav($('[data-sublink="phone"] #p_nav-contact [data-n="'+this.selected+'"]'))};
|
||||
inputPhoneContact.prototype.attach=function(a){console.log("CONTACTS: ATTACH");lsi.createDataset("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)};
|
||||
|
|
|
@ -35,7 +35,7 @@ inputPhoneContact.prototype.fieldsToStorage = function(){
|
|||
console.log('CONTACTS: FIELDS TO STORAGE');
|
||||
|
||||
// {1} Pour chaque formulaire de contact présent //
|
||||
var visibleContacts = $$('article.contact-panel .new-contact');
|
||||
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 //
|
||||
|
@ -109,7 +109,7 @@ inputPhoneContact.prototype.add = function(objectData){
|
|||
this.container.innerHTML += contactBuilder.build(objectData);
|
||||
|
||||
// {2} On attache les évènements sur les formulaires //
|
||||
var contactForms = $$('article.contact-panel .new-contact');
|
||||
var contactForms = $$('[data-sublink="phone"] article.contact-panel .new-contact');
|
||||
|
||||
// On met à jour les listener (remove, puis add)
|
||||
var ptr = this;
|
||||
|
@ -173,7 +173,7 @@ inputPhoneContact.prototype.nav = function(element){
|
|||
return false;
|
||||
|
||||
/* (2) On désactive tous les éléments actifs */
|
||||
var activeElements = $$('#nav-contact > span.active');
|
||||
var activeElements = $$('[data-sublink="phone"] #p_nav-contact > span.active');
|
||||
for( var i = 0 ; i < activeElements.length ; i++ )
|
||||
activeElements[i].remClass('active');
|
||||
|
||||
|
@ -209,7 +209,7 @@ inputPhoneContact.prototype.updateNavBar = function(){
|
|||
|
||||
|
||||
/* (4) On séléctionne par défaut la dernière MINI fiche sélectionnée */
|
||||
this.nav( $('#nav-contact [data-n="'+( this.selected )+'"]') );
|
||||
this.nav( $('[data-sublink="phone"] #p_nav-contact [data-n="'+( this.selected )+'"]') );
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),e=crc32(JSON.stringify(c)),d=lsi.get("fiches",c.uid);if(!1!==d){if(null!=d.hash&&d.hash==e)break;c={contact:parseInt(c.contact),uid:parseInt(c.uid),sexe:c.sexe,age:c.age,job:c.job,famsit:c.famsit,studies:c.studies,reltype:c.reltype,reltypeSpecial:c.reltypeSpecial,
|
||||
inputPhoneFiche.prototype.fieldsToStorage=function(){console.log("FICHE: FIELDS TO STORAGE");for(var a=$$('[data-sublink="phone"] article.relation-panel .fiche-relation'),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),e=crc32(JSON.stringify(c)),d=lsi.get("fiches",c.uid);if(!1!==d){if(null!=d.hash&&d.hash==e)break;c={contact:parseInt(c.contact),uid:parseInt(c.uid),sexe:c.sexe,age:c.age,job:c.job,famsit:c.famsit,studies:c.studies,reltype:c.reltype,reltypeSpecial:c.reltypeSpecial,
|
||||
city:c.city,quartier:c.quartier,cp:c.cp,loc:c.loc,duration:c.duration,context:c.context,contextSpecial:c.contextSpecial,freq:c.freq,connect:c.connect,connectSpecial:c.connectSpecial,hash:e};c.valid=this.check(c);0<diff(d,c,["hash","valid","timestamp"]).length&&(console.log(diff(d,c,["hash","valid","timestamp"])),console.warn("> 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;b<c.length;b++)c[b].value==a.sexe?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');for(b=0;b<c.length;b++)c[b].value==a.famsit?
|
||||
c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(b=0;b<c.length;b++)c[b].value==a.reltype?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length;b++)c[b].value==a.loc?c[b].setAttribute("checked","checked"):
|
||||
c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(b=0;b<c.length;b++)c[b].value==a.context?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');for(b=0;b<c.length;b++)-1<a.freq.indexOf(c[b].value)?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");
|
||||
c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');for(b=0;b<c.length;b++)-1<a.connect.indexOf(c[b].value)?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("fiches");this.container.innerHTML="";for(var b in a)a[b].uid==this.selected&&this.add(a[b]);this.updateNavBar()};
|
||||
connectspecial0:a.connectSpecial[0],connectspecial1:a.connectSpecial[1]});b=$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+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;b<c.length;b++)c[b].value==a.sexe?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');
|
||||
for(b=0;b<c.length;b++)c[b].value==a.famsit?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(b=0;b<c.length;b++)c[b].value==a.reltype?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');
|
||||
for(b=0;b<c.length;b++)c[b].value==a.loc?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(b=0;b<c.length;b++)c[b].value==a.context?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');
|
||||
for(b=0;b<c.length;b++)-1<a.freq.indexOf(c[b].value)?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');for(b=0;b<c.length;b++)-1<a.connect.indexOf(c[b].value)?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};
|
||||
inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("fiches");this.container.innerHTML="";for(var b in a)a[b].uid==this.selected&&this.add(a[b]);this.updateNavBar()};
|
||||
inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");var a=lsi["export"]("contacts"),b=[],c;for(c in a){if(-1<a[c].call){var e=a[c].call;b.push(e);var d=lsi.get("fiches",e);null==d&&(d=this.defaultData);d.uid=e;d.contact=parseInt(c);lsi.set("fiches",e,d)}-1<a[c].sms&&(e=10+a[c].sms,b.push(e),d=lsi.get("fiches",e),null==d&&(d=this.defaultData),d.uid=e,d.contact=parseInt(c),lsi.set("fiches",e,d))}e=20>lsi.keys("contacts").length?lsi.keys("contacts").length:20;if(b.length<e)for(c in a){for(a=
|
||||
0;-1<b.indexOf(a)&&a<e;)a++;b.push(a);d=lsi.get("fiches",a);null==d&&(d=this.defaultData);d.uid=a;d.contact=parseInt(c);lsi.set("fiches",a,d);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<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
|
||||
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=$$('[data-sublink="phone"] #p_nav-fiche > span.active'),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
|
||||
inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("fiches");this.nav_container.innerHTML="";for(var b=Object.keys(a),c=0;c<b.length;c++){var e=parseInt(b[c]);0==e&&(this.nav_container.innerHTML+="<span>APPELS</span>");10>e&&c<b.length-1&&10<=b[c+1]?this.nav_container.innerHTML+='<span data-n="'+e+'" class="lc">'+(e%10+1)+"</span> ":(10==e&&(this.nav_container.innerHTML+='<span class="fc">SMS</span>'),this.nav_container.innerHTML+='<span data-n="'+e+'">'+(e%10+1)+"</span>")}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]))&&0<a.duration[0].length||isNaN(parseInt(a.duration[1]))&&0<a.duration[1].length||0==a.duration[0].length+a.duration[1].length||"."==a.job||"."==a.studies||"."==a.age||""==a.sexe||""==a.famsit||""==a.reltype||""==a.loc||""==a.context)return!1;for(var b=0;b<a.freq.length;b++)if(""==a.freq[b])return!1;for(b=0;b<a.connect.length;b++)if(""==a.connect[b])return!1;return"10"==a.reltype&&2>a.reltypeSpecial.length||
|
||||
"11"==a.context&&2>a.contextSpecial[0].length||"12"==a.context&&2>a.contextSpecial[1].length||"13"==a.context&&2>a.contextSpecial[2].length?!1:!0};inputPhoneFiche.prototype.attach=function(a){console.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)};
|
||||
|
|
|
@ -42,7 +42,7 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
|
|||
console.log('FICHE: FIELDS TO STORAGE');
|
||||
|
||||
// {1} Pour chaque formulaire de contact présent //
|
||||
var existingFiches = $$('article.relation-panel .fiche-relation');
|
||||
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 //
|
||||
|
@ -191,65 +191,65 @@ inputPhoneFiche.prototype.add = function(objectData){
|
|||
|
||||
|
||||
/* {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+'"]');
|
||||
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+'"]');
|
||||
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+'"]');
|
||||
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 <radio> pour le SEXE */
|
||||
var sexeCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');
|
||||
var sexeCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');
|
||||
for( var i = 0 ; i < sexeCreated.length ; i++ )
|
||||
if( sexeCreated[i].value == objectData.sexe ) sexeCreated[i].setAttribute('checked', 'checked');
|
||||
else sexeCreated[i].removeAttribute('checked');
|
||||
|
||||
|
||||
/* {10} On sélectionna la valeur des boutons <radio> pour la SITUATION FAMILIALE */
|
||||
var famsitCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');
|
||||
var famsitCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');
|
||||
for( var i = 0 ; i < famsitCreated.length ; i++ )
|
||||
if( famsitCreated[i].value == objectData.famsit ) famsitCreated[i].setAttribute('checked', 'checked');
|
||||
else famsitCreated[i].removeAttribute('checked');
|
||||
|
||||
|
||||
/* {11} On sélectionna la valeur des boutons <radio> pour le TYPE DE RELATION */
|
||||
var reltypeCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');
|
||||
var reltypeCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');
|
||||
for( var i = 0 ; i < reltypeCreated.length ; i++ )
|
||||
if( reltypeCreated[i].value == objectData.reltype ) reltypeCreated[i].setAttribute('checked', 'checked');
|
||||
else reltypeCreated[i].removeAttribute('checked');
|
||||
|
||||
|
||||
/* {12} On sélectionna la valeur des boutons <radio> pour la LOCATION */
|
||||
var locCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');
|
||||
var locCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');
|
||||
for( var i = 0 ; i < locCreated.length ; i++ )
|
||||
if( locCreated[i].value == objectData.loc ) locCreated[i].setAttribute('checked', 'checked');
|
||||
else locCreated[i].removeAttribute('checked');
|
||||
|
||||
|
||||
/* {13} On sélectionna la valeur des boutons <radio> pour le CONTEXTE DE RENCONTRE */
|
||||
var contextCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="context"]');
|
||||
var contextCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="context"]');
|
||||
for( var i = 0 ; i < contextCreated.length ; i++ )
|
||||
if( contextCreated[i].value == objectData.context ) contextCreated[i].setAttribute('checked', 'checked');
|
||||
else contextCreated[i].removeAttribute('checked');
|
||||
|
||||
|
||||
/* {14} On sélectionna la valeur des boutons <radio> pour les FREQUENCES */
|
||||
var freqCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');
|
||||
var freqCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');
|
||||
for( var i = 0 ; i < freqCreated.length ; i++ )
|
||||
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 <radio> pour les CONNECTIONS */
|
||||
var connectCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');
|
||||
var connectCreated = $$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');
|
||||
for( var i = 0 ; i < connectCreated.length ; i++ )
|
||||
if( objectData.connect.indexOf(connectCreated[i].value) > -1 ) connectCreated[i].setAttribute('checked', 'checked');
|
||||
else connectCreated[i].removeAttribute('checked');
|
||||
|
@ -452,7 +452,7 @@ inputPhoneFiche.prototype.nav = function(element){
|
|||
return false;
|
||||
|
||||
/* (2) On désactive tous les éléments actifs */
|
||||
var activeElements = $$('#nav-fiche > span.active');
|
||||
var activeElements = $$('[data-sublink="phone"] #p_nav-fiche > span.active');
|
||||
for( var i = 0 ; i < activeElements.length ; i++ )
|
||||
activeElements[i].remClass('active');
|
||||
|
||||
|
@ -504,7 +504,7 @@ inputPhoneFiche.prototype.updateNavBar = function(){
|
|||
/* (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;
|
||||
|
@ -519,7 +519,7 @@ inputPhoneFiche.prototype.updateNavBar = function(){
|
|||
}
|
||||
|
||||
/* (4) On séléctionne par défaut le dernier sélectionné */
|
||||
this.nav( $('#nav-fiche [data-n="'+this.selected+'"]') );
|
||||
this.nav( $('[data-sublink="phone"] #p_nav-fiche [data-n="'+this.selected+'"]') );
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),e=crc32(JSON.stringify(c)),d=lsi.get("mini-fiches",c.uid);if(!1!==d){if(null!=d&&null!=d.hash&&d.hash==e)break;console.warn("> 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<diff(d,c,["hash","valid","timestamp"]).length&&(console.log(diff(d,c,["hash","valid","timestamp"])),console.warn("> 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<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),e=crc32(JSON.stringify(c)),d=lsi.get("mini-fiches",c.uid);if(!1!==d){if(null!=d&&null!=d.hash&&d.hash==e)break;console.warn("> 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<diff(d,c,["hash","valid","timestamp"]).length&&(console.log(diff(d,c,["hash","valid","timestamp"])),console.warn("> 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;b<c.length;b++)c[b].value==a.sexe?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(b=0;b<c.length;b++)c[b].value==a.reltype?c[b].setAttribute("checked","checked"):
|
||||
c[b].removeAttribute("checked");c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length;b++)c[b].value==a.loc?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi.get("mini-fiches",this.selected);if(null==a)return this.updateNavBar(),!1;this.container.innerHTML="";this.add(a);this.updateNavBar()};
|
||||
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=$('[data-sublink="phone"] 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=$('[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;b<c.length;b++)c[b].value==a.sexe?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(b=0;b<c.length;b++)c[b].value==
|
||||
a.reltype?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length;b++)c[b].value==a.loc?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};
|
||||
inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi.get("mini-fiches",this.selected);if(null==a)return this.updateNavBar(),!1;this.container.innerHTML="";this.add(a);this.updateNavBar()};
|
||||
inputPhoneMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");var a=lsi["export"]("contacts"),b=lsi["export"]("fiches"),c=[],e;for(e in b)-1==c.indexOf(b[e].contact)&&c.push(b[e].contact);for(var d in a)-1<c.indexOf(parseInt(d))?lsi.del("mini-fiches",d):(b=0==a[d].username.length+a[d].firstname.length+a[d].lastname.length?d.toString()+"-":d,e=lsi.get("mini-fiches",b),null==e&&(e=this.defaultData,e.valid=!1,isNaN(b)&&(e.reltype="9")),e.uid=parseInt(d),lsi.set("mini-fiches",b,e));e=lsi["export"]("mini-fiches");
|
||||
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=$$("#nav-mini > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
|
||||
inputPhoneMini.prototype.updateNavBar=function(){var a=lsi["export"]("mini-fiches");this.nav_container.innerHTML="";var b=0,c;for(c in a)isNaN(c)||(this.nav_container.innerHTML+='<span data-n="'+c+'">'+ ++b+"</span>");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.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
|
||||
inputPhoneMini.prototype.updateNavBar=function(){var a=lsi["export"]("mini-fiches");this.nav_container.innerHTML="";var b=0,c;for(c in a)isNaN(c)||(this.nav_container.innerHTML+='<span data-n="'+c+'">'+ ++b+"</span>");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)};
|
||||
|
|
|
@ -31,7 +31,7 @@ inputPhoneMini.prototype.fieldsToStorage = function(){
|
|||
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');
|
||||
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']);
|
||||
|
@ -139,29 +139,29 @@ inputPhoneMini.prototype.add = function(objectData){
|
|||
|
||||
|
||||
/* {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+'"]');
|
||||
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+'"]');
|
||||
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 <radio> pour le SEXE */
|
||||
var sexeCreated = $$('article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="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 <radio> 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"]');
|
||||
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 <radio> pour la LOCATION */
|
||||
var locCreated = $$('article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');
|
||||
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');
|
||||
|
@ -302,7 +302,7 @@ inputPhoneMini.prototype.nav = function(element){
|
|||
return false;
|
||||
|
||||
/* (2) On désactive tous les éléments actifs */
|
||||
var activeElements = $$('#nav-mini > span.active');
|
||||
var activeElements = $$('[data-sublink="phone"] #p_nav-mini > span.active');
|
||||
for( var i = 0 ; i < activeElements.length ; i++ )
|
||||
activeElements[i].remClass('active');
|
||||
|
||||
|
@ -339,7 +339,7 @@ inputPhoneMini.prototype.updateNavBar = function(){
|
|||
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;
|
||||
|
@ -358,7 +358,7 @@ inputPhoneMini.prototype.updateNavBar = function(){
|
|||
|
||||
|
||||
/* (3) On séléctionne par défaut la dernière MINI fiche sélectionnée */
|
||||
this.nav( $('#nav-mini [data-n="'+this.selected+'"]') );
|
||||
this.nav( $('[data-sublink="phone"] #p_nav-mini [data-n="'+this.selected+'"]') );
|
||||
};
|
||||
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
131
view/input.php
131
view/input.php
|
@ -39,17 +39,17 @@
|
|||
<h3 data-n='0' class='color4'>Effacer les données de la dernière enquête</h3>
|
||||
<span data-space></span>
|
||||
<h4 class='self color2' data-icon=''>
|
||||
<a style='display:none' id='download-target'></a>
|
||||
<input type='submit' class='primary' id='export-all' value="Sauvegarder l'enquête"><br>
|
||||
<a style='display:none' id='p_download-target'></a>
|
||||
<input type='submit' class='primary' id='p_export-all' value="Sauvegarder l'enquête"><br>
|
||||
</h4>
|
||||
|
||||
<h4 class='self color2' data-icon='u'>
|
||||
<input type='file' id='local-upload' style='display: none;'>
|
||||
<input type='submit' class='primary' id='import-all' value='Récupérer une sauvegarde'><br>
|
||||
<input type='file' id='p_local-upload' style='display: none;'>
|
||||
<input type='submit' class='primary' id='p_import-all' value='Récupérer une sauvegarde'><br>
|
||||
</h4>
|
||||
|
||||
<h4 class='self color2' data-icon='w'>
|
||||
<input type='submit' class='primary' id='clear-all' value='Tout effacer'>
|
||||
<input type='submit' class='primary' id='p_clear-all' value='Tout effacer'>
|
||||
</h4>
|
||||
<span data-space></span>
|
||||
|
||||
|
@ -61,7 +61,7 @@
|
|||
<article class='subject-panel'>
|
||||
<h4 class='self color2' data-icon='a'>
|
||||
<input type='hidden' data-name='tmp_id' value=''>
|
||||
<input type='text' data-name='number' id='subject_phone_number' placeholder='Numéro de téléphone'>
|
||||
<input type='text' data-name='number' id='p_subject_phone_number' placeholder='Numéro de téléphone'>
|
||||
<input type='text' data-name='username' placeholder='Pseudo'>
|
||||
<input type='text' data-name='firstname' placeholder='Prénom'>
|
||||
<input type='text' data-name='lastname' placeholder='Nom'>
|
||||
|
@ -75,7 +75,7 @@
|
|||
<span data-space></span>
|
||||
<h5 data-text="Seuls les fichiers au format XML et spécifiques sont pris en compte."></h5>
|
||||
<h4 data-icon='u' class='color2'>
|
||||
<input type='file' id='call_log-import'>
|
||||
<input type='file' id='p_call_log-import'>
|
||||
<span class='file-input'>Importer un journal d'appels</span>
|
||||
</h4>
|
||||
<span data-space></span>
|
||||
|
@ -92,7 +92,7 @@
|
|||
<h5 data-text="Renseigner au moins un des nominatifs pour chaque contact. (pseudo, prénom et/ou nom)"></h5>
|
||||
|
||||
<span data-space></span>
|
||||
<div class='arrow-container line' id='nav-contact'></div>
|
||||
<div class='arrow-container line' id='p_nav-contact'></div>
|
||||
|
||||
<article class='contact-panel'>
|
||||
</article>
|
||||
|
@ -105,7 +105,7 @@
|
|||
<h3 data-n='3' class='color4'>Remplir les fiches relations rapides pour tous les contacts</h3>
|
||||
<!-- NAVIGATION ENTRE LES FICHES -->
|
||||
<span data-space></span>
|
||||
<div class='arrow-container line' id='nav-mini'></div>
|
||||
<div class='arrow-container line' id='p_nav-mini'></div>
|
||||
|
||||
<article class='mini-relation-panel'>
|
||||
|
||||
|
@ -117,7 +117,7 @@
|
|||
<!-- GESTION DES FICHES RELATIONS -->
|
||||
<h3 data-n='4' class='color4'>Remplir les fiches relations complètes des contacts les plus contactés</h3>
|
||||
<!-- NAVIGATION ENTRE LES FICHES -->
|
||||
<div class='arrow-container line' id='nav-fiche'></div>
|
||||
<div class='arrow-container line' id='p_nav-fiche'></div>
|
||||
<article class='relation-panel'></article>
|
||||
<span data-space></span>
|
||||
|
||||
|
@ -133,7 +133,7 @@
|
|||
<h3 data-n='6' class='color4'>Envoi des données</h3>
|
||||
<article class='submit-panel'>
|
||||
<h4>
|
||||
<input type='submit' class='line' value='Envoyer le formulaire' id='submit-all'>
|
||||
<input type='submit' class='line' value='Envoyer le formulaire' id='p_submit-all'>
|
||||
</h4>
|
||||
</article>
|
||||
|
||||
|
@ -146,8 +146,111 @@
|
|||
|
||||
|
||||
|
||||
<?php /* [4] ADMIN -> Donnees de Messenger
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?php /* [4] ADMIN -> Donnees Facebook
|
||||
=========================================================*/
|
||||
?><section data-sublink='messenger'>
|
||||
Messenger
|
||||
?><section data-sublink='facebook'> <!-- IMPORT ou SAISIE -->
|
||||
|
||||
<section data-timeline>
|
||||
|
||||
<h3 data-n='0' class='color4'>Effacer les données de la dernière enquête</h3>
|
||||
<span data-space></span>
|
||||
<h4 class='self color2' data-icon=''>
|
||||
<a style='display:none' id='f_download-target'></a>
|
||||
<input type='submit' class='primary' id='f_export-all' value="Sauvegarder l'enquête"><br>
|
||||
</h4>
|
||||
|
||||
<h4 class='self color2' data-icon='u'>
|
||||
<input type='file' id='f_local-upload' style='display: none;'>
|
||||
<input type='submit' class='primary' id='f_import-all' value='Récupérer une sauvegarde'><br>
|
||||
</h4>
|
||||
|
||||
<h4 class='self color2' data-icon='w'>
|
||||
<input type='submit' class='primary' id='f_clear-all' value='Tout effacer'>
|
||||
</h4>
|
||||
<span data-space></span>
|
||||
|
||||
|
||||
|
||||
<h3 data-n='1' class='color4'>Identifier l'enquêté</h3>
|
||||
<span data-space></span>
|
||||
<h5 data-text="Renseigner au moins un des nominatifs pour chaque amis. (pseudo, prénom et/ou nom)"></h5>
|
||||
<article class='subject-panel'>
|
||||
<h4 class='self color2' data-icon='a'>
|
||||
<input type='text' data-name='username' placeholder='Pseudo'>
|
||||
<input type='text' data-name='firstname' placeholder='Prénom'>
|
||||
<input type='text' data-name='lastname' placeholder='Nom'>
|
||||
<input type='submit' class='primary' data-name='submit' data-store value='Enregistrer'>
|
||||
</h4>
|
||||
</article>
|
||||
<span data-space></span>
|
||||
|
||||
<h3 data-n='2' class='color4'>Saisir manuellement les amis</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- GESTION DE L'AJOUT DES CONTACTS -->
|
||||
<span data-space></span>
|
||||
<h5 data-text="Renseigner au moins un des nominatifs pour chaque amis. (pseudo, prénom et/ou nom)"></h5>
|
||||
|
||||
<span data-space></span>
|
||||
<div class='arrow-container line' id='f_nav-contact'></div>
|
||||
|
||||
<article class='contact-panel'>
|
||||
</article>
|
||||
<span data-space></span>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- GESTION DES MINI-FICHES RELATIONS -->
|
||||
<h3 data-n='3' class='color4'>Remplir les fiches relations rapides pour tous les amis</h3>
|
||||
<!-- NAVIGATION ENTRE LES FICHES -->
|
||||
<span data-space></span>
|
||||
<div class='arrow-container line' id='f_nav-mini'></div>
|
||||
|
||||
<article class='mini-relation-panel'>
|
||||
|
||||
</article>
|
||||
<span data-space></span>
|
||||
|
||||
|
||||
|
||||
<!-- GESTION DES FICHES RELATIONS -->
|
||||
<h3 data-n='4' class='color4'>Remplir les fiches relations complètes des amis les plus proches</h3>
|
||||
<!-- NAVIGATION ENTRE LES FICHES -->
|
||||
<div class='arrow-container line' id='f_nav-fiche'></div>
|
||||
<article class='relation-panel'></article>
|
||||
<span data-space></span>
|
||||
|
||||
|
||||
|
||||
<!-- MATRICE RELATIONNELLE DES 2 TOP 10 -->
|
||||
<h3 data-n='5' class='color4'>Saisir les matrices des relations entre les amis les plus proches</h3>
|
||||
<!-- NAVIGATION ENTRE LES FICHES -->
|
||||
<article class='matrice-panel'></article>
|
||||
|
||||
|
||||
<!-- BOUTON D'ENVOI DU FORMULAIRE -->
|
||||
<h3 data-n='6' class='color4'>Envoi des données</h3>
|
||||
<article class='submit-panel'>
|
||||
<h4>
|
||||
<input type='submit' class='line' value='Envoyer le formulaire' id='f_submit-all'>
|
||||
</h4>
|
||||
</article>
|
||||
|
||||
</section>
|
||||
<span data-space></span>
|
||||
|
||||
</section>
|
||||
|
|
|
@ -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<e.value.length||0==a.value.length&&0==b.value.length)return!1;e.value=a.value+" "+b.value;a.value="";b.value=""}else console.log("> 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 0<a.length?0<e+c?a+" ("+(f+" "+b).trim()+")":a:0<e+c?(f+" "+b).trim():"Inconnu"}
|
||||
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(){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"]'));subjectManager.attach();contactManager=new inputPhoneContact($("article.contact-panel"),$("#nav-contact"));contactManager.attach(dynamicUpdate);miniManager=new inputPhoneMini($("article.mini-relation-panel"),$("#nav-mini"));miniManager.attach(dynamicUpdate);ficheManager=new inputPhoneFiche($("article.relation-panel"),$("#nav-fiche"));ficheManager.attach(dynamicUpdate);matriceManager=new inputPhoneMatrice($("article.matrice-panel"));
|
||||
matriceManager.attach(dynamicUpdate);$('input#call_log-import[type="file"]').addEventListener("click",function(a){a.target.value=null},!1);$('input#call_log-import[type="file"]').addEventListener("change",function(a){a={path:"upload/call_log",phone_number:$("#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 <b>sujet</b> 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<a.call.length;e++){var c=a.directory[a.call[e]],d=c.name.split(" ");lsi.set("contacts",c.id,{uid:c.id,number:c.number,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:c.sms,countcall:c.call,call:e,sms:-1})}for(e=0;e<
|
||||
a.sms.length;e++)c=a.directory[a.sms[e]],-1<a.call.indexOf(a.sms[e])?(d=lsi.get("contacts",c.id),d.sms=e,lsi.set("contacts",c.id,d)):(d=c.name.split(" "),lsi.set("contacts",c.id,{uid:c.id,number:c.number,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:c.sms,countcall:c.call,call:-1,sms:e}));for(var g in a.directory)g=parseInt(g),-1<a.call.indexOf(g)||-1<a.sms.indexOf(g)||(c=a.directory[g],d=c.name.split(" "),lsi.set("contacts",c.id,{uid:c.id,
|
||||
number:c.number,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:c.sms,countcall:c.call,call:-1,sms:-1}));contactManager.storageToFields();dynamicUpdate(!0);null!=b&&b.click();Notification.success("OK","Chargement termin\u00e9")}})},!1);$("#clear-all").addEventListener("click",function(a){lsi.clear("subject");lsi.clear("contacts");lsi.clear("mini-fiches");lsi.clear("fiches");lsi.clear("matrice");subjectManager.storageToFields();contactManager.storageToFields();
|
||||
miniManager.storageToFields();ficheManager.storageToFields();matriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$("#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 f=
|
||||
$("#download-target");f.download="local-data.json";f.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));f.click()},!1);$("#import-all").addEventListener("click",function(a){$("#local-upload").click()},!1);$("#local-upload").addEventListener("click",function(a){a.target.value=null},!1);$("#local-upload").addEventListener("change",function(a){a={path:"upload/local_data",file:$("#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);subjectManager.storageToFields();contactManager.storageToFields();matriceManager.storageToFields();dynamicUpdate(!0)})},!1);$("#submit-all").addEventListener("click",function(a){console.log("> GATHERING ALL DATA");subjectManager.fieldsToStorage();contactManager.fieldsToStorage();
|
||||
miniManager.fieldsToStorage();ficheManager.fieldsToStorage();if(!subjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!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 <i>fiche rapide</i> <b>"+f+"</b> 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<a.length?0<e+d?a+" ("+(c+" "+b).trim()+")":a:0<e+d?(c+" "+b).trim():"Inconnu"}var cSubjectManager,cContactManager,cMiniManager,cFicheManager,cMatriceManager;
|
||||
if(null!=pageManager.vars[0]&&"phone"==pageManager.vars[0]){var cDynamicUpdate=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&&("p_nav-mini"==a.parentNode.id||"p_nav-fiche"==a.parentNode.id),c=c&&"SPAN"==a.tagName&&"p_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<e.value.length||0==a.value.length&&0==b.value.length)return!1;e.value=a.value+" "+b.value;a.value="";b.value=""}else console.log("> 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 <b>sujet</b> 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<a.call.length;e++){var d=a.directory[a.call[e]],f=d.name.split(" ");lsi.set("contacts",d.id,{uid:d.id,number:d.number,username:1==f.length?f[0]:"",firstname:1<f.length?f[0]:"",lastname:1<f.length?f.splice(1).join(" "):"",countsms:d.sms,countcall:d.call,call:e,sms:-1})}for(e=0;e<a.sms.length;e++)d=a.directory[a.sms[e]],
|
||||
-1<a.call.indexOf(a.sms[e])?(f=lsi.get("contacts",d.id),f.sms=e,lsi.set("contacts",d.id,f)):(f=d.name.split(" "),lsi.set("contacts",d.id,{uid:d.id,number:d.number,username:1==f.length?f[0]:"",firstname:1<f.length?f[0]:"",lastname:1<f.length?f.splice(1).join(" "):"",countsms:d.sms,countcall:d.call,call:-1,sms:e}));for(var g in a.directory)g=parseInt(g),-1<a.call.indexOf(g)||-1<a.sms.indexOf(g)||(d=a.directory[g],f=d.name.split(" "),lsi.set("contacts",d.id,{uid:d.id,number:d.number,username:1==f.length?
|
||||
f[0]:"",firstname:1<f.length?f[0]:"",lastname:1<f.length?f.splice(1).join(" "):"",countsms:d.sms,countcall:d.call,call:-1,sms:-1}));cContactManager.storageToFields();cDynamicUpdate(!0);null!=b&&b.click();Notification.success("OK","Chargement termin\u00e9")}})},!1);$('[data-sublink="phone"] #p_clear-all').addEventListener("click",function(a){lsi.clear("subject");lsi.clear("contacts");lsi.clear("mini-fiches");lsi.clear("fiches");lsi.clear("matrice");cSubjectManager.storageToFields();cContactManager.storageToFields();
|
||||
cMiniManager.storageToFields();cFicheManager.storageToFields();cMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="phone"] #p_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches"),matrice:lsi["export"]("matrice")[0]};
|
||||
var c=$('[data-sublink="phone"] #p_download-target');c.download="local-phone-data.json";c.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));c.click()},!1);$('[data-sublink="phone"] #p_import-all').addEventListener("click",function(a){$('[data-sublink="phone"] #local-upload').click()},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("change",function(a){a=
|
||||
{path:"upload/local_data",file:$('[data-sublink="phone"] #p_local-upload').files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("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);cSubjectManager.storageToFields();cContactManager.storageToFields();cMatriceManager.storageToFields();
|
||||
cDynamicUpdate(!0)})},!1);$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");cSubjectManager.fieldsToStorage();cContactManager.fieldsToStorage();cMiniManager.fieldsToStorage();cFicheManager.fieldsToStorage();if(!cSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!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 <i>fiche rapide</i> <b>"+c+"</b> 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<e.value.length||0==a.value.length&&0==b.value.length)return!1;e.value=a.value+" "+b.value;a.value="";b.value=""}else console.log("> 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 <i>sujet</i>"),
|
||||
!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 <i>fiche rapide</i> <b>"+c+"</b> 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)})})})})})};
|
||||
|
|
690
view/js/input.js
690
view/js/input.js
|
@ -1,23 +1,59 @@
|
|||
// 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
|
||||
|
||||
/* 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;
|
||||
|
||||
/* (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()+')';
|
||||
|
||||
/* (4) Si @username uniquement -> username */
|
||||
else
|
||||
return u;
|
||||
|
||||
/* (5) Si pas @username */
|
||||
}else{
|
||||
|
||||
/* (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 subjectManager;
|
||||
var contactManager;
|
||||
var miniManager;
|
||||
var ficheManager;
|
||||
var matriceManager;
|
||||
var cSubjectManager;
|
||||
var cContactManager;
|
||||
var cMiniManager;
|
||||
var cFicheManager;
|
||||
var cMatriceManager;
|
||||
|
||||
|
||||
if( pageManager.vars[0] != null && pageManager.vars[0] == 'phone' ){
|
||||
|
||||
|
||||
/* (2) Fonctions utiles */
|
||||
function dynamicUpdate(target){
|
||||
function cDynamicUpdate(target){
|
||||
|
||||
|
||||
/* (0) Vérification de la cohérence de la @target
|
||||
|
@ -26,8 +62,8 @@ function dynamicUpdate(target){
|
|||
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';
|
||||
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 )
|
||||
|
@ -80,70 +116,34 @@ function dynamicUpdate(target){
|
|||
console.log('> dynamic update');
|
||||
|
||||
/* (1) On enregistre les MINI fiches relation */
|
||||
miniManager.fieldsToStorage();
|
||||
cMiniManager.fieldsToStorage();
|
||||
|
||||
/* (2) On enregister les FICHES relation */
|
||||
ficheManager.fieldsToStorage();
|
||||
cFicheManager.fieldsToStorage();
|
||||
|
||||
/* (3) On enregistre les CONTACTS */
|
||||
contactManager.fieldsToStorage();
|
||||
cContactManager.fieldsToStorage();
|
||||
|
||||
/* (4) On enregistre la MATRICE */
|
||||
matriceManager.fieldsToStorage();
|
||||
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
|
||||
ficheManager.sync();
|
||||
cFicheManager.sync();
|
||||
|
||||
/* (6) On synchronise les MINI avec les CONTACTS */
|
||||
// Supprime les contacts déja dans les FICHES
|
||||
miniManager.sync();
|
||||
cMiniManager.sync();
|
||||
|
||||
/* (7) On affiche le tout */
|
||||
miniManager.storageToFields();
|
||||
ficheManager.storageToFields();
|
||||
matriceManager.storageToFields();
|
||||
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 )
|
||||
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;
|
||||
|
||||
/* (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()+')';
|
||||
|
||||
/* (4) Si @username uniquement -> username */
|
||||
else
|
||||
return u;
|
||||
|
||||
/* (5) Si pas @username */
|
||||
}else{
|
||||
|
||||
/* (6) Si @firstname et/ou @lastname -> firstname lastname*/
|
||||
if( fl+ll > 0 )
|
||||
return (f+' '+l).trim();
|
||||
|
||||
/* (7) Si rien -> Inconnu */
|
||||
else
|
||||
return 'Inconnu';
|
||||
|
||||
cContactManager.storageToFields();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,17 +172,17 @@ 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"]')
|
||||
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 */
|
||||
subjectManager.attach();
|
||||
cSubjectManager.attach();
|
||||
|
||||
|
||||
|
||||
|
@ -191,49 +191,49 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
/* (2) Gestion des formulaires de contact
|
||||
---------------------------------------------------------*/
|
||||
/* (1) On crée une instance du gestionnaire des CONTACTS */
|
||||
contactManager = new inputPhoneContact(
|
||||
$('article.contact-panel'),
|
||||
$('#nav-contact')
|
||||
cContactManager = new inputPhoneContact(
|
||||
$('[data-sublink="phone"] article.contact-panel'),
|
||||
$('[data-sublink="phone"] #p_nav-contact')
|
||||
);
|
||||
|
||||
/* (2) On le démarre */
|
||||
contactManager.attach(dynamicUpdate);
|
||||
cContactManager.attach(cDynamicUpdate);
|
||||
|
||||
|
||||
|
||||
/* (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')
|
||||
cMiniManager = new inputPhoneMini(
|
||||
$('[data-sublink="phone"] article.mini-relation-panel'),
|
||||
$('[data-sublink="phone"] #p_nav-mini')
|
||||
);
|
||||
|
||||
/* (2) On le démarre */
|
||||
miniManager.attach(dynamicUpdate);
|
||||
cMiniManager.attach(cDynamicUpdate);
|
||||
|
||||
|
||||
/* (4) Gestion des fiches relation
|
||||
---------------------------------------------------------*/
|
||||
/* (1) On crée une instance du gestionnaire des fiches relation */
|
||||
ficheManager = new inputPhoneFiche(
|
||||
$('article.relation-panel'),
|
||||
$('#nav-fiche')
|
||||
cFicheManager = new inputPhoneFiche(
|
||||
$('[data-sublink="phone"] article.relation-panel'),
|
||||
$('[data-sublink="phone"] #p_nav-fiche')
|
||||
);
|
||||
|
||||
/* (2) On le démarre */
|
||||
ficheManager.attach(dynamicUpdate);
|
||||
cFicheManager.attach(cDynamicUpdate);
|
||||
|
||||
|
||||
/* (5) Gestion de la matrice de relations
|
||||
---------------------------------------------------------*/
|
||||
/* (1) On crée une instance du gestionnaire de la matrice */
|
||||
matriceManager = new inputPhoneMatrice(
|
||||
$('article.matrice-panel')
|
||||
cMatriceManager = new inputPhoneMatrice(
|
||||
$('[data-sublink="phone"] article.matrice-panel')
|
||||
);
|
||||
|
||||
/* (2) On le démarre */
|
||||
matriceManager.attach(dynamicUpdate);
|
||||
cMatriceManager.attach(cDynamicUpdate);
|
||||
|
||||
|
||||
|
||||
|
@ -248,16 +248,16 @@ 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){
|
||||
$('[data-sublink="phone"] input#p_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){
|
||||
$('[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: $('#subject_phone_number').value,
|
||||
phone_number: $('[data-sublink="phone"] #p_subject_phone_number').value,
|
||||
file: e.target.files[0]
|
||||
};
|
||||
|
||||
|
@ -279,9 +279,9 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
|
||||
|
||||
/* (3) On enregistre l'identifiant temporaire du sujet */
|
||||
subjectManager.tmp_id.value = response.tmp_id;
|
||||
subjectManager.fieldsToStorage();
|
||||
subjectManager.storageToFields();
|
||||
cSubjectManager.tmp_id.value = response.tmp_id;
|
||||
cSubjectManager.fieldsToStorage();
|
||||
cSubjectManager.storageToFields();
|
||||
|
||||
|
||||
|
||||
|
@ -375,8 +375,8 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
}
|
||||
|
||||
/* (8) On met à jour l'affichage */
|
||||
contactManager.storageToFields();
|
||||
dynamicUpdate(true);
|
||||
cContactManager.storageToFields();
|
||||
cDynamicUpdate(true);
|
||||
|
||||
|
||||
/* (9) On notifie la fin du chargement */
|
||||
|
@ -395,7 +395,7 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
|
||||
/* (7) Gestion de l'effacement des données locales
|
||||
---------------------------------------------------------*/
|
||||
$('#clear-all').addEventListener('click', function(e){
|
||||
$('[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');
|
||||
|
@ -405,11 +405,11 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
|
||||
|
||||
/* (2) On met à jour l'affichage */
|
||||
subjectManager.storageToFields();
|
||||
contactManager.storageToFields();
|
||||
miniManager.storageToFields();
|
||||
ficheManager.storageToFields();
|
||||
matriceManager.storageToFields();
|
||||
cSubjectManager.storageToFields();
|
||||
cContactManager.storageToFields();
|
||||
cMiniManager.storageToFields();
|
||||
cFicheManager.storageToFields();
|
||||
cMatriceManager.storageToFields();
|
||||
|
||||
Notification.success('OK', 'Les données ont été supprimées');
|
||||
}, false);
|
||||
|
@ -418,7 +418,7 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
|
||||
/* (8) Gestion de l'export des données locales
|
||||
---------------------------------------------------------*/
|
||||
$('#export-all').addEventListener('click', function(e){
|
||||
$('[data-sublink="phone"] #p_export-all').addEventListener('click', function(e){
|
||||
|
||||
Notification.info('INFORMATION', 'Lancement du téléchargement de la sauvegarde');
|
||||
|
||||
|
@ -433,8 +433,8 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
|
||||
|
||||
/* (2) On lance le téléchargement */
|
||||
var downloadTarget = $('#download-target'); // On récupère le lien (<a>) caché qui fera le téléchargement
|
||||
downloadTarget.download = 'local-data.json'; // Nom du fichier qui sera téléchargé
|
||||
var downloadTarget = $('[data-sublink="phone"] #p_download-target'); // On récupère le lien (<a>) 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
|
||||
|
||||
|
@ -446,22 +446,22 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
/* (9) Gestion de l'import des données locales
|
||||
---------------------------------------------------------*/
|
||||
// Le bouton lance l'<input> file
|
||||
$('#import-all').addEventListener('click', function(e){
|
||||
$('#local-upload').click();
|
||||
$('[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
|
||||
$('#local-upload').addEventListener('click', function(e){
|
||||
$('[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
|
||||
$('#local-upload').addEventListener('change', function(e){
|
||||
$('[data-sublink="phone"] #p_local-upload').addEventListener('change', function(e){
|
||||
/* (1) Rédaction de la requête d'upload */
|
||||
var request = {
|
||||
path: 'upload/local_data',
|
||||
file: $('#local-upload').files[0]
|
||||
file: $('[data-sublink="phone"] #p_local-upload').files[0]
|
||||
};
|
||||
|
||||
/* (2) Upload et réponse */
|
||||
|
@ -482,10 +482,10 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
lsi.set('matrice', 0, response.local_data.matrice);
|
||||
|
||||
/* (3) On met à jour l'affichage */
|
||||
subjectManager.storageToFields();
|
||||
contactManager.storageToFields();
|
||||
matriceManager.storageToFields();
|
||||
dynamicUpdate(true);
|
||||
cSubjectManager.storageToFields();
|
||||
cContactManager.storageToFields();
|
||||
cMatriceManager.storageToFields();
|
||||
cDynamicUpdate(true);
|
||||
|
||||
});
|
||||
|
||||
|
@ -496,18 +496,18 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
|
||||
/* (10) Gestion de la validation et de l'envoi des données
|
||||
---------------------------------------------------------*/
|
||||
$('#submit-all').addEventListener('click', function(e){
|
||||
$('[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 */
|
||||
subjectManager.fieldsToStorage();
|
||||
contactManager.fieldsToStorage();
|
||||
miniManager.fieldsToStorage();
|
||||
ficheManager.fieldsToStorage();
|
||||
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( !subjectManager.check() ){
|
||||
if( !cSubjectManager.check() ){
|
||||
Notification.warning('Attention', 'Vous devez saisir les informations du <i>sujet</i>');
|
||||
return false;
|
||||
}
|
||||
|
@ -565,3 +565,463 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
|
||||
|
||||
}); }); }); }); });
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*=========================================================*/
|
||||
/************ Gestion du formulaire facebook ***************/
|
||||
/*=========================================================*/
|
||||
|
||||
/* [1] Initialisation des utilitaires et variables
|
||||
=========================================================*
|
||||
/* (1) Initialisation des managers */
|
||||
var fSubjectManager;
|
||||
var fContactManager;
|
||||
var fMiniManager;
|
||||
var fFicheManager;
|
||||
var fMatriceManager;
|
||||
|
||||
if( pageManager.vars[0] != null && pageManager.vars[0] == 'facebook' ){
|
||||
|
||||
|
||||
|
||||
/* (2) Fonctions utiles */
|
||||
function fDynamicUpdate(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 == 'f_nav-mini' || target.parentNode.id == 'f_nav-fiche');
|
||||
var isNavContact = isElement && target.tagName == 'SPAN' && target.parentNode.id == 'f_nav-contact';
|
||||
|
||||
// Si erreur, on retourne une erreur
|
||||
if( !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 */
|
||||
fMiniManager.fieldsToStorage();
|
||||
|
||||
/* (2) On enregister les FICHES relation */
|
||||
fFicheManager.fieldsToStorage();
|
||||
|
||||
/* (3) On enregistre les CONTACTS */
|
||||
fContactManager.fieldsToStorage();
|
||||
|
||||
/* (4) On enregistre la MATRICE */
|
||||
fMatriceManager.fieldsToStorage();
|
||||
|
||||
/* (5) On synchronise les FICHE avec les CONTACTS */
|
||||
// 1. On synchronise les `mini` et `fiches` associées en fonction de la dernière date de modification
|
||||
// 2. On synchronise les `fiches` dupliquées en fonction de la dernière date de modification
|
||||
fFicheManager.sync();
|
||||
|
||||
/* (6) On synchronise les MINI avec les CONTACTS */
|
||||
// Supprime les contacts déja dans les FICHES
|
||||
fMiniManager.sync();
|
||||
|
||||
/* (7) On 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* [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(){
|
||||
|
||||
|
||||
/* (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"]')
|
||||
);
|
||||
|
||||
/* (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 (<a>) 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'<input> 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 <i>sujet</i>');
|
||||
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 <i>fiche rapide</i> <b>'+i+'</b> 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 <i>fiche complète</i> <b>'+(parseInt(id)+1)+'</b> 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);
|
||||
|
||||
|
||||
}); }); }); }); });
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue