Valid XHTML     Valid CSS2    

Listing du fichier l2xml.js

 

00001     // # (gH) -_- l2xml.js ; TimeStamp (unix) : 25 Juillet 2017 vers 18:20
00002     
00003     // ###################################################################################
00004     
00005     function partie(nump=0) {
00006     
00007     // ###################################################################################
00008     
00009      if (nump==0) { window.location.href="l2xml.php" ; } ;
00010     
00011      var url = "#" ;
00012     
00013      if (nump==1) {
00014      url = "l2xml_1_introduction.php" + "?standalone=FALSE"
00015      } // fin si
00016     
00017      if (nump==2) {
00018      url = "l2xml_2_structure.php" + "?standalone=FALSE"
00019      } // fin si
00020     
00021      if (nump==3) {
00022      url = "l2xml_3_valide.php" + "?standalone=FALSE"
00023      } // fin si
00024     
00025      if (nump==4) {
00026      url = "l2xml_4_transforme.php" + "?standalone=FALSE"
00027      } // fin si
00028     
00029      if (nump==5) {
00030      url = "l2xml_5_conclusion.php" + "?standalone=FALSE"
00031      } // fin si
00032     
00033      if (nump==6) {
00034      url = "l2xml_6_exercices.php" + "?standalone=FALSE"
00035      } // fin si
00036     
00037      if (nump==61) {
00038      url = "l2xml_6_tp1.php" + "?standalone=TRUE"
00039      window.document.location.href="l2xml_6_tp1.php" ;
00040      } // fin si
00041     
00042      if (nump==62) {
00043      url = "l2xml_6_tp2.php" + "?standalone=TRUE"
00044      window.document.location.href="l2xml_6_tp2.php" ;
00045      } // fin si
00046     
00047      if (nump==63) {
00048      url = "l2xml_6_tp3.php" + "?standalone=TRUE"
00049      window.document.location.href="l2xml_6_tp3.php" ;
00050      } // fin si
00051     
00052      if (nump==64) {
00053      url = "l2xml_6_tp4.php" + "?standalone=TRUE"
00054      window.document.location.href="l2xml_6_tp4.php" ;
00055      } // fin si
00056     
00057      if (nump==65) {
00058      url = "l2xml_6_tp5.php" + "?standalone=TRUE"
00059      window.document.location.href="l2xml_6_tp5.php" ;
00060      } // fin si
00061     
00062      if (nump>0) {
00063      // OK : ocument.location.href = url
00064     
00065      var xhr;
00066      try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); }
00067     
00068      catch (e) {
00069     
00070      try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
00071     
00072      catch (e2) {
00073     
00074      try { xhr = new XMLHttpRequest(); }
00075     
00076      catch (e3) { xhr = false; }
00077     
00078      }
00079     
00080      } // fin du catch
00081     
00082      xhr.onreadystatechange = function() {
00083     
00084      if (xhr.readyState == 4) {
00085     
00086      if (xhr.status == 200) {
00087     
00088      // on transmet tout le fichier
00089     
00090      document.getElementById("contenu").innerHTML = xhr.responseText ;
00091     
00092      } else {
00093     
00094      document.getElementById("contenu").innerHTML= "<h1>Error code " + xhr.status + "</h1>" ;
00095     
00096      } ; // fin de xhr.status == 200
00097     
00098      } ; // fin de xhr.readyState == 4
00099     
00100      } ; // fin de fonction xhr.onreadystatechange
00101     
00102     
00103      xhr.open("GET", url+"?standalone=FALSE", true);
00104      xhr.send(null);
00105     
00106      } // fin si
00107     
00108     
00109     } // fin de fonction partie
00110     
00111     // ###################################################################################
00112     
00113     function montreSolution(numeroExercice) {
00114     
00115     // ######################################################################
00116     
00117     // rend visible la division qui contient la solution
00118     
00119      window.document.getElementById("solution"+numeroExercice).setAttribute("class","visible") ;
00120      window.document.getElementById("bsol"+numeroExercice).innerHTML =" &nbsp; masquer la solution &nbsp; " ;
00121      window.document.getElementById("bsol"+numeroExercice).setAttribute("onclick","masqueSolution("+numeroExercice+") ; return false")
00122      window.document.getElementById("bsol"+numeroExercice).setAttribute("class","bouton_fin orange_pastel nou nobold") ;
00123     
00124     } ; // fin de fonction montreSolution
00125     
00126     // ######################################################################
00127     
00128     function masqueSolution(numeroExercice) {
00129     
00130     // ######################################################################
00131     
00132     // rend visible la division qui contient la solution
00133     
00134      window.document.getElementById("solution"+numeroExercice).setAttribute("class","invisible") ;
00135      window.document.getElementById("bsol"+numeroExercice).innerHTML =" &nbsp; afficher la solution &nbsp; " ;
00136      window.document.getElementById("bsol"+numeroExercice).setAttribute("onclick","montreSolution("+numeroExercice+") ; return false")
00137      window.document.getElementById("bsol"+numeroExercice).setAttribute("class","bouton_fin vert_pastel nou nobold") ;
00138     
00139     } ; // fin de fonction masqueSolution
00140     
00141     // ######################################################################
00142     
00143     function montreFichier(fichier,ta) {
00144     
00145     // ######################################################################
00146     
00147     // transfère le contenu du fichier dans le texterea dont l'id est ta
00148     // sauf si le chemin du fichier commence par "."
00149     
00150     if (fichier.substr(0,1)==".") {
00151      window.document.getElementById(ta).value = "[fichier non affichable]" ;
00152     } else {
00153      window.document.getElementById(ta).value = file_get_contents(fichier) ;
00154     } ; // fin si
00155     
00156     } ; // fin de fonction montreFichier
00157     
00158     // ######################################################################
00159     
00160     function file_get_contents (url, flags, context, offset, maxLen) { // http://phpjs.org/functions/file_get_contents:400
00161     
00162     // ######################################################################
00163     
00164      // Read the entire file into a string
00165      //
00166      // version: 906.111
00167      // discuss at: http://phpjs.org/functions/file_get_contents
00168      // + original by: Legaev Andrey
00169      // + input by: Jani Hartikainen
00170      // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
00171      // + improved by: Brett Zamir (http://brett-zamir.me)
00172      // + input by: Raphael (Ao) RUDLER
00173      // + bugfixed by: Brett Zamir (http://brett-zamir.me)
00174      // % note 1: This function uses XmlHttpRequest and cannot retrieve resource from different domain without modifications.
00175      // % note 2: Synchronous by default (as in PHP) so may lock up browser. Can
00176      // % note 2: get async by setting a custom "phpjs.async" property to true and "notification" for an
00177      // % note 2: optional callback (both as context params, with responseText, and other JS-specific
00178      // % note 2: request properties available via 'this'). Note that file_get_contents() will not return the text
00179      // % note 2: in such a case (use this.responseText within the callback). Or, consider using
00180      // % note 2: jQuery's: $('#divId').load('http://url') instead.
00181      // % note 3: The context argument is only implemented for http, and only partially (see below for
00182      // % note 3: "Presently unimplemented HTTP context options"); also the arguments passed to
00183      // % note 3: notification are incomplete
00184      // * example 1: file_get_contents('http://kevin.vanzonneveld.net/pj_test_supportfile_1.htm');
00185      // * returns 1: '123'
00186      // Note: could also be made to optionally add to global $http_response_header as per http://php.net/manual/en/reserved.variables.httpresponseheader.php
00187     
00188      var tmp, headers = [], newTmp = [], k=0, i=0, href = '', pathPos = -1, flagNames = 0, content = null, http_stream = false;
00189      var func = function (value) { return value.substring(1) !== ''; };
00190     
00191      // BEGIN REDUNDANT
00192      this.php_js = this.php_js || {};
00193      this.php_js.ini = this.php_js.ini || {};
00194      // END REDUNDANT
00195     
00196      var ini = this.php_js.ini;
00197      context = context || this.php_js.default_streams_context || null;
00198     
00199      if (!flags) {flags = 0;}
00200      var OPTS = {
00201      FILE_USE_INCLUDE_PATH : 1,
00202      FILE_TEXT : 32,
00203      FILE_BINARY : 64
00204      };
00205      if (typeof flags === 'number') { // Allow for a single string or an array of string flags
00206      flagNames = flags;
00207      }
00208      else {
00209      flags = [].concat(flags);
00210      for (i=0; i < flags.length; i++) {
00211      if (OPTS[flags[i]]) {
00212      flagNames = flagNames | OPTS[flags[i]];
00213      }
00214      }
00215      }
00216     
00217      if (flagNames & OPTS.FILE_BINARY && (flagNames & OPTS.FILE_TEXT)) { // These flags shouldn't be together
00218      throw 'You cannot pass both FILE_BINARY and FILE_TEXT to file_get_contents()';
00219      }
00220     
00221      if ((flagNames & OPTS.FILE_USE_INCLUDE_PATH) && ini.include_path &&
00222      ini.include_path.local_value) {
00223      var slash = ini.include_path.local_value.indexOf('/') !== -1 ? '/' : '\\';
00224      url = ini.include_path.local_value+slash+url;
00225      }
00226      else if (!/^(https?|file):/.test(url)) { // Allow references within or below the same directory (should fix to allow other relative references or root reference; could make dependent on parse_url())
00227      href = this.window.location.href;
00228      pathPos = url.indexOf('/') === 0 ? href.indexOf('/', 8)-1 : href.lastIndexOf('/');
00229      url = href.slice(0, pathPos+1)+url;
00230      }
00231     
00232      if (context) {
00233      var http_options = context.stream_options && context.stream_options.http;
00234      http_stream = !!http_options;
00235      }
00236     
00237      if (!context || http_stream) {
00238      var req = this.window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
00239      if (!req) {throw new Error('XMLHttpRequest not supported');}
00240     
00241      var method = http_stream ? http_options.method : 'GET';
00242      var async = !!(context && context.stream_params && context.stream_params['phpjs.async']);
00243     
00244      if (ini['phpjs.ajaxBypassCache'] && ini['phpjs.ajaxBypassCache'].local_value) {
00245      url += (url.match(/\?/) == null ? "?" : "&") + (new Date()).getTime(); // Give optional means of forcing bypass of cache
00246      }
00247     
00248      req.open(method, url, async);
00249      if (async) {
00250      var notification = context.stream_params.notification;
00251      if (typeof notification === 'function') {
00252      // Fix: make work with req.addEventListener if available: https://developer.mozilla.org/En/Using_XMLHttpRequest
00253      if (0 && req.addEventListener) { // Unimplemented so don't allow to get here
00254      /*
00255      req.addEventListener('progress', updateProgress, false);
00256      req.addEventListener('load', transferComplete, false);
00257      req.addEventListener('error', transferFailed, false);
00258      req.addEventListener('abort', transferCanceled, false);
00259      */
00260      }
00261      else {
00262      req.onreadystatechange = function (aEvt) { // aEvt has stopPropagation(), preventDefault(); see https://developer.mozilla.org/en/NsIDOMEvent
00263     
00264     
00265      // Other XMLHttpRequest properties: multipart, responseXML, status, statusText, upload, withCredentials
00266      /*
00267      PHP Constants:
00268      STREAM_NOTIFY_RESOLVE 1 A remote address required for this stream has been resolved, or the resolution failed. See severity for an indication of which happened.
00269      STREAM_NOTIFY_CONNECT 2 A connection with an external resource has been established.
00270      STREAM_NOTIFY_AUTH_REQUIRED 3 Additional authorization is required to access the specified resource. Typical issued with severity level of STREAM_NOTIFY_SEVERITY_ERR.
00271      STREAM_NOTIFY_MIME_TYPE_IS 4 The mime-type of resource has been identified, refer to message for a description of the discovered type.
00272      STREAM_NOTIFY_FILE_SIZE_IS 5 The size of the resource has been discovered.
00273      STREAM_NOTIFY_REDIRECTED 6 The external resource has redirected the stream to an alternate location. Refer to message .
00274      STREAM_NOTIFY_PROGRESS 7 Indicates current progress of the stream transfer in bytes_transferred and possibly bytes_max as well.
00275      STREAM_NOTIFY_COMPLETED 8 There is no more data available on the stream.
00276      STREAM_NOTIFY_FAILURE 9 A generic error occurred on the stream, consult message and message_code for details.
00277      STREAM_NOTIFY_AUTH_RESULT 10 Authorization has been completed (with or without success).
00278     
00279      STREAM_NOTIFY_SEVERITY_INFO 0 Normal, non-error related, notification.
00280      STREAM_NOTIFY_SEVERITY_WARN 1 Non critical error condition. Processing may continue.
00281      STREAM_NOTIFY_SEVERITY_ERR 2 A critical error occurred. Processing cannot continue.
00282      */
00283      var objContext = {
00284      responseText : req.responseText,
00285      responseXML : req.responseXML,
00286      status : req.status,
00287      statusText : req.statusText,
00288      readyState : req.readyState,
00289      evt : aEvt
00290      }; // properties are not available in PHP, but offered on notification via 'this' for convenience
00291     
00292      // notification args: notification_code, severity, message, message_code, bytes_transferred, bytes_max (all int's except string 'message')
00293      // Need to add message, etc.
00294      var bytes_transferred;
00295      switch (req.readyState) {
00296      case 0: // UNINITIALIZED open() has not been called yet.
00297      notification.call(objContext, 0, 0, '', 0, 0, 0);
00298      break;
00299      case 1: // LOADING send() has not been called yet.
00300      notification.call(objContext, 0, 0, '', 0, 0, 0);
00301      break;
00302      case 2: // LOADED send() has been called, and headers and status are available.
00303      notification.call(objContext, 0, 0, '', 0, 0, 0);
00304      break;
00305      case 3: // INTERACTIVE Downloading; responseText holds partial data.
00306      bytes_transferred = req.responseText.length*2; // One character is two bytes
00307      notification.call(objContext, 7, 0, '', 0, bytes_transferred, 0);
00308      break;
00309      case 4: // COMPLETED The operation is complete.
00310      if (req.status >= 200 && req.status < 400) {
00311      bytes_transferred = req.responseText.length*2; // One character is two bytes
00312      notification.call(objContext, 8, 0, '', req.status, bytes_transferred, 0);
00313      }
00314      else if (req.status === 403) { // Fix: These two are finished except for message
00315      notification.call(objContext, 10, 2, '', req.status, 0, 0);
00316      }
00317      else { // Errors
00318      notification.call(objContext, 9, 2, '', req.status, 0, 0);
00319      }
00320      break;
00321      default:
00322      throw 'Unrecognized ready state for file_get_contents()';
00323      }
00324      }
00325      }
00326      }
00327      }
00328     
00329      if (http_stream) {
00330      var sendHeaders = http_options.header && http_options.header.split(/\r?\n/);
00331      var userAgentSent = false;
00332      for (i=0; i < sendHeaders.length; i++) {
00333      var sendHeader = sendHeaders[i];
00334      var breakPos = sendHeader.search(/:\s*/);
00335      var sendHeaderName = sendHeader.substring(0, breakPos);
00336      req.setRequestHeader(sendHeaderName, sendHeader.substring(breakPos+1));
00337      if (sendHeaderName === 'User-Agent') {
00338      userAgentSent = true;
00339      }
00340      }
00341      if (!userAgentSent) {
00342      var user_agent = http_options.user_agent ||
00343      (ini.user_agent && ini.user_agent.local_value);
00344      if (user_agent) {
00345      req.setRequestHeader('User-Agent', user_agent);
00346      }
00347      }
00348      content = http_options.content || null;
00349      /*
00350      // Presently unimplemented HTTP context options
00351      var request_fulluri = http_options.request_fulluri || false; // When set to TRUE, the entire URI will be used when constructing the request. (i.e. GET http://www.example.com/path/to/file.html HTTP/1.0). While this is a non-standard request format, some proxy servers require it.
00352      var max_redirects = http_options.max_redirects || 20; // The max number of redirects to follow. Value 1 or less means that no redirects are followed.
00353      var protocol_version = http_options.protocol_version || 1.0; // HTTP protocol version
00354      var timeout = http_options.timeout || (ini.default_socket_timeout && ini.default_socket_timeout.local_value); // Read timeout in seconds, specified by a float
00355      var ignore_errors = http_options.ignore_errors || false; // Fetch the content even on failure status codes.
00356      */
00357      }
00358     
00359      if (flagNames & OPTS.FILE_TEXT) { // Overrides how encoding is treated (regardless of what is returned from the server)
00360      var content_type = 'text/html';
00361      if (http_options && http_options['phpjs.override']) { // Fix: Could allow for non-HTTP as well
00362      content_type = http_options['phpjs.override']; // We use this, e.g., in gettext-related functions if character set
00363      // overridden earlier by bind_textdomain_codeset()
00364      }
00365      else {
00366      var encoding = (ini['unicode.stream_encoding'] && ini['unicode.stream_encoding'].local_value) || 'UTF-8';
00367      if (http_options && http_options.header && (/^content-type:/im).test(http_options.header)) { // We'll assume a content-type expects its own specified encoding if present
00368      content_type = http_options.header.match(/^content-type:\s*(.*)$/im)[1]; // We let any header encoding stand
00369      }
00370      if (!(/;\s*charset=/).test(content_type)) { // If no encoding
00371      content_type += '; charset='+encoding;
00372      }
00373      }
00374      req.overrideMimeType(content_type);
00375      }
00376      // Default is FILE_BINARY, but for binary, we apparently deviate from PHP in requiring the flag, since many if not
00377      // most people will also want a way to have it be auto-converted into native JavaScript text instead
00378      else if (flagNames & OPTS.FILE_BINARY) { // Trick at https://developer.mozilla.org/En/Using_XMLHttpRequest to get binary
00379      req.overrideMimeType('text/plain; charset=x-user-defined');
00380      // Getting an individual byte then requires:
00381      // responseText.charCodeAt(x) & 0xFF; // throw away high-order byte (f7) where x is 0 to responseText.length-1 (see notes in our substr())
00382      }
00383     
00384      if (http_options && http_options['phpjs.sendAsBinary']) { // For content sent in a POST or PUT request (use with file_put_contents()?)
00385      req.sendAsBinary(content); // In Firefox, only available FF3+
00386      }
00387      else {
00388      req.send(content);
00389      }
00390     
00391      tmp = req.getAllResponseHeaders();
00392      if (tmp) {
00393      tmp = tmp.split('\n');
00394      for (k=0; k < tmp.length; k++) {
00395      if (func(tmp[k])) {
00396      newTmp.push(tmp[k]);
00397      }
00398      }
00399      tmp = newTmp;
00400      for (i=0; i < tmp.length; i++) {
00401      headers[i] = tmp[i];
00402      }
00403      this.$http_response_header = headers; // see http://php.net/manual/en/reserved.variables.httpresponseheader.php
00404      }
00405     
00406      if (offset || maxLen) {
00407      if (maxLen) {
00408      return req.responseText.substr(offset || 0, maxLen);
00409      }
00410      return req.responseText.substr(offset);
00411      }
00412      return req.responseText;
00413      }
00414      return false;
00415     }
00416     

Pour ne pas voir les numéros de ligne, ajoutez &nl=non à la suite du nom du fichier.

 

 

retour gH    Retour à la page principale de   (gH)