/* Optional: Temporarily hide the "tabber" class so it does not "flash" on the page as plain HTML. After tabber runs, the class is changed to "tabberlive" and it will appear. */ ///var myApp={}; myApp.xmlfile=""; ////myApp.ownersite='systemboost'; ///myApp.urldir='_scripts/iCloud'; ///myApp.urldir='http://127.0.0.1/iCloud/'+myApp.ownersite+'/scripts'; ////myApp.datadir=urldir;////'http://127.0.0.1/myproducts_sites/ws/prototypes/php'; /* function creerRequeteCORS(methode, url) { var xhr = new XMLHttpRequest(); //Test pour savoir si l'objet XHR gère withCredentials, ce qui indique qu'il s'agit bien de la version 2 de XHR if(xhr.withCredentials)/// in xhr) { xhr.open(method, url, true); } //Sinon on teste l'objet XDomainRequest pour Internet Explorer else if (typeof xhr.XDomainRequest != undefined) { xhr = new XDomainRequest(); xhr.open(method, url); } //Sinon le navigateur est trop ancien, il ne gère pas cette API else xhr = null; return xhr; } */ class myAjax { //c https://codeburst.io/comment-%C3%A9crire-une-classe-un-objet-en-javascript-634808aa5062 //c https://www.gchagnon.fr/cours/dhtml/objets.html#class constructor(ownersite,url,xmlfile,datadir) { this.ownersite = (ownersite?ownersite:myApp.ownersite); this.xmlfile = (xmlfile?xmlfile:myApp.xmlfile); this.url = (url?url:myApp.urldir); this.datadir = (datadir?datadir:this.url); } static analyse_status(xhr,warning,id,url){ //// alert('ljs:77 xhr.status = '+xhr.status); var msg='Success : '+id,status=(xhr.status),success=(status===200); if(!success){ msg='An error '+status+' occurred!'; switch(status){ case 404: if(url)msg+=' -> Default URL = '+this.url; break; default: }//c switch(xhr.status) }//c if(!success) if(warning)alert(msg); return([success,status,xhr.responseText]); } static getXDomainRequest() {         var xdr = null;                  if (window.XDomainRequest) {                 xdr = new XDomainRequest();          } else if (window.XMLHttpRequest) {                 xdr = new XMLHttpRequest();          } else {                 alert("Votre navigateur ne gère pas l'AJAX cross-domain !");         }                  return(xdr);         } /* function sendData() {         var xdr = getXDomainRequest(); alert(xdr);         xdr.onload = function() {                 alert(xdr.responseText);         }          ///        xdr.open("GET", "http://www.foxycode.net/dev/ajax/XDomain_1.php"); var line='?essai=ok';         xdr.open("GET", "http://www.pooletude.com/iCloud/systemboost/scripts/sendmail.php"+line);         xdr.send(); return(false); } */ file_exists(url,warning){ /// alert('ljs:93 '+' file_exists(url,warning)'); // Create a new FormData object. https://thoughtbot.com/blog/ridiculously-simple-ajax-uploads-with-formdata var formData=new FormData(),fct='ajax_file_exists';//c new FormData(form_upload) formData.append('command',fct); // Set up the request. var xhr=new XMLHttpRequest(); var exists=false; // Open the connection en synchrone false xhr.open('POST',url,false); // Set up a handler for when the request finishes. xhr.onload=function(){ /// alert('ljs:104 url = '+url+' - xhr.status = '+xhr.status); var s=myAjax.analyse_status(xhr,false,fct,url); /// alert('ljs:106 s[0] = '+s[0]); exists=s[0];//c success };//c xhr.onload=function () // Send the Data. xhr.send(formData); return(exists); } gorequete(mode,datas,elmdiv){ // mode ={'method':'POST','synchrone':false,'action':'update'} var line ='';///num='+num;//+'&action='+action+'&datadir='+datadir+'&line='+transmit+'&items='+items+'&reaction='+reaction+'&search='+search; ////alert('ljs:111'); for(var i=0;i element ("Milk") of