6 lines
1.7 KiB
JavaScript
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 e in a[b])null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b][e]));else null!==a[b]&&(null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b])));lsi.set("p_matrice",0,d)};
|
|
inputPhoneMatrice.prototype.storageToFields=function(){console.log("MATRICE: STORAGE TO FIELDS");var a=lsi["export"]("p_fiches"),d=lsi.get("p_matrice",0),b=lsi["export"]("p_contacts"),e=[],c;for(c in a)-1==e.indexOf(a[c].contact)&&e.push(a[c].contact);a="<table class='line'>";for(c=0;c<e.length;c++){var f=b[c],a=a+"<tr>";0<c?(a+='<td style="text-align: right;">',a+=readableName(f.username,f.firstname,f.lastname),a+="</td>"):a+="<td></td>";for(var h=0;h<e.length;h++)if(h<e.length-1){var g=b[h];0==
|
|
c?(a+="<td>",a+='<span style="writing-mode: vertical-lr; text-align: right;">',a+=readableName(g.username,g.firstname,g.lastname),a+="</span>"):h<c?(a+="<td>",a+="<input type='checkbox' name='matrice_"+f.uid+"_"+g.uid+"' data-name='"+f.uid+"' value='"+g.uid+"' id='matrice_"+f.uid+"_"+g.uid+"'",null!=d[c]&&-1<d[c].indexOf(h)&&(a+=" checked"),a+=" >",a+="<label for='matrice_"+f.uid+"_"+g.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("p_matrice");this.storageToFields();var a=this;this.container.addEventListener("click",function(d){a.fieldsToStorage();a.storageToFields()},!1)};
|