28 lines
13 KiB
JavaScript
28 lines
13 KiB
JavaScript
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("p_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("p_contacts",d.id),f.sms=e,lsi.set("p_contacts",d.id,f)):(f=d.name.split(" "),lsi.set("p_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("p_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("p_subject");lsi.clear("p_contacts");lsi.clear("p_mini-fiches");lsi.clear("p_fiches");lsi.clear("p_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"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),
|
|
matrice:lsi["export"]("p_matrice")[0]};var 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"] #p_local-upload').click()},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("change",
|
|
function(a){a={path:"upload/local_data",file:$('[data-sublink="phone"] #p_local-upload').files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("p_subject",0,a.local_data.subject);lsi["import"]("p_contacts",a.local_data.contacts);lsi["import"]("p_mini-fiches",a.local_data.mini);lsi["import"]("p_fiches",a.local_data.fiches);lsi.set("p_matrice",0,a.local_data.matrice);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"]("p_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"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};api.send(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[2],b=b.children[3],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[1];a=b.children[2];b=b.children[3];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("f_subject");lsi.clear("f_contacts");
|
|
lsi.clear("f_mini-fiches");lsi.clear("f_fiches");lsi.clear("f_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"]("f_subject")[0],
|
|
contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};var 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("f_subject",0,a.local_data.subject);lsi["import"]("f_contacts",a.local_data.contacts);lsi["import"]("f_mini-fiches",a.local_data.mini);lsi["import"]("f_fiches",a.local_data.fiches);
|
|
lsi.set("f_matrice",0,a.local_data.matrice);fSubjectManager.storageToFields();fContactManager.storageToFields();fMatriceManager.storageToFields();fDynamicUpdate(!0)})},!1);$('[data-sublink="facebook"] #f_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");fSubjectManager.fieldsToStorage();fContactManager.fieldsToStorage();fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();if(!fSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),
|
|
!1;a=lsi["export"]("f_mini-fiches");var 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/facebook",subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};api.send(b,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",
|
|
a.ModuleError),!1;console.log(a)},!1)},!1)})})})})})};
|