NxTIC/view/js/input-min.js

12 lines
4.9 KiB
JavaScript

var subjectBuilder=new HTMLBuilder;subjectBuilder.setLayout("<h4 data-icon='p' class='self color2'> \n\t<input type='text' data-name='number' placeholder='Num\u00e9ro de t\u00e9l\u00e9phone' value='@number' > \n\t<input type='text' data-name='username' placeholder='Pseudo' value='@username' > \n\t<input type='text' data-name='firstname' placeholder='Pr\u00e9nom' value='@firstname' > \n\t<input type='text' data-name='lastname' placeholder='Nom' value='@lastname' > \n\t<input type='submit' class='primary sub-number' value='Enregistrer'>\n</h4>\n\n");
var contactBuilder=new HTMLBuilder;contactBuilder.setLayout("<h4 data-icon='p' class='new-contact color2'> \n\t<input type='text' data-name='number' placeholder='Num\u00e9ro de t\u00e9l\u00e9phone' value='@number' > \n\t<input type='text' data-name='username' placeholder='Pseudo' value='@username' > \n\t<input type='text' data-name='firstname' placeholder='Pr\u00e9nom' value='@firstname' > \n\t<input type='text' data-name='lastname' placeholder='Nom' value='@lastname' > \n\t<input type='submit' class='primary sub-number' value='Enregistrer'>\n</h4>\n\n");
var ficheBuilder=new HTMLBuilder;ficheBuilder.setLayout("<h4 data-icon='p' class='new-contact'> \t<input type='text' data-name='number' placeholder='Num\u00e9ro de t\u00e9l\u00e9phone' value='@number' > \t<input type='text' data-name='username' placeholder='Pseudo' value='@username' > \t<input type='text' data-name='firstname' placeholder='Pr\u00e9nom' value='@firstname' > \t<input type='text' data-name='lastname' placeholder='Nom' value='@lastname' > \t<input type='submit' class='primary sub-number' value='Enregistrer'></h4>");
function updateListener(a,b,c){a.removeEventListener(b,c);a.addEventListener(b,c)}
var ic=new inputChecker,FormDeflaterP={tags:["input"],attr:["data-name"]},importCallLog=$('input#call_log-import[type="file"]'),addContact=$("h4.add-contact"),addFiche=$("h4.add-fiche"),subjectInput={number:$('article.subject-panel [data-name="number"]'),username:$('article.subject-panel [data-name="username"]'),firstname:$('article.subject-panel [data-name="firstname"]'),lastname:$('article.subject-panel [data-name="lastname"]'),store:$('article.subject-panel [data-name="submit"]')};lsi.createDataset("subject");
function storeSubject(){console.log("storing subject");var a=0<subjectInput.number.value.length,a=a&&0<subjectInput.username.value.length+subjectInput.firstname.value.length+subjectInput.lastname.value.length;if(!a)return!1;lsi.set("subject","form",{number:subjectInput.number.value,username:subjectInput.username.value,firstname:subjectInput.firstname.value,lastname:subjectInput.lastname.value})}
function restoreSubject(){var a=lsi.get("subject","form");console.log(a);null!=a&&(subjectInput.number.value=a.number,subjectInput.username.value=a.username,subjectInput.firstname.value=a.firstname,subjectInput.lastname.value=a.lastname)}restoreSubject();subjectInput.store.addEventListener("click",storeSubject,!1);var contactContainer=$("article.contact-panel");lsi.createDataset("contacts");
function storeContacts(){console.log("storing all forms");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;(e=e&&0<d.username.value.length+d.firstname.value.length+d.lastname.value.length)&&lsi.set("contacts","form"+c,{number:d.number.value,username:d.username.value,firstname:d.firstname.value,lastname:d.lastname.value})}restoreContacts()}
function addNewContact(a,b,c,d){contactContainer.innerHTML+=contactBuilder.build({number:"string"!=typeof a?"":a,username:"string"!=typeof b?"":b,firstname:"string"!=typeof c?"":c,lastname:"string"!=typeof d?"":d});a=$$('article.contact-panel .new-contact input[type="submit"]');for(b=0;b<a.length;b++)updateListener(a[b],"click",storeContacts)}
function restoreContacts(){var a=lsi.keys("contacts");contactContainer.innerHTML="";for(var b=0;b<a.length;b++){var c=lsi.get("contacts",a[b]);addNewContact(c.number,c.username,c.firstname,c.lastname)}addNewContact();a=$$('article.contact-panel .new-contact input[type="submit"]');for(b=0;b<a.length;b++)updateListener(a[b],"click",storeContacts)}restoreContacts();addContact.addEventListener("click",storeContacts,!1);var ficheContainer=$("article.contact-panel");
function addNewFiche(a,b,c,d){ficheContainer.innerHTML+=contactBuilder.build({number:"string"!=typeof a?"":a,username:"string"!=typeof b?"":b,firstname:"string"!=typeof c?"":c,lastname:"string"!=typeof d?"":d})}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")})},!1);