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

7 lines
2.2 KiB
JavaScript
Raw Permalink Normal View History

2016-10-10 08:58:44 +00:00
var inputPhoneMatrice=function(a){this.container=a};inputPhoneMatrice.prototype={container:this.container};
inputPhoneMatrice.prototype.fieldsToStorage=function(){console.group("[phone.matrice] fields to storage");var a=(new FormDeflater(this.container,["input"],["data-name"])).deflate();crc32(JSON.stringify(a));var c={},b;for(b in a)if(a[b]instanceof Array)for(var e in a[b])null==c[b]&&(c[b]=[]),c[b].push(parseInt(a[b][e]));else null!==a[b]&&(null==c[b]&&(c[b]=[]),c[b].push(parseInt(a[b])));lsi.set("p_matrice",0,c);console.groupEnd()};
inputPhoneMatrice.prototype.storageToFields=function(){console.group("[phone.matrice] storage to fields");var a=lsi["export"]("p_fiches"),c=lsi.get("p_matrice",0),b=lsi["export"]("p_contacts"),e=[],d;for(d in a)-1==e.indexOf(a[d].contact)&&e.push(a[d].contact);a=["<table class='line'>"];for(d=0;d<e.length;d++){var f=b[d];a.push("<tr>");0<d?(a.push('<td style="text-align: right;">'),a.push(isNaN(f.existing)?f.username:lsi.get("p_friends",f.existing).name),a.push("</td>")):a.push("<td></td>");for(var h=
0;h<e.length;h++)if(h<e.length-1){var g=b[h];0==d?(a.push("<td>"),a.push('<span style="writing-mode: vertical-lr; text-align: right;">'),a.push(isNaN(g.existing)?g.username:lsi.get("p_friends",g.existing).name),a.push("</span>")):h<d?(a.push("<td>"),a.push("<input type='checkbox' name='matrice_"+f.uid+"_"+g.uid+"' data-name='"+f.uid+"' value='"+g.uid+"' id='p_matrice_"+f.uid+"_"+g.uid+"'"),null!=c[d]&&-1<c[d].indexOf(h)&&a.push(" checked"),a.push(" >"),a.push("<label for='p_matrice_"+f.uid+"_"+g.uid+
"'></label>")):a.push("<td class='hidden'>");a.push("</td>")}a.push("</tr>")}a.push("</table>");this.container.innerHTML=a.join("");console.groupEnd()};inputPhoneMatrice.prototype.attach=function(){console.group("[phone.matrice] attaching events");lsi.createDataset("p_matrice");this.storageToFields();var a=this;this.container.addEventListener("click",function(c){a.fieldsToStorage();setTimeout(function(){a.storageToFields()},500)},!1);console.groupEnd()};
2016-10-10 08:58:44 +00:00
inputPhoneMatrice.prototype.parseGrid=function(){var a=$$(".matrice-panel input[data-name][value]"),c;for(c in a)if(a[c]instanceof Element){var b=a[c].getData("name"),e=a[c].value;this.sGrid[b]instanceof Array||(this.sGrid[b]=[]);this.sGrid[b][e]=a[c]}};