1 | function SelectAll( formulaire ) |
---|
2 | { |
---|
3 | var len = formulaire.elements.length; |
---|
4 | var i=0; |
---|
5 | for( i = 0; i < len; i++) |
---|
6 | { |
---|
7 | if ( formulaire.elements[i].type=='checkbox' |
---|
8 | && formulaire.elements[i].name != 'copie') |
---|
9 | { |
---|
10 | formulaire.elements[i].checked = true; |
---|
11 | } |
---|
12 | } |
---|
13 | } |
---|
14 | |
---|
15 | function DeselectAll( formulaire ) |
---|
16 | { |
---|
17 | var len = formulaire.elements.length; |
---|
18 | var i=0; |
---|
19 | for( i = 0; i < len; i++) |
---|
20 | { |
---|
21 | if ( formulaire.elements[i].type=='checkbox' |
---|
22 | && formulaire.elements[i].name != 'copie') |
---|
23 | { |
---|
24 | formulaire.elements[i].checked = false; |
---|
25 | } |
---|
26 | } |
---|
27 | } |
---|
28 | |
---|
29 | function Inverser( formulaire ) |
---|
30 | { |
---|
31 | var len = formulaire.elements.length; |
---|
32 | var i=0; |
---|
33 | for( i=0; i<len; i++) |
---|
34 | { |
---|
35 | if ( formulaire.elements[i].type=='checkbox' |
---|
36 | && formulaire.elements[i].name != 'copie') |
---|
37 | { |
---|
38 | formulaire.elements[i].checked = !formulaire.elements[i].checked; |
---|
39 | } |
---|
40 | } |
---|
41 | } |
---|
42 | |
---|
43 | function phpWGOpenWindow(theURL,winName,features) |
---|
44 | { |
---|
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); |
---|
59 | } |
---|
60 | |
---|
61 | function resizeWindowToFit() |
---|
62 | { |
---|
63 | newWin.resizeTo( img.width+50, img.height+100); |
---|
64 | } |
---|
65 | |
---|
66 | function popuphelp(url) |
---|
67 | { |
---|
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 | ); |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | |
---|
75 | Function.prototype.pwgBind = function() { |
---|
76 | var __method = this, object = arguments[0], args = new Array(); |
---|
77 | for (var i=1; i<arguments.length; i++) |
---|
78 | args[i-1] = arguments[i]; |
---|
79 | return function() { return __method.apply(object, args); } |
---|
80 | } |
---|
81 | |
---|
82 | function PwgWS(urlRoot) |
---|
83 | { |
---|
84 | this.urlRoot = urlRoot; |
---|
85 | this.options = { |
---|
86 | method: "GET", |
---|
87 | async: true, |
---|
88 | onFailure: null, |
---|
89 | onSuccess: null |
---|
90 | }; |
---|
91 | }; |
---|
92 | |
---|
93 | PwgWS.prototype = { |
---|
94 | |
---|
95 | callService : function(method, parameters, options) |
---|
96 | { |
---|
97 | if (options) |
---|
98 | { |
---|
99 | for (var property in options) |
---|
100 | this.options[property] = options[property]; |
---|
101 | } |
---|
102 | try { this.transport = new XMLHttpRequest();} |
---|
103 | catch(e) { |
---|
104 | try { this.transport = new ActiveXObject('Msxml2.XMLHTTP'); } |
---|
105 | catch(e) { |
---|
106 | try { this.transport = new ActiveXObject('Microsoft.XMLHTTP'); } |
---|
107 | catch (e){ |
---|
108 | dispatchError(0, "Cannot create request object"); |
---|
109 | } |
---|
110 | } |
---|
111 | } |
---|
112 | this.transport.onreadystatechange = this.onStateChange.pwgBind(this); |
---|
113 | |
---|
114 | var url = this.urlRoot+"ws.php?format=json"; |
---|
115 | |
---|
116 | var body = "method="+method; |
---|
117 | if (parameters) |
---|
118 | { |
---|
119 | for (var property in parameters) |
---|
120 | { |
---|
121 | if ( typeof parameters[property] == 'object' && parameters[property]) |
---|
122 | { |
---|
123 | for (var i=0; i<parameters[property].length; i++) |
---|
124 | body += "&"+property+"[]="+encodeURIComponent(parameters[property][i]); |
---|
125 | } |
---|
126 | else |
---|
127 | body += "&"+property+"="+encodeURIComponent(parameters[property]); |
---|
128 | } |
---|
129 | } |
---|
130 | |
---|
131 | if (this.options.method == "POST" ) |
---|
132 | { |
---|
133 | this.transport.open(this.options.method, url, this.options.async); |
---|
134 | this.transport.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); |
---|
135 | this.transport.send(body); |
---|
136 | } |
---|
137 | else |
---|
138 | { |
---|
139 | url += "&"+body; |
---|
140 | this.transport.open(this.options.method, url, this.options.async); |
---|
141 | this.transport.send(null); |
---|
142 | } |
---|
143 | }, |
---|
144 | |
---|
145 | onStateChange: function() { |
---|
146 | var readyState = this.transport.readyState; |
---|
147 | if (readyState == 4) |
---|
148 | this.respondToReadyState(this.transport.readyState); |
---|
149 | }, |
---|
150 | |
---|
151 | dispatchError: function( httpCode, text ) |
---|
152 | { |
---|
153 | !this.options.onFailure || this.options.onFailure( httpCode, text); |
---|
154 | }, |
---|
155 | |
---|
156 | respondToReadyState: function(readyState) |
---|
157 | { |
---|
158 | var transport = this.transport; |
---|
159 | if (readyState==4 && transport.status == 200) |
---|
160 | { |
---|
161 | var resp; |
---|
162 | try { |
---|
163 | eval('resp = ' + transport.responseText); |
---|
164 | } |
---|
165 | catch (e) { |
---|
166 | this.dispatchError( 200, e.message + '\n' + transport.responseText.substr(0,512) ); |
---|
167 | } |
---|
168 | if (resp!=null) |
---|
169 | { |
---|
170 | if (resp.stat==null) |
---|
171 | this.dispatchError( 200, "Invalid response" ); |
---|
172 | else if (resp.stat=='ok') |
---|
173 | { |
---|
174 | if (this.options.onSuccess) this.options.onSuccess( resp.result ); |
---|
175 | } |
---|
176 | else |
---|
177 | this.dispatchError( 200, resp.err + " " + resp.message); |
---|
178 | } |
---|
179 | } |
---|
180 | if (readyState==4 && transport.status != 200) |
---|
181 | this.dispatchError( transport.status, transport.statusText ); |
---|
182 | }, |
---|
183 | |
---|
184 | |
---|
185 | transport: null, |
---|
186 | urlRoot: null, |
---|
187 | options: {} |
---|
188 | } |
---|