NxTIC/js/lib/api-min.js

6 lines
1.7 KiB
JavaScript
Raw Normal View History

function APIClass(b){this.target=b}
2016-04-20 09:59:21 +00:00
APIClass.prototype={xhr:[],send:function(b,c,d){b.hasOwnProperty("path")||c({ModuleError:4});for(var a=0;a<this.xhr.length;a++)4==this.xhr[a].readyState&&(this.xhr=this.xhr.slice(0,a-1).concat(this.xhr.slice(a,this.xhr.length-1)));this.xhr.push(null);a=this.xhr.length-1;this.xhr[a]=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHttpRequest");console.log(b);var f=this;this.xhr[a].onreadystatechange=function(){if(4==f.xhr[a].readyState)if(-1<[0,200].indexOf(f.xhr[a].status))try{c(JSON.parse(f.xhr[a].responseText))}catch(b){c({ModuleError:1})}else c({ModuleError:3})};
var h=new FormData,g;for(g in b)h.append(g,b[g]);this.xhr[a].open("POST",this.target,!0);null!=d&&this.xhr[a].setRequestHeader("Authorization","Digest "+d);this.xhr[a].send(h)}};
function fileUploader(b,c,d){c=new FormData;c.append("filename",filename);c.append("file",b,b.name);var a=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHttpRequest");a.open("POST","manager/import.php",!0);a.onreadystatechange=function(){4==a.readyState&&-1<[0,200].indexOf(a.status)&&(console.log("[1] IMPORT=> "+a.responseText),"success"==a.responseText?API.send({level_0:"excel",level_1:"import_inscrits"},function(a){console.log("[2] PARSE=>"+a.request);"success"==a.request?
(requestIntegration={level_0:"groups",level_1:"addUserlist",rang:rang,annee:annee,formationList:a.formationList},API.send(requestIntegration,function(a){console.log("[3] INTEGRATION=>"+a.request);"success"==a.request?(console.log("liste int\u00e9gr\u00e9e"),reload()):(console.log("integration error"),makeBounce(e.target.parentNode))})):(console.log("import error"),makeBounce(e.target.parentNode),console.log(e.target))}):makeBounce(e.target.parentNode))};a.send(c)};