[539] | 1 | function SelectAll( formulaire ) |
---|
| 2 | { |
---|
[1611] | 3 | var len = formulaire.elements.length; |
---|
[539] | 4 | var i=0; |
---|
| 5 | for( i = 0; i < len; i++) |
---|
| 6 | { |
---|
[2429] | 7 | if ( formulaire.elements[i].type=='checkbox' |
---|
| 8 | && formulaire.elements[i].name != 'copie') |
---|
| 9 | { |
---|
| 10 | formulaire.elements[i].checked = true; |
---|
| 11 | } |
---|
[539] | 12 | } |
---|
| 13 | } |
---|
| 14 | |
---|
[1114] | 15 | function DeselectAll( formulaire ) |
---|
| 16 | { |
---|
[1611] | 17 | var len = formulaire.elements.length; |
---|
[1114] | 18 | var i=0; |
---|
| 19 | for( i = 0; i < len; i++) |
---|
| 20 | { |
---|
[2429] | 21 | if ( formulaire.elements[i].type=='checkbox' |
---|
| 22 | && formulaire.elements[i].name != 'copie') |
---|
| 23 | { |
---|
[1114] | 24 | formulaire.elements[i].checked = false; |
---|
[2429] | 25 | } |
---|
[1114] | 26 | } |
---|
| 27 | } |
---|
| 28 | |
---|
[539] | 29 | function Inverser( formulaire ) |
---|
| 30 | { |
---|
[1611] | 31 | var len = formulaire.elements.length; |
---|
[539] | 32 | var i=0; |
---|
| 33 | for( i=0; i<len; i++) |
---|
| 34 | { |
---|
[2429] | 35 | if ( formulaire.elements[i].type=='checkbox' |
---|
| 36 | && formulaire.elements[i].name != 'copie') |
---|
| 37 | { |
---|
[539] | 38 | formulaire.elements[i].checked = !formulaire.elements[i].checked; |
---|
[2429] | 39 | } |
---|
[539] | 40 | } |
---|
| 41 | } |
---|
| 42 | |
---|
[1611] | 43 | function phpWGOpenWindow(theURL,winName,features) |
---|
[1468] | 44 | { |
---|
[2429] | 45 | img = new Image(); |
---|
| 46 | img.src = theURL; |
---|
| 47 | if (img.complete) |
---|
| 48 | { |
---|
| 49 | var width=img.width +40; |
---|
| 50 | var height=img.height +40; |
---|
| 51 | } |
---|
| 52 | else |
---|
| 53 | { |
---|
| 54 | var width=640; |
---|
| 55 | var height=480; |
---|
| 56 | img.onload = resizeWindowToFit; |
---|
| 57 | } |
---|
| 58 | newWin = window.open(theURL,winName,features+',left=2,top=1,width=' + width + ',height=' + height); |
---|
[1468] | 59 | } |
---|
| 60 | |
---|
[1611] | 61 | function resizeWindowToFit() |
---|
[539] | 62 | { |
---|
[2429] | 63 | newWin.resizeTo( img.width+50, img.height+100); |
---|
[858] | 64 | } |
---|
| 65 | |
---|
| 66 | function popuphelp(url) |
---|
| 67 | { |
---|
[2429] | 68 | window.open( url, 'dc_popup', |
---|
| 69 | 'alwaysRaised=yes,dependent=yes,toolbar=no,height=420,width=500,menubar=no,resizable=yes,scrollbars=yes,status=no' |
---|
| 70 | ); |
---|
[858] | 71 | } |
---|
| 72 | |
---|
[2413] | 73 | |
---|
[4512] | 74 | function blockToggleDisplay(headerId, contentId) |
---|
| 75 | { |
---|
| 76 | var revHeader = document.getElementById(headerId); |
---|
| 77 | var revContent = document.getElementById(contentId); |
---|
[2413] | 78 | |
---|
[4512] | 79 | if (revContent.style.display == 'none') |
---|
| 80 | { |
---|
| 81 | revContent.style.display = 'block'; |
---|
| 82 | revHeader.className = 'instructionBlockHeaderExpanded'; |
---|
| 83 | } |
---|
| 84 | else |
---|
| 85 | { |
---|
| 86 | revContent.style.display = 'none'; |
---|
| 87 | revHeader.className = 'instructionBlockHeaderCollapsed'; |
---|
| 88 | } |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | |
---|
[2413] | 92 | Function.prototype.pwgBind = function() { |
---|
| 93 | var __method = this, object = arguments[0], args = new Array(); |
---|
| 94 | for (var i=1; i<arguments.length; i++) |
---|
| 95 | args[i-1] = arguments[i]; |
---|
| 96 | return function() { return __method.apply(object, args); } |
---|
| 97 | } |
---|
| 98 | |
---|
[2700] | 99 | function PwgWS(urlRoot) |
---|
[2413] | 100 | { |
---|
| 101 | this.urlRoot = urlRoot; |
---|
| 102 | this.options = { |
---|
| 103 | method: "GET", |
---|
| 104 | async: true, |
---|
| 105 | onFailure: null, |
---|
| 106 | onSuccess: null |
---|
| 107 | }; |
---|
| 108 | }; |
---|
| 109 | |
---|
[3009] | 110 | |
---|
[2413] | 111 | PwgWS.prototype = { |
---|
| 112 | |
---|
| 113 | callService : function(method, parameters, options) |
---|
| 114 | { |
---|
| 115 | if (options) |
---|
| 116 | { |
---|
| 117 | for (var property in options) |
---|
| 118 | this.options[property] = options[property]; |
---|
| 119 | } |
---|
| 120 | try { this.transport = new XMLHttpRequest();} |
---|
| 121 | catch(e) { |
---|
| 122 | try { this.transport = new ActiveXObject('Msxml2.XMLHTTP'); } |
---|
| 123 | catch(e) { |
---|
| 124 | try { this.transport = new ActiveXObject('Microsoft.XMLHTTP'); } |
---|
| 125 | catch (e){ |
---|
| 126 | dispatchError(0, "Cannot create request object"); |
---|
| 127 | } |
---|
| 128 | } |
---|
| 129 | } |
---|
| 130 | this.transport.onreadystatechange = this.onStateChange.pwgBind(this); |
---|
| 131 | |
---|
[4512] | 132 | var url = this.urlRoot+"ws.php?format=json"; |
---|
| 133 | |
---|
| 134 | var body = "method="+method; |
---|
[2413] | 135 | if (parameters) |
---|
| 136 | { |
---|
| 137 | for (var property in parameters) |
---|
| 138 | { |
---|
| 139 | if ( typeof parameters[property] == 'object' && parameters[property]) |
---|
| 140 | { |
---|
| 141 | for (var i=0; i<parameters[property].length; i++) |
---|
[4512] | 142 | body += "&"+property+"[]="+encodeURIComponent(parameters[property][i]); |
---|
[2413] | 143 | } |
---|
| 144 | else |
---|
[4512] | 145 | body += "&"+property+"="+encodeURIComponent(parameters[property]); |
---|
[2413] | 146 | } |
---|
| 147 | } |
---|
[4512] | 148 | |
---|
| 149 | if (this.options.method == "POST" ) |
---|
| 150 | { |
---|
| 151 | this.transport.open(this.options.method, url, this.options.async); |
---|
| 152 | this.transport.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); |
---|
| 153 | this.transport.send(body); |
---|
| 154 | } |
---|
| 155 | else |
---|
| 156 | { |
---|
| 157 | url += "&"+body; |
---|
| 158 | this.transport.open(this.options.method, url, this.options.async); |
---|
| 159 | this.transport.send(null); |
---|
| 160 | } |
---|
[2413] | 161 | }, |
---|
| 162 | |
---|
| 163 | onStateChange: function() { |
---|
| 164 | var readyState = this.transport.readyState; |
---|
| 165 | if (readyState == 4) |
---|
| 166 | this.respondToReadyState(this.transport.readyState); |
---|
| 167 | }, |
---|
| 168 | |
---|
| 169 | dispatchError: function( httpCode, text ) |
---|
| 170 | { |
---|
| 171 | !this.options.onFailure || this.options.onFailure( httpCode, text); |
---|
| 172 | }, |
---|
| 173 | |
---|
| 174 | respondToReadyState: function(readyState) |
---|
| 175 | { |
---|
| 176 | var transport = this.transport; |
---|
| 177 | if (readyState==4 && transport.status == 200) |
---|
| 178 | { |
---|
| 179 | var resp; |
---|
| 180 | try { |
---|
| 181 | eval('resp = ' + transport.responseText); |
---|
| 182 | } |
---|
[2496] | 183 | catch (e) { |
---|
[2429] | 184 | this.dispatchError( 200, e.message + '\n' + transport.responseText.substr(0,512) ); |
---|
[2413] | 185 | } |
---|
| 186 | if (resp!=null) |
---|
| 187 | { |
---|
| 188 | if (resp.stat==null) |
---|
| 189 | this.dispatchError( 200, "Invalid response" ); |
---|
| 190 | else if (resp.stat=='ok') |
---|
| 191 | { |
---|
| 192 | if (this.options.onSuccess) this.options.onSuccess( resp.result ); |
---|
| 193 | } |
---|
| 194 | else |
---|
| 195 | this.dispatchError( 200, resp.err + " " + resp.message); |
---|
| 196 | } |
---|
| 197 | } |
---|
| 198 | if (readyState==4 && transport.status != 200) |
---|
| 199 | this.dispatchError( transport.status, transport.statusText ); |
---|
| 200 | }, |
---|
| 201 | |
---|
| 202 | |
---|
| 203 | transport: null, |
---|
| 204 | urlRoot: null, |
---|
| 205 | options: {} |
---|
| 206 | } |
---|