6 lines
1.8 KiB
JavaScript
Executable File
6 lines
1.8 KiB
JavaScript
Executable File
function inputFacebookMatrice(a){this.container=a}inputFacebookMatrice.prototype={container:this.container};
|
|
inputFacebookMatrice.prototype.fieldsToStorage=function(){console.group("[facebook.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 f in a[b])null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b][f]));else null!==a[b]&&(null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b])));lsi.set("f_matrice",0,d);console.groupEnd()};
|
|
inputFacebookMatrice.prototype.storageToFields=function(){console.group("[facebook.matrice] storage to fields");var a=lsi["export"]("f_fiches"),d=lsi.get("f_matrice",0),b=lsi["export"]("f_contacts"),f=[],c;for(c in a)-1==f.indexOf(a[c].contact)&&f.push(a[c].contact);var a=["<div class='line matrice'>"],e,g,k,h,l;g=0;for(k=f.length;g<k;g++)for(c=b[g],h=g+1,l=f.length;h<l;h++)e=b[h],a.push("<input type='checkbox' data-name='"+c.uid+"' value='"+e.uid+"' id='f_matrice_"+c.uid+"_"+e.uid+"'"),d.hasOwnProperty(c.uid)&&
|
|
-1<d[c.uid].indexOf(e.uid)&&a.push("checked='checked'"),a.push(">"),a.push("<label class='matrice-content' for='f_matrice_"+c.uid+"_"+e.uid+"'>"),a.push("Est-ce que <span>"),a.push(isNaN(c.existing)?c.username:lsi.get("f_friends",c.existing).name),a.push("</span> et <span>"),a.push(isNaN(e.existing)?e.username:lsi.get("f_friends",e.existing).name),a.push("</span> se connaissent ?"),a.push("</label>");a.push("</div>");this.container.innerHTML=a.join("");console.groupEnd()};
|
|
inputFacebookMatrice.prototype.attach=function(){console.group("[facebook.matrice] attaching events");lsi.createDataset("f_matrice");this.storageToFields();var a=this;this.container.addEventListener("click",function(d){a.fieldsToStorage();setTimeout(function(){a.storageToFields()},500)},!1);console.groupEnd()};
|