NxTIC/js/includes/input-phone-matrice-min.js

6 lines
1.7 KiB
JavaScript

function inputPhoneMatrice(a){this.container=a}inputPhoneMatrice.prototype={container:this.container};
inputPhoneMatrice.prototype.fieldsToStorage=function(){console.log("MATRICE: FIELDS TO STORAGE");var a=(new FormDeflater(this.container,["input"],["data-name"])).deflate();crc32(JSON.stringify(a));var d={},b;for(b in a)if(a[b]instanceof Array)for(var g in a[b])null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b][g]));else null!==a[b]&&(null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b])));lsi.set("matrice",0,d)};
inputPhoneMatrice.prototype.storageToFields=function(){console.log("MATRICE: STORAGE TO FIELDS");var a=lsi["export"]("fiches"),d=lsi.get("matrice",0),b=lsi["export"]("contacts"),g=[],c;for(c in a)-1==g.indexOf(a[c].contact)&&g.push(a[c].contact);a="<table class='line'>";for(c=0;c<g.length;c++){var e=b[c],a=a+"<tr>";0<c?(a+='<td style="text-align: right;">',a+=e.firstname+" "+e.lastname,a+=0<e.username.length?" ("+e.username+")":"",a+="</td>"):a+="<td></td>";for(var h=0;h<g.length;h++)if(h<g.length-
1){var f=b[h];0==c?(a+="<td>",a+='<span style="writing-mode: vertical-lr; text-align: right;">',a+=f.firstname+" "+f.lastname,a+=0<f.username.length?" ("+f.username+")":"",a+="</span>"):h<c?(a+="<td>",a+="<input type='checkbox' name='matrice_"+e.uid+"_"+f.uid+"' data-name='"+e.uid+"' value='"+f.uid+"' id='matrice_"+e.uid+"_"+f.uid+"'",null!=d[c]&&-1<d[c].indexOf(h)&&(a+=" checked"),a+=" >",a+="<label for='matrice_"+e.uid+"_"+f.uid+"'></label>"):a+="<td class='hidden'>";a+="</td>"}a+="</tr>"}this.container.innerHTML=
a+"</table>"};inputPhoneMatrice.prototype.attach=function(){console.log("MATRICE: ATTACH");lsi.createDataset("matrice");this.storageToFields();var a=this;this.container.addEventListener("click",function(d){a.fieldsToStorage();a.storageToFields()},!1)};