Affichage partiel des contacts (10/10)
This commit is contained in:
parent
996dd38060
commit
b641c732f8
|
@ -1,5 +1,8 @@
|
|||
function inputPhoneContact(a){this.container=a}inputPhoneContact.prototype={container:this.container,handler:null};
|
||||
inputPhoneContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$("article.contact-panel .new-contact"),c=0;c<a.length;c++){var d=a[c].parentNode.children.indexOf(a[c]),b=(new FormDeflater(a[c],["input"],["data-name"])).deflate(),e=0<b.number.value.length;if(e=e&&0<b.username.value.length+b.firstname.value.length+b.lastname.value.length)b={uid:d,number:b.number.value,username:b.username.value,firstname:b.firstname.value,lastname:b.lastname.value},b.hash=
|
||||
crc32(JSON.stringify(b)),lsi.set("contacts","form"+d,b)}};
|
||||
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");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:"";this.container.innerHTML+=contactBuilder.build(a);a=$$("article.contact-panel .new-contact");for(var c=this,d=0;d<a.length;d++)a[d].removeEventListener("click",function(a){c.handler(a.target)},!1),a[d].addEventListener("click",function(a){c.handler(a.target)},!1)};
|
||||
inputPhoneContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi["export"]("contacts");this.container.innerHTML="";for(var c in a)this.add(a[c]);this.add({number:"",firstname:"",lastname:"",username:""})};inputPhoneContact.prototype.attach=function(a){console.log("CONTACTS: ATTACH");lsi.createDataset("contacts");this.handler=a};
|
||||
function inputPhoneContact(a,b){this.container=a;this.nav_container=b}inputPhoneContact.prototype={container:this.container,nav_container:this.nav_container,selected:1,handler:null};
|
||||
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=a[b].parentNode.children.indexOf(a[b]),d=(new FormDeflater(a[b],["input"],["data-name"])).deflate(),e=0<d.number.value.length;if(e=e&&0<d.username.value.length+d.firstname.value.length+d.lastname.value.length)d={uid:c,number:d.number.value,username:d.username.value,firstname:d.firstname.value,lastname:d.lastname.value},d.hash=
|
||||
crc32(JSON.stringify(d)),lsi.set("contacts","form"+c,d)}};
|
||||
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");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:"";this.container.innerHTML+=contactBuilder.build(a);a=$$("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=10*(this.selected-1)+10,c=10*(this.selected-1);c<b&&c<a.length;c++)this.add(lsi.get("contacts",a[c]));b>=a.length&&this.add({number:"",firstname:"",lastname:"",username:""});this.updateNavBar()};
|
||||
inputPhoneContact.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML)||"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.innerHTML)};
|
||||
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>"+(1+b/10)+"</span>"}this.nav(this.nav_container.children[this.selected-1])};
|
||||
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)};
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
/* [0] Constructeur -> définit le conteneur et le bouton d'ajout
|
||||
=========================================================*/
|
||||
function inputPhoneContact(container){
|
||||
this.container = container;
|
||||
function inputPhoneContact(container, navContainer){
|
||||
this.container = container;
|
||||
this.nav_container = navContainer;
|
||||
}
|
||||
|
||||
/* [1] Attributs
|
||||
=========================================================*/
|
||||
inputPhoneContact.prototype = {
|
||||
container: this.container, // Conteneur des formulaires de contact
|
||||
handler: null // Fonction pour l'enregistrement et la synchronisation des données
|
||||
container: this.container, // Conteneur des formulaires de contact
|
||||
nav_container: this.nav_container, // Conteneur de la navigation entre les formulaires
|
||||
selected: 1, // UID du permier des contacts sélectionnés (10 par 10)
|
||||
handler: null // Fonction pour l'enregistrement et la synchronisation des données
|
||||
};
|
||||
|
||||
|
||||
|
@ -93,8 +96,8 @@ inputPhoneContact.prototype.add = function(objectData){
|
|||
// 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.handler(e.target); }, false);
|
||||
contactForms[i].addEventListener('click', function(e){ ptr.handler(e.target); }, false);
|
||||
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);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -114,23 +117,86 @@ inputPhoneContact.prototype.storageToFields = function(){
|
|||
console.log('CONTACTS: STORAGE TO FIELDS');
|
||||
|
||||
// {1} Pour chaque contact du 'localStorage' //
|
||||
var contactsData = lsi.export('contacts');
|
||||
var contactKeys = lsi.keys('contacts');
|
||||
|
||||
// On réinitialise le HTML
|
||||
this.container.innerHTML = '';
|
||||
|
||||
// {2} On ajoute chaque contact à la liste //
|
||||
for( var key in contactsData )
|
||||
this.add(contactsData[key]);
|
||||
// {2} On ajoute chaque contact (parmi les séléctionnés) à la liste //
|
||||
var min = 10*(this.selected-1); // On affiche du contact sélectionné
|
||||
var max = 10*(this.selected-1)+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
|
||||
this.add({number:'', firstname:'', lastname:'', username:''});
|
||||
// On ajoute un champ de plus à remplir si c'est la dernière page
|
||||
if( max >= contactKeys.length )
|
||||
this.add({number:'', firstname:'', lastname:'', username:''});
|
||||
|
||||
/* (3) On met à jour la barre de navigation */
|
||||
this.updateNavBar();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* [6] Gestion de la navigation entre les formulaires (10 par 10)
|
||||
=========================================================*/
|
||||
inputPhoneContact.prototype.nav = function(element){
|
||||
/* (1) On vérifie que l'élément contient un nombre et existe */
|
||||
if( typeof element == 'undefined' )
|
||||
return false;
|
||||
|
||||
if( isNaN(element.innerHTML) || element.parentNode.id != 'nav-contact' )
|
||||
return false;
|
||||
|
||||
/* (2) On désactive tous les éléments actifs */
|
||||
var activeElements = $$('#nav-contact > span.active');
|
||||
for( var i = 0 ; i < activeElements.length ; i++ )
|
||||
activeElements[i].remClass('active');
|
||||
|
||||
/* (3) On active l'élément courant */
|
||||
element.addClass('active');
|
||||
this.selected = parseInt(element.innerHTML);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* [7] Mise à jour de la navigation
|
||||
=========================================================*/
|
||||
inputPhoneContact.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>'+ (1+i/10) +'</span>';
|
||||
}
|
||||
|
||||
/* (4) On séléctionne par défaut la dernière MINI fiche sélectionnée */
|
||||
this.nav( this.nav_container.children[this.selected-1] );
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* [5] Point d'amorçage de la gestion des contacts
|
||||
=========================================================*/
|
||||
inputPhoneContact.prototype.attach = function(handler){
|
||||
|
@ -139,9 +205,19 @@ inputPhoneContact.prototype.attach = function(handler){
|
|||
/* (1) On initialise le jeu de données */
|
||||
lsi.createDataset('contacts');
|
||||
|
||||
/* (2) On enregistre le handler */
|
||||
/* (2) On charge les contacts depuis la mémoire ('localStorage') */
|
||||
this.storageToFields();
|
||||
|
||||
/* (3) On enregistre le handler */
|
||||
this.handler = handler;
|
||||
|
||||
/* (3) On charge les contacts depuis la mémoire ('localStorage') */
|
||||
// this.storageToFields();
|
||||
/* (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);
|
||||
|
||||
};
|
||||
|
|
|
@ -15,7 +15,7 @@ a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+a.job+'"]');null!=b&
|
|||
c[b].removeAttribute("checked");for(c=0;c<a.freq.length;c++)for(var d=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq'+c+'"]'),b=0;b<d.length&&b<a.freq[c].length;b++)a.freq[c][b].status?d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked");for(c=0;c<a.connect.length;c++)for(d=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect'+c+'"]'),b=0;b<d.length&&b<a.connect[c].length;b++)a.connect[c][b].status?
|
||||
d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked")};inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("fiches");this.container.innerHTML="";var b=[],c;for(c in a){var d=a[c].uid;d==this.selected&&this.add(a[c]);b.push(d)}this.updateNavBar(b)};
|
||||
inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");for(var a=lsi.keys("contacts"),b=0;b<a.length&&10>b;b++){var c=lsi.get("contacts",a[b]),d=lsi.get("fiches",a[b]);null==d&&(d=this.defaultData);d.uid=c.uid;d.firstname=c.firstname;d.lastname=c.lastname;d.username=c.username;lsi.set("fiches",a[b],d)}};
|
||||
inputPhoneFiche.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML))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.innerHTML)-1};
|
||||
inputPhoneFiche.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML)||"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.innerHTML)-1};
|
||||
inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("fiches"),b=Object.keys(a).length;if(this.nav_container.children.length!=b){this.nav_container.innerHTML="";for(var c=0;c<b;c++)this.nav_container.innerHTML+="<span></span>"}for(var d in a)b=this.nav_container.children[a[d].uid],b.innerHTML=a[d].uid+1,!0===a[d].valid?b.addClass("done"):b.remClass("done");this.nav(this.nav_container.children[this.selected])};
|
||||
inputPhoneFiche.prototype.check=function(a){if(isNaN(parseInt(a.age))||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||!checkRadioValue(a.sexe)||!checkRadioValue(a.famsit)||!checkRadioValue(a.reltype)||!checkRadioValue(a.loc)||!checkRadioValue(a.context))return!1;for(var b=0;b<a.freq.length;b++)if(!checkRadioValue(a.freq[b]))return!1;for(b=0;b<
|
||||
a.connect.length;b++)if(!checkRadioValue(a.connect[b]))return!1;return a.reltype[8].status&&2>a.reltypeSpecial.length||a.context[11].status&&2>a.contextSpecial[0].length||a.context[12].status&&2>a.contextSpecial[1].length||a.context[13].status&&2>a.contextSpecial[2].length?!1:!0};
|
||||
|
|
|
@ -369,7 +369,7 @@ inputPhoneFiche.prototype.nav = function(element){
|
|||
if( typeof element == 'undefined' )
|
||||
return false;
|
||||
|
||||
if( isNaN(element.innerHTML) )
|
||||
if( isNaN(element.innerHTML) || element.parentNode.id != 'nav-fiche' )
|
||||
return false;
|
||||
|
||||
/* (2) On désactive tous les éléments actifs */
|
||||
|
|
|
@ -5,6 +5,6 @@ inputPhoneMini.prototype.add=function(a){console.log("MINI FICHE: ADD");if(null=
|
|||
miniFicheBuilder.build({firstname:a.firstname,lastname:a.lastname,username:a.username,uid:a.uid,age:a.age,job:a.job});var b=$('article.mini-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");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<a.sexe.length;b++)a.sexe[b].status?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<a.loc.length;b++)a.loc[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi["export"]("mini-fiches");this.container.innerHTML="";this.add(a["form"+this.selected]);this.updateNavBar()};
|
||||
inputPhoneMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");var a=lsi["export"]("contacts"),b;for(b in a){var c=lsi.get("mini-fiches",b);null==c&&(c=this.defaultData,c.valid=!1);c.uid=a[b].uid;c.firstname=a[b].firstname;c.lastname=a[b].lastname;c.username=a[b].username;lsi.set("mini-fiches",b,c)}};
|
||||
inputPhoneMini.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML))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.innerHTML)-1};
|
||||
inputPhoneMini.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML)||"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.innerHTML)-1};
|
||||
inputPhoneMini.prototype.updateNavBar=function(){var a=lsi["export"]("mini-fiches"),b=Object.keys(a).length;if(this.nav_container.children.length!=b){this.nav_container.innerHTML="";for(var c=0;c<b;c++)this.nav_container.innerHTML+="<span></span>"}for(var d in a)b=this.nav_container.children[a[d].uid],b.innerHTML=a[d].uid+1,!0===a[d].valid?b.addClass("done"):b.remClass("done");this.nav(this.nav_container.children[this.selected])};
|
||||
inputPhoneMini.prototype.check=function(a){return!isNaN(parseInt(a.age))&&checkRadioValue(a.sexe)&&"."!=a.job&&checkRadioValue(a.loc)?!0:!1};inputPhoneMini.prototype.attach=function(a){console.log("MINI FICHE: ATTACH");lsi.createDataset("mini-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)};
|
||||
inputPhoneMini.prototype.check=function(a){return!isNaN(parseInt(a.age))&&checkRadioValue(a.sexe)&&"."!=a.job&&checkRadioValue(a.loc)?!0:!1};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)};
|
||||
|
|
|
@ -9,7 +9,7 @@ function inputPhoneMini(container, navContainer){
|
|||
=========================================================*/
|
||||
inputPhoneMini.prototype = {
|
||||
container: this.container, // Conteneur des mini fiches relation
|
||||
nav_container: this.nav_container, // Conteneur de la navigation entre les fiches
|
||||
nav_container: this.nav_container, // Conteneur de la navigation entre les MINI fiches
|
||||
selected: 0, // UID de la MINI fiche sélectionnée
|
||||
handler: null, // Fonction pour l'enregistrement et la synchronisation des données
|
||||
defaultData: { // Valeur par défaut
|
||||
|
@ -223,7 +223,7 @@ inputPhoneMini.prototype.nav = function(element){
|
|||
if( typeof element == 'undefined' )
|
||||
return false;
|
||||
|
||||
if( isNaN(element.innerHTML) )
|
||||
if( isNaN(element.innerHTML) || element.parentNode.id != 'nav-mini' )
|
||||
return false;
|
||||
|
||||
/* (2) On désactive tous les éléments actifs */
|
||||
|
@ -325,9 +325,8 @@ inputPhoneMini.prototype.attach = function(handler){
|
|||
/* (3) On attache la barre de navigation à une fonction */
|
||||
// On enregistre le handler
|
||||
this.handler = handler;
|
||||
var ptr = this;
|
||||
|
||||
/* (2) On attache l'évènement sur le bouton d'ajout de contact */
|
||||
/* (2) On attache l'évènement sur le conteneur de navigation */
|
||||
var ptr = this;
|
||||
this.nav_container.addEventListener('click', function(e){
|
||||
// 1. On gère la navigation
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
for( $i = 0 ; $i < count($fetchData) ; $i++ ) // pour tout les utilisateurs
|
||||
foreach($fetchData[$i] as $col => $val){ // pour toutes les entrées
|
||||
|
||||
if( !mb_detect_encoding($val, 'UTF-8') )
|
||||
if( !\mb_detect_encoding($val, 'UTF-8') )
|
||||
$fetchData[$i][$col] = utf8_encode($val);
|
||||
|
||||
if( is_int($col) ){ // Si indice numerique
|
||||
|
@ -143,7 +143,7 @@
|
|||
// on supprime les doublons des entrées (indice numérique)
|
||||
foreach($fetchData as $i=>$val){ // pour toutes les entrées
|
||||
|
||||
if( !mb_detect_encoding($val, 'UTF-8') )
|
||||
if( !\mb_detect_encoding($val, 'UTF-8') )
|
||||
$fetchData[$i] = utf8_encode($val);
|
||||
|
||||
if( is_int($i) ){ // Si indice numerique
|
||||
|
|
|
@ -71,9 +71,18 @@
|
|||
<!-- <span data-tag='OU'></span> -->
|
||||
<h3 data-n='2' class='color4'>Saisir manuellement les contacts</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- GESTION DE L'AJOUT DES CONTACTS -->
|
||||
<span data-space></span>
|
||||
<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>
|
||||
|
||||
<article class='contact-panel'>
|
||||
</article>
|
||||
<span data-space></span>
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
var clearAllButton=$("#clear-all"),importCallLog=$('input#call_log-import[type="file"]'),subjectManager,contactManager,miniManager,ficheManager;
|
||||
function dynamicUpdate(a){var c=a instanceof Element,b=c&&"SPAN"==a.tagName&&"switch-left"==a.className,d=c&&"SPAN"==a.tagName&&"switch-both"==a.className,e=c&&"INPUT"==a.tagName&&"submit"==a.type,c=c&&"SPAN"==a.tagName&&("nav-mini"==a.parentNode.id||"nav-fiche"==a.parentNode.id);if(!(d||b||e||c)&&!0!==a)return!1;d?(console.log("> switch firstname <-> lastname"),b=a.parentNode,a=b.children[3],b=b.children[5],d=a.value,a.value=b.value,b.value=d):b?(console.log("> switch firstname+lastname -> username"),
|
||||
b=a.parentNode,d=b.children[1],a=b.children[3],b=b.children[5],d.value=a.value+" "+b.value,a.value="",b.value=""):(console.log("> dynamic update"),miniManager.fieldsToStorage(),ficheManager.fieldsToStorage(),contactManager.fieldsToStorage(),miniManager.sync(),ficheManager.sync(),miniManager.storageToFields(),ficheManager.storageToFields(),e&&contactManager.storageToFields())}function checkRadioValue(a){for(var c=0,b=0;b<a.length;b++)!0===a[b].status&&c++;return 1!=c?!1:!0}
|
||||
function dynamicUpdate(a){var c=a instanceof Element,b=c&&"SPAN"==a.tagName&&"switch-left"==a.className,d=c&&"SPAN"==a.tagName&&"switch-both"==a.className,e=c&&"INPUT"==a.tagName&&"submit"==a.type,f=c&&"SPAN"==a.tagName&&("nav-mini"==a.parentNode.id||"nav-fiche"==a.parentNode.id),c=c&&"SPAN"==a.tagName&&"nav-contact"==a.parentNode.id;if(!(d||b||e||f||c)&&!0!==a)return!1;d?(console.log("> switch firstname <-> lastname"),b=a.parentNode,a=b.children[3],b=b.children[5],d=a.value,a.value=b.value,b.value=
|
||||
d):b?(console.log("> switch firstname+lastname -> username"),b=a.parentNode,d=b.children[1],a=b.children[3],b=b.children[5],d.value=a.value+" "+b.value,a.value="",b.value=""):(console.log("> dynamic update"),miniManager.fieldsToStorage(),ficheManager.fieldsToStorage(),contactManager.fieldsToStorage(),miniManager.sync(),ficheManager.sync(),miniManager.storageToFields(),ficheManager.storageToFields(),(e||c)&&contactManager.storageToFields())}
|
||||
function checkRadioValue(a){for(var c=0,b=0;b<a.length;b++)!0===a[b].status&&c++;return 1!=c?!1:!0}
|
||||
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(){subjectManager=new inputPhoneSubject($('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"),$("h4.add-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);importCallLog.addEventListener("change",function(a){api.send({path:"upload/call_log",file:importCallLog.files[0]},function(a){console.log(a);
|
||||
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);importCallLog.addEventListener("change",function(a){api.send({path:"upload/call_log",file:importCallLog.files[0]},function(a){console.log(a);
|
||||
0==a.ModuleError&&(importCallLog.addClass("active"),a={path:"call_log/unserialize",phone_number:$("#subject_phone_number").value},api.send(a,function(a){console.log(a);if(0==a.ModuleError){for(var d=0;d<a.directory.length;d++){var c=(null===a.directory[d].name?"":a.directory[d].name).split(" ");lsi.set("contacts","form"+d,{uid:d,number:a.directory[d].number,username:1==c.length?c[0]:"",firstname:1<c.length?c[0]:"",lastname:1<c.length?c.splice(1).join(" "):""})}contactManager.storageToFields();dynamicUpdate(!0)}}))})},
|
||||
!1);clearAllButton.addEventListener("click",function(a){localStorage.clear();reload()},!1)})})})});
|
||||
|
|
|
@ -30,9 +30,10 @@ function dynamicUpdate(target){
|
|||
var isSwitchBoth = isElement && target.tagName == 'SPAN' && target.className == 'switch-both';
|
||||
var isSaveButton = isElement && target.tagName == 'INPUT' && target.type == 'submit';
|
||||
var isNavButton = isElement && target.tagName == 'SPAN' && (target.parentNode.id == 'nav-mini' || target.parentNode.id == 'nav-fiche');
|
||||
var isNavContact = isElement && target.tagName == 'SPAN' && target.parentNode.id == 'nav-contact';
|
||||
|
||||
// Si erreur, on retourne une erreur
|
||||
if( !isSwitchBoth && !isSwitchLeft && !isSaveButton && !isNavButton && target !== true )
|
||||
if( !isSwitchBoth && !isSwitchLeft && !isSaveButton && !isNavButton && !isNavContact && target !== true )
|
||||
return false;
|
||||
|
||||
/* (1) Gestion de l'échange de nom/prénom
|
||||
|
@ -95,8 +96,8 @@ function dynamicUpdate(target){
|
|||
miniManager.storageToFields();
|
||||
ficheManager.storageToFields();
|
||||
|
||||
/* (7) On met à jour les contacts si on les a modifié */
|
||||
if( isSaveButton )
|
||||
/* (7) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
|
||||
if( isSaveButton || isNavContact )
|
||||
contactManager.storageToFields();
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +164,7 @@ include('/js/includes/input-phone-fiche.js', function(){
|
|||
/* (1) On crée une instance du gestionnaire des CONTACTS */
|
||||
contactManager = new inputPhoneContact(
|
||||
$('article.contact-panel'),
|
||||
$('h4.add-contact')
|
||||
$('#nav-contact')
|
||||
);
|
||||
|
||||
/* (2) On le démarre */
|
||||
|
|
Loading…
Reference in New Issue