NxTIC/view/js/input-min.js

8 lines
2.6 KiB
JavaScript
Raw Normal View History

var clearAllButton=$("#clear-all"),importCallLog=$('input#call_log-import[type="file"]'),subjectManager,contactManager,miniManager,ficheManager;
function dynamicUpdate(a){var b="SPAN"==a.tagName&&"switch-left"==a.className,c="SPAN"==a.tagName&&"switch-both"==a.className,e="INPUT"==a.tagName&&"submit"==a.type,d="SPAN"==a.tagName&&("nav-mini"==a.parentNode.id||"nav-fiche"==a.parentNode.id);if(!(c||b||e||d)&&!0!==a)return!1;c?(console.log("> switch firstname <-> lastname"),b=a.parentNode,a=b.children[3],b=b.children[5],c=a.value,a.value=b.value,b.value=c):b?(console.log("> switch firstname+lastname -> username"),b=a.parentNode,c=b.children[1],
a=b.children[3],b=b.children[5],c.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(),contactManager.storageToFields())}function checkRadioValue(a){for(var b=0,c=0;c<a.length;c++)!0===a[c].status&&b++;return 1!=b?!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);
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 b=0;b<a.directory.length&&20>b;b++){var d=a.directory[b].name.split(" ");lsi.set("contacts","form"+b,{uid:b,number:a.directory[b].number,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):""})}dynamicUpdate()}}))})},!1);clearAllButton.addEventListener("click",
function(a){localStorage.clear();reload()},!1)})})})});