Listing du fichier pagsd.js
00001// # (gH) -_- pagsd.js ; TimeStamp (unix) : 24 Mars 2014 vers 22:31
00002
00003 // ######################################################################
00004
00005 function montreSolution(numeroExercice) {
00006
00007 // ######################################################################
00008
00009 // rend visible la division qui contient la solution
00010
00011 window.document.getElementById("solution"+numeroExercice).setAttribute("class","visible") ;
00012 window.document.getElementById("bsol"+numeroExercice).innerHTML =" masquer la solution " ;
00013 window.document.getElementById("bsol"+numeroExercice).setAttribute("onclick","masqueSolution("+numeroExercice+") ; return false")
00014 window.document.getElementById("bsol"+numeroExercice).setAttribute("class","bouton_fin orange_pastel nou nobold") ;
00015
00016 } ; // fin de fonction montreFichier
00017
00018 // ######################################################################
00019
00020 function masqueSolution(numeroExercice) {
00021
00022 // ######################################################################
00023
00024 // rend visible la division qui contient la solution
00025
00026 window.document.getElementById("solution"+numeroExercice).setAttribute("class","invisible") ;
00027 window.document.getElementById("bsol"+numeroExercice).innerHTML =" afficher la solution " ;
00028 window.document.getElementById("bsol"+numeroExercice).setAttribute("onclick","montreSolution("+numeroExercice+") ; return false")
00029 window.document.getElementById("bsol"+numeroExercice).setAttribute("class","bouton_fin vert_pastel nou nobold") ;
00030
00031 } ; // fin de fonction montreFichier
00032
00033 // ######################################################################
00034
00035 function montreFichier(fichier,ta) {
00036
00037 // ######################################################################
00038
00039 // transfère le contenu du fichier dans le texterea dont l'id est ta
00040 // sauf si le chemin du fichier commence par "."
00041
00042 if (fichier.substr(0,1)==".") {
00043 window.document.getElementById(ta).value = "[fichier non affichable]" ;
00044 } else {
00045 window.document.getElementById(ta).value = file_get_contents(fichier) ;
00046 } ; // fin si
00047
00048 } ; // fin de fonction montreFichier
00049
00050 // ######################################################################
00051
00052 // ######################################################################
00053 // http://phpjs.org/functions/file_get_contents:400
00054
00055 function file_get_contents (url, flags, context, offset, maxLen) {
00056
00057 // ######################################################################
00058
00059 // Read the entire file into a string
00060 //
00061 // version: 906.111
00062 // discuss at: http://phpjs.org/functions/file_get_contents
00063 // + original by: Legaev Andrey
00064 // + input by: Jani Hartikainen
00065 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
00066 // + improved by: Brett Zamir (http://brett-zamir.me)
00067 // + input by: Raphael (Ao) RUDLER
00068 // + bugfixed by: Brett Zamir (http://brett-zamir.me)
00069 // % note 1: This function uses XmlHttpRequest and cannot retrieve resource from different domain without modifications.
00070 // % note 2: Synchronous by default (as in PHP) so may lock up browser. Can
00071 // % note 2: get async by setting a custom "phpjs.async" property to true and "notification" for an
00072 // % note 2: optional callback (both as context params, with responseText, and other JS-specific
00073 // % note 2: request properties available via 'this'). Note that file_get_contents() will not return the text
00074 // % note 2: in such a case (use this.responseText within the callback). Or, consider using
00075 // % note 2: jQuery's: $('#divId').load('http://url') instead.
00076 // % note 3: The context argument is only implemented for http, and only partially (see below for
00077 // % note 3: "Presently unimplemented HTTP context options"); also the arguments passed to
00078 // % note 3: notification are incomplete
00079 // * example 1: file_get_contents('http://kevin.vanzonneveld.net/pj_test_supportfile_1.htm');
00080 // * returns 1: '123'
00081 // Note: could also be made to optionally add to global $http_response_header as per http://php.net/manual/en/reserved.variables.httpresponseheader.php
00082
00083 var tmp, headers = [], newTmp = [], k=0, i=0, href = '', pathPos = -1, flagNames = 0, content = null, http_stream = false;
00084 var func = function (value) { return value.substring(1) !== ''; };
00085
00086 // BEGIN REDUNDANT
00087 this.php_js = this.php_js || {};
00088 this.php_js.ini = this.php_js.ini || {};
00089 // END REDUNDANT
00090
00091 var ini = this.php_js.ini;
00092 context = context || this.php_js.default_streams_context || null;
00093
00094 if (!flags) {flags = 0;}
00095 var OPTS = {
00096 FILE_USE_INCLUDE_PATH : 1,
00097 FILE_TEXT : 32,
00098 FILE_BINARY : 64
00099 };
00100 if (typeof flags === 'number') { // Allow for a single string or an array of string flags
00101 flagNames = flags;
00102 }
00103 else {
00104 flags = [].concat(flags);
00105 for (i=0; i < flags.length; i++) {
00106 if (OPTS[flags[i]]) {
00107 flagNames = flagNames | OPTS[flags[i]];
00108 }
00109 }
00110 }
00111
00112 if (flagNames & OPTS.FILE_BINARY && (flagNames & OPTS.FILE_TEXT)) { // These flags shouldn't be together
00113 throw 'You cannot pass both FILE_BINARY and FILE_TEXT to file_get_contents()';
00114 }
00115
00116 if ((flagNames & OPTS.FILE_USE_INCLUDE_PATH) && ini.include_path &&
00117 ini.include_path.local_value) {
00118 var slash = ini.include_path.local_value.indexOf('/') !== -1 ? '/' : '\\';
00119 url = ini.include_path.local_value+slash+url;
00120 }
00121 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())
00122 href = this.window.location.href;
00123 pathPos = url.indexOf('/') === 0 ? href.indexOf('/', 8)-1 : href.lastIndexOf('/');
00124 url = href.slice(0, pathPos+1)+url;
00125 }
00126
00127 if (context) {
00128 var http_options = context.stream_options && context.stream_options.http;
00129 http_stream = !!http_options;
00130 }
00131
00132 if (!context || http_stream) {
00133 var req = this.window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
00134 if (!req) {throw new Error('XMLHttpRequest not supported');}
00135
00136 var method = http_stream ? http_options.method : 'GET';
00137 var async = !!(context && context.stream_params && context.stream_params['phpjs.async']);
00138
00139 if (ini['phpjs.ajaxBypassCache'] && ini['phpjs.ajaxBypassCache'].local_value) {
00140 url += (url.match(/\?/) == null ? "?" : "&") + (new Date()).getTime(); // Give optional means of forcing bypass of cache
00141 }
00142
00143 req.open(method, url, async);
00144 if (async) {
00145 var notification = context.stream_params.notification;
00146 if (typeof notification === 'function') {
00147 // Fix: make work with req.addEventListener if available: https://developer.mozilla.org/En/Using_XMLHttpRequest
00148 if (0 && req.addEventListener) { // Unimplemented so don't allow to get here
00149 /*
00150 req.addEventListener('progress', updateProgress, false);
00151 req.addEventListener('load', transferComplete, false);
00152 req.addEventListener('error', transferFailed, false);
00153 req.addEventListener('abort', transferCanceled, false);
00154 */
00155 }
00156 else {
00157 req.onreadystatechange = function (aEvt) { // aEvt has stopPropagation(), preventDefault(); see https://developer.mozilla.org/en/NsIDOMEvent
00158
00159 // Other XMLHttpRequest properties: multipart, responseXML, status, statusText, upload, withCredentials
00160 /*
00161 PHP Constants:
00162 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.
00163 STREAM_NOTIFY_CONNECT 2 A connection with an external resource has been established.
00164 STREAM_NOTIFY_AUTH_REQUIRED 3 Additional authorization is required to access the specified resource. Typical issued with severity level of STREAM_NOTIFY_SEVERITY_ERR.
00165 STREAM_NOTIFY_MIME_TYPE_IS 4 The mime-type of resource has been identified, refer to message for a description of the discovered type.
00166 STREAM_NOTIFY_FILE_SIZE_IS 5 The size of the resource has been discovered.
00167 STREAM_NOTIFY_REDIRECTED 6 The external resource has redirected the stream to an alternate location. Refer to message .
00168 STREAM_NOTIFY_PROGRESS 7 Indicates current progress of the stream transfer in bytes_transferred and possibly bytes_max as well.
00169 STREAM_NOTIFY_COMPLETED 8 There is no more data available on the stream.
00170 STREAM_NOTIFY_FAILURE 9 A generic error occurred on the stream, consult message and message_code for details.
00171 STREAM_NOTIFY_AUTH_RESULT 10 Authorization has been completed (with or without success).
00172
00173 STREAM_NOTIFY_SEVERITY_INFO 0 Normal, non-error related, notification.
00174 STREAM_NOTIFY_SEVERITY_WARN 1 Non critical error condition. Processing may continue.
00175 STREAM_NOTIFY_SEVERITY_ERR 2 A critical error occurred. Processing cannot continue.
00176 */
00177 var objContext = {
00178 responseText : req.responseText,
00179 responseXML : req.responseXML,
00180 status : req.status,
00181 statusText : req.statusText,
00182 readyState : req.readyState,
00183 evt : aEvt
00184 }; // properties are not available in PHP, but offered on notification via 'this' for convenience
00185
00186 // notification args: notification_code, severity, message, message_code, bytes_transferred, bytes_max (all int's except string 'message')
00187 // Need to add message, etc.
00188 var bytes_transferred;
00189 switch (req.readyState) {
00190 case 0: // UNINITIALIZED open() has not been called yet.
00191 notification.call(objContext, 0, 0, '', 0, 0, 0);
00192 break;
00193 case 1: // LOADING send() has not been called yet.
00194 notification.call(objContext, 0, 0, '', 0, 0, 0);
00195 break;
00196 case 2: // LOADED send() has been called, and headers and status are available.
00197 notification.call(objContext, 0, 0, '', 0, 0, 0);
00198 break;
00199 case 3: // INTERACTIVE Downloading; responseText holds partial data.
00200 bytes_transferred = req.responseText.length*2; // One character is two bytes
00201 notification.call(objContext, 7, 0, '', 0, bytes_transferred, 0);
00202 break;
00203 case 4: // COMPLETED The operation is complete.
00204 if (req.status >= 200 && req.status < 400) {
00205 bytes_transferred = req.responseText.length*2; // One character is two bytes
00206 notification.call(objContext, 8, 0, '', req.status, bytes_transferred, 0);
00207 }
00208 else if (req.status === 403) { // Fix: These two are finished except for message
00209 notification.call(objContext, 10, 2, '', req.status, 0, 0);
00210 }
00211 else { // Errors
00212 notification.call(objContext, 9, 2, '', req.status, 0, 0);
00213 }
00214 break;
00215 default:
00216 throw 'Unrecognized ready state for file_get_contents()';
00217 }
00218 }
00219 }
00220 }
00221 }
00222
00223 if (http_stream) {
00224 var sendHeaders = http_options.header && http_options.header.split(/\r?\n/);
00225 var userAgentSent = false;
00226 for (i=0; i < sendHeaders.length; i++) {
00227 var sendHeader = sendHeaders[i];
00228 var breakPos = sendHeader.search(/:\s*/);
00229 var sendHeaderName = sendHeader.substring(0, breakPos);
00230 req.setRequestHeader(sendHeaderName, sendHeader.substring(breakPos+1));
00231 if (sendHeaderName === 'User-Agent') {
00232 userAgentSent = true;
00233 }
00234 }
00235 if (!userAgentSent) {
00236 var user_agent = http_options.user_agent ||
00237 (ini.user_agent && ini.user_agent.local_value);
00238 if (user_agent) {
00239 req.setRequestHeader('User-Agent', user_agent);
00240 }
00241 }
00242 content = http_options.content || null;
00243 /*
00244 // Presently unimplemented HTTP context options
00245 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.
00246 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.
00247 var protocol_version = http_options.protocol_version || 1.0; // HTTP protocol version
00248 var timeout = http_options.timeout || (ini.default_socket_timeout && ini.default_socket_timeout.local_value); // Read timeout in seconds, specified by a float
00249 var ignore_errors = http_options.ignore_errors || false; // Fetch the content even on failure status codes.
00250 */
00251 }
00252
00253 if (flagNames & OPTS.FILE_TEXT) { // Overrides how encoding is treated (regardless of what is returned from the server)
00254 var content_type = 'text/html';
00255 if (http_options && http_options['phpjs.override']) { // Fix: Could allow for non-HTTP as well
00256 content_type = http_options['phpjs.override']; // We use this, e.g., in gettext-related functions if character set
00257 // overridden earlier by bind_textdomain_codeset()
00258 }
00259 else {
00260 var encoding = (ini['unicode.stream_encoding'] && ini['unicode.stream_encoding'].local_value) || 'UTF-8';
00261 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
00262 content_type = http_options.header.match(/^content-type:\s*(.*)$/im)[1]; // We let any header encoding stand
00263 }
00264 if (!(/;\s*charset=/).test(content_type)) { // If no encoding
00265 content_type += '; charset='+encoding;
00266 }
00267 }
00268 req.overrideMimeType(content_type);
00269 }
00270 // Default is FILE_BINARY, but for binary, we apparently deviate from PHP in requiring the flag, since many if not
00271 // most people will also want a way to have it be auto-converted into native JavaScript text instead
00272 else if (flagNames & OPTS.FILE_BINARY) { // Trick at https://developer.mozilla.org/En/Using_XMLHttpRequest to get binary
00273 req.overrideMimeType('text/plain; charset=x-user-defined');
00274 // Getting an individual byte then requires:
00275 // responseText.charCodeAt(x) & 0xFF; // throw away high-order byte (f7) where x is 0 to responseText.length-1 (see notes in our substr())
00276 }
00277
00278 if (http_options && http_options['phpjs.sendAsBinary']) { // For content sent in a POST or PUT request (use with file_put_contents()?)
00279 req.sendAsBinary(content); // In Firefox, only available FF3+
00280 }
00281 else {
00282 req.send(content);
00283 }
00284
00285 tmp = req.getAllResponseHeaders();
00286 if (tmp) {
00287 tmp = tmp.split('\n');
00288 for (k=0; k < tmp.length; k++) {
00289 if (func(tmp[k])) {
00290 newTmp.push(tmp[k]);
00291 }
00292 }
00293 tmp = newTmp;
00294 for (i=0; i < tmp.length; i++) {
00295 headers[i] = tmp[i];
00296 }
00297 this.$http_response_header = headers; // see http://php.net/manual/en/reserved.variables.httpresponseheader.php
00298 }
00299
00300 if (offset || maxLen) {
00301 if (maxLen) {
00302 return req.responseText.substr(offset || 0, maxLen);
00303 }
00304 return req.responseText.substr(offset);
00305 }
00306 return req.responseText;
00307 }
00308 return false;
00309 }
Pour ne pas voir les numéros de ligne, ajoutez &nl=non à la suite du nom du fichier.
Retour à la page principale de (gH)