This commit is contained in:
xdrm-brackets 2016-10-17 12:24:44 +02:00
commit c63d025971
1 changed files with 11 additions and 0 deletions

View File

@ -1,13 +1,24 @@
<<<<<<< HEAD
function inputFacebookMini(a,c){this.container=a;this.nav_container=c}inputFacebookMini.prototype={container:this.container,nav_container:this.nav_container,selected:null,handler:null,defaultData:{contact:null,sexe:"2",age:".",studies:"0",loc:".",reltype:"9",reltypeSpecial:"",unknown:!1,timestamp:0,valid:!1}}; function inputFacebookMini(a,c){this.container=a;this.nav_container=c}inputFacebookMini.prototype={container:this.container,nav_container:this.nav_container,selected:null,handler:null,defaultData:{contact:null,sexe:"2",age:".",studies:"0",loc:".",reltype:"9",reltypeSpecial:"",unknown:!1,timestamp:0,valid:!1}};
inputFacebookMini.prototype.fieldsToStorage=function(){console.group("[facebook.mini] fields to storage");for(var a=$$('[data-sublink="facebook"] article.mini-relation-panel .mini-fiche-relation'),c=0;c<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate(),e=crc32(JSON.stringify(b)),d=lsi.get("f_mini-fiches",b.uid);if(!1!==d){if(null!=d&&null!=d.hash&&d.hash==e)return;console.warn("> MINI UPDATE");b={uid:parseInt(b.uid),contact:parseInt(b.uid),sexe:b.sexe,age:b.age, inputFacebookMini.prototype.fieldsToStorage=function(){console.group("[facebook.mini] fields to storage");for(var a=$$('[data-sublink="facebook"] article.mini-relation-panel .mini-fiche-relation'),c=0;c<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate(),e=crc32(JSON.stringify(b)),d=lsi.get("f_mini-fiches",b.uid);if(!1!==d){if(null!=d&&null!=d.hash&&d.hash==e)return;console.warn("> MINI UPDATE");b={uid:parseInt(b.uid),contact:parseInt(b.uid),sexe:b.sexe,age:b.age,
studies:b.studies,reltype:b.reltype,reltypeSpecial:b.reltypeSpecial,loc:b.loc,unknown:null!=b.unknown,hash:e};b.valid=this.check(b);0<diff(d,b,["hash","valid","timestamp"]).length?(console.log(diff(d,b,["hash","valid","timestamp"])),console.warn("> MINI UPDATE"),b.timestamp=Date.now()):void 0==d.timestamp&&(b.timestamp=this.defaultData.timestamp);lsi.set("f_mini-fiches",b.uid,b)}}console.groupEnd()}; studies:b.studies,reltype:b.reltype,reltypeSpecial:b.reltypeSpecial,loc:b.loc,unknown:null!=b.unknown,hash:e};b.valid=this.check(b);0<diff(d,b,["hash","valid","timestamp"]).length?(console.log(diff(d,b,["hash","valid","timestamp"])),console.warn("> MINI UPDATE"),b.timestamp=Date.now()):void 0==d.timestamp&&(b.timestamp=this.defaultData.timestamp);lsi.set("f_mini-fiches",b.uid,b)}}console.groupEnd()};
=======
function inputFacebookMini(a,c){this.container=a;this.nav_container=c}inputFacebookMini.prototype={container:this.container,nav_container:this.nav_container,selected:null,handler:null,defaultData:{sexe:"2",age:".",studies:"0",loc:".",reltype:"9",unknown:!1,reltypeSpecial:"",timestamp:0,valid:!1}};
inputFacebookMini.prototype.fieldsToStorage=function(){console.group("[facebook.mini] fields to storage");for(var a=$$('[data-sublink="facebook"] article.mini-relation-panel .mini-fiche-relation'),c=0;c<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate(),e=crc32(JSON.stringify(b)),d=lsi.get("f_mini-fiches",b.uid);if(!1!==d){if(null!=d&&null!=d.hash&&d.hash==e)return;console.warn("> MINI UPDATE");b={uid:parseInt(b.uid),sexe:b.sexe,age:b.age,studies:b.studies,reltype:b.reltype,
reltypeSpecial:b.reltypeSpecial,loc:b.loc,unknown:null!=b.unknown,hash:e};b.valid=this.check(b);0<diff(d,b,["hash","valid","timestamp"]).length?(console.log(diff(d,b,["hash","valid","timestamp"])),console.warn("> FICHE UPDATE"),b.timestamp=Date.now()):void 0==d.timestamp&&(b.timestamp=this.defaultData.timestamp);lsi.set("f_mini-fiches",b.uid,b)}}console.groupEnd()};
>>>>>>> f8c0ef141fac6b47b8616172eba10575a9fb1273
inputFacebookMini.prototype.add=function(a){if(null==a||null==a.uid)return!1;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.studies=null!=a.studies?a.studies:this.defaultData.studies;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;a.loc=null!=a.loc?a.loc:this.defaultData.loc;a.unknown=null!=a.unknown?a.unknown:this.defaultData.unknown;var c=lsi.get("f_contacts", inputFacebookMini.prototype.add=function(a){if(null==a||null==a.uid)return!1;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.studies=null!=a.studies?a.studies:this.defaultData.studies;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;a.loc=null!=a.loc?a.loc:this.defaultData.loc;a.unknown=null!=a.unknown?a.unknown:this.defaultData.unknown;var c=lsi.get("f_contacts",
a.uid);if(!1===c)return!1;if(!isNaN(c.existing)){var b=lsi.get("f_friends",c.existing);c.username=b.name;a.contact=b.contact;a.age=b.age;a.sexe=b.sexe;a.loc=b.dist;isNaN(b.reltype)?(a.reltype=10,a.reltypeSpecial=b.reltype):(a.reltype=b.reltype,a.reltypeSpecial="");null!=b.studies1&&(a.studies=b.studies1)}this.container.innerHTML+=fMiniFicheBuilder.build({name:c.username,uid:a.uid,reltypespecial:a.reltypeSpecial});c=$('[data-sublink="facebook"] article.mini-fiche-relation input[data-name="uid"][value="'+ a.uid);if(!1===c)return!1;if(!isNaN(c.existing)){var b=lsi.get("f_friends",c.existing);c.username=b.name;a.contact=b.contact;a.age=b.age;a.sexe=b.sexe;a.loc=b.dist;isNaN(b.reltype)?(a.reltype=10,a.reltypeSpecial=b.reltype):(a.reltype=b.reltype,a.reltypeSpecial="");null!=b.studies1&&(a.studies=b.studies1)}this.container.innerHTML+=fMiniFicheBuilder.build({name:c.username,uid:a.uid,reltypespecial:a.reltypeSpecial});c=$('[data-sublink="facebook"] article.mini-fiche-relation input[data-name="uid"][value="'+
a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=c&&c.setAttribute("selected","selected");c=$('[data-sublink="facebook"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+a.age+'"]');null!=c&&c.setAttribute("selected","selected");b=$$('[data-sublink="facebook"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');for(c=0;c<b.length;c++)b[c].value== a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=c&&c.setAttribute("selected","selected");c=$('[data-sublink="facebook"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+a.age+'"]');null!=c&&c.setAttribute("selected","selected");b=$$('[data-sublink="facebook"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');for(c=0;c<b.length;c++)b[c].value==
a.sexe?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="facebook"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(c=0;c<b.length;c++)b[c].value==a.reltype?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="facebook"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(c=0;c<b.length;c++)b[c].value== a.sexe?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="facebook"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(c=0;c<b.length;c++)b[c].value==a.reltype?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="facebook"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(c=0;c<b.length;c++)b[c].value==
a.loc?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");c=$('[data-sublink="facebook"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="checkbox"][data-name="unknown"]');null!=c&&a.unknown&&c.setAttribute("checked","checked")}; a.loc?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");c=$('[data-sublink="facebook"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="checkbox"][data-name="unknown"]');null!=c&&a.unknown&&c.setAttribute("checked","checked")};
inputFacebookMini.prototype.storageToFields=function(){console.group("[facebook.mini] storage to fields");var a=lsi.get("f_mini-fiches",this.selected);if(null===a){if(null===this.selected)return a=lsi.keys("f_mini-fiches"),0<a.length?(this.selected=a[0],this.storageToFields()):!1;this.updateNavBar();return!1}this.container.innerHTML="";this.add(a);this.updateNavBar();console.groupEnd()}; inputFacebookMini.prototype.storageToFields=function(){console.group("[facebook.mini] storage to fields");var a=lsi.get("f_mini-fiches",this.selected);if(null===a){if(null===this.selected)return a=lsi.keys("f_mini-fiches"),0<a.length?(this.selected=a[0],this.storageToFields()):!1;this.updateNavBar();return!1}this.container.innerHTML="";this.add(a);this.updateNavBar();console.groupEnd()};
<<<<<<< HEAD
inputFacebookMini.prototype.sync=function(){console.group("[facebook.mini] synchronisation");var a=lsi["export"]("f_contacts"),c;ficheIndexes=lsi.keys("f_fiches");for(c in ficheIndexes)delete a[ficheIndexes[c]];for(var b in a){var e=0==a[b].username.length?b.toString()+"-":b;c=lsi.get("f_mini-fiches",e);null==c&&(c=this.defaultData,c.contact=a[b].uid,c.valid=!1);c.uid=parseInt(b);lsi.set("f_mini-fiches",e,c)}c=lsi["export"]("f_mini-fiches");if(null==c[this.selected])for(b in c)if(!isNaN(b)){this.selected= inputFacebookMini.prototype.sync=function(){console.group("[facebook.mini] synchronisation");var a=lsi["export"]("f_contacts"),c;ficheIndexes=lsi.keys("f_fiches");for(c in ficheIndexes)delete a[ficheIndexes[c]];for(var b in a){var e=0==a[b].username.length?b.toString()+"-":b;c=lsi.get("f_mini-fiches",e);null==c&&(c=this.defaultData,c.contact=a[b].uid,c.valid=!1);c.uid=parseInt(b);lsi.set("f_mini-fiches",e,c)}c=lsi["export"]("f_mini-fiches");if(null==c[this.selected])for(b in c)if(!isNaN(b)){this.selected=
parseInt(b);break}console.groupEnd()};inputFacebookMini.prototype.nav=function(a){if(!(a instanceof Element&&a.getData("n"))||isNaN(a.getData("n"))||"f_nav-mini"!=a.parentNode.id)return!1;for(var c=$$('[data-sublink="facebook"] #f_nav-mini > span.active'),b=0;b<c.length;b++)c[b].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))}; parseInt(b);break}console.groupEnd()};inputFacebookMini.prototype.nav=function(a){if(!(a instanceof Element&&a.getData("n"))||isNaN(a.getData("n"))||"f_nav-mini"!=a.parentNode.id)return!1;for(var c=$$('[data-sublink="facebook"] #f_nav-mini > span.active'),b=0;b<c.length;b++)c[b].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
=======
inputFacebookMini.prototype.sync=function(){console.group("[facebook.mini] synchronisation");var a=lsi["export"]("f_contacts"),c=lsi["export"]("f_fiches"),b=[],e;for(e in c)-1==b.indexOf(c[e].contact)&&b.push(c[e].contact);for(var d in a)-1<b.indexOf(parseInt(d))?lsi.del("f_mini-fiches",d):(c=0==a[d].username.length?d.toString()+"-":d,e=lsi.get("f_mini-fiches",c),null==e&&(e=this.defaultData,e.valid=!1,isNaN(c)&&(e.reltype="9")),e.uid=parseInt(d),lsi.set("f_mini-fiches",c,e));e=lsi["export"]("f_mini-fiches");
if(null==e[this.selected])for(d in e)if(!isNaN(d)){this.selected=parseInt(d);break}console.groupEnd()};inputFacebookMini.prototype.nav=function(a){if(!(a instanceof Element&&a.getData("n"))||isNaN(a.getData("n"))||"f_nav-mini"!=a.parentNode.id)return!1;for(var c=$$('[data-sublink="facebook"] #f_nav-mini > span.active'),b=0;b<c.length;b++)c[b].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
>>>>>>> f8c0ef141fac6b47b8616172eba10575a9fb1273
inputFacebookMini.prototype.updateNavBar=function(){var a=lsi["export"]("f_mini-fiches");this.nav_container.innerHTML="";var c=0,b;for(b in a)isNaN(b)||(this.nav_container.innerHTML+='<span data-n="'+b+'">'+ ++c+"</span>");for(b in a)isNaN(b)||(c=$('[data-sublink="facebook"] #f_nav-mini [data-n="'+a[b].uid+'"]'),null!=c&&(!0===a[b].valid?c.addClass("done"):c.remClass("done")));this.nav($('[data-sublink="facebook"] #f_nav-mini [data-n="'+this.selected+'"]'))}; inputFacebookMini.prototype.updateNavBar=function(){var a=lsi["export"]("f_mini-fiches");this.nav_container.innerHTML="";var c=0,b;for(b in a)isNaN(b)||(this.nav_container.innerHTML+='<span data-n="'+b+'">'+ ++c+"</span>");for(b in a)isNaN(b)||(c=$('[data-sublink="facebook"] #f_nav-mini [data-n="'+a[b].uid+'"]'),null!=c&&(!0===a[b].valid?c.addClass("done"):c.remClass("done")));this.nav($('[data-sublink="facebook"] #f_nav-mini [data-n="'+this.selected+'"]'))};
inputFacebookMini.prototype.check=function(a){return a.unknown?!0:""==a.sexe||"."==a.studies||"."==a.age||""==a.loc||""==a.reltype||"10"==a.reltype&&2>a.reltypeSpecial.length?!1:!0};inputFacebookMini.prototype.attach=function(a){console.group("[facebook.mini] attaching events");lsi.createDataset("f_mini-fiches");this.storageToFields();this.handler=a;this.nav_container.addEventListener("click",function(a){this.nav(a.target);this.handler(a.target)}.bind(this),!1);console.groupEnd()}; inputFacebookMini.prototype.check=function(a){return a.unknown?!0:""==a.sexe||"."==a.studies||"."==a.age||""==a.loc||""==a.reltype||"10"==a.reltype&&2>a.reltypeSpecial.length?!1:!0};inputFacebookMini.prototype.attach=function(a){console.group("[facebook.mini] attaching events");lsi.createDataset("f_mini-fiches");this.storageToFields();this.handler=a;this.nav_container.addEventListener("click",function(a){this.nav(a.target);this.handler(a.target)}.bind(this),!1);console.groupEnd()};