Changeset 1849 for trunk/tools
- Timestamp:
- Feb 22, 2007, 2:12:32 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/ws.htm
r1698 r1849 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 1 2 <html> 2 3 <head> … … 41 42 42 43 var gServiceUrl; 44 var gCurrentMethodParams; 43 45 44 46 Ajax.Responders.register({ … … 105 107 106 108 gServiceUrl = $F('ws_url'); 109 gCurrentMethodParams = null; 107 110 108 111 try { … … 138 141 setVisibility("methodDetailWrapper", "hidden"); 139 142 setVisibility("methodWrapper", "visible"); 143 gCurrentMethodParams = null; 140 144 141 145 try { … … 161 165 methodParamsElt.tBodies[0].deleteRow(methodParamsElt.tBodies[0].rows.length-1); 162 166 163 if (result.params && result.params.length>0) 164 { 165 for (var i=0; i<result.params.length; i++) 166 { 167 var row = methodParamsElt.tBodies[0].insertRow(-1); 168 var isOptional = result.params[i].optional; 169 var defaultValue = result.params[i].defaultValue == null ? '' : result.params[i].defaultValue; 170 171 row.insertCell(0).innerHTML = result.params[i].name; 172 row.insertCell(1).innerHTML = (isOptional ? 'optional':'required'); 173 row.insertCell(2).innerHTML = '<input id="methodParameterSend_'+i+'" type="checkbox" '+(isOptional ? '':'checked="checked"')+'/>'; 174 row.insertCell(3).innerHTML = '<input id="methodParameterName_'+i+'" type="hidden" value="'+result.params[i].name+'"/>' 175 +'<input id="methodParameterValue_'+i+'"" value="'+defaultValue+'" style="width:99%" onchange="$(\'methodParameterSend_'+i+'\').checked=true;"/>'; 176 } 167 if (result.params) 168 { 169 gCurrentMethodParams = result.params; 170 if (result.params.length>0) 171 { 172 for (var i=0; i<result.params.length; i++) 173 { 174 var row = methodParamsElt.tBodies[0].insertRow(-1); 175 var isOptional = result.params[i].optional; 176 var defaultValue = result.params[i].defaultValue == null ? '' : result.params[i].defaultValue; 177 178 row.insertCell(0).innerHTML = result.params[i].name; 179 row.insertCell(1).innerHTML = (isOptional ? 'optional':'required'); 180 row.insertCell(2).innerHTML = '<input id="methodParameterSend_'+i+'" type="checkbox" '+(isOptional ? '':'checked="checked"')+'/>'; 181 row.insertCell(3).innerHTML = '<input id="methodParameterValue_'+i+'"" value="'+defaultValue+'" style="width:99%" onchange="$(\'methodParameterSend_'+i+'\').checked=true;"/>'; 182 } 183 } 177 184 } 178 185 setElementText("methodDescription", result.description); … … 180 187 } 181 188 182 function pwgInvokeMethod( )189 function pwgInvokeMethod( newWindow ) 183 190 { 184 191 var method = document.getElementById('methodName').innerHTML; … … 190 197 { 191 198 reqUrl += "&method="+method; 192 var i=0; 193 do 199 for ( var i=0; i<gCurrentMethodParams.length; i++) 194 200 { 195 var elt = document.getElementById('methodParameterName_'+i);196 if (!elt) break;197 201 if (document.getElementById('methodParameterSend_'+i).checked) 198 reqUrl += '&'+elt.value+'='+$F('methodParameterValue_'+i); 199 i++; 202 reqUrl += '&'+gCurrentMethodParams[i].name+'='+$F('methodParameterValue_'+i); 200 203 } 201 while (1); 202 document.getElementById("invokeFrame").src = reqUrl; 204 if ( !newWindow ) 205 document.getElementById("invokeFrame").src = reqUrl; 206 else 207 window.open(reqUrl); 203 208 } 204 209 else … … 207 212 form.action = reqUrl; 208 213 var t = '<input type="hidden" name="'+'method'+'" value="'+method+'"/>'; 209 var i=0; 210 do 214 for ( var i=0; i<gCurrentMethodParams.length; i++) 211 215 { 212 var elt = document.getElementById('methodParameterName_'+i);213 if (!elt) break;214 216 if (document.getElementById('methodParameterSend_'+i).checked) 215 t += '<input type="hidden" name="'+elt.value+'" value="'+$F('methodParameterValue_'+i)+'"/>'; 216 i++; 217 t += '<input type="hidden" name="'+gCurrentMethodParams[i].name+'" value="'+$F('methodParameterValue_'+i)+'"/>'; 217 218 } 218 while (1);219 219 form.innerHTML = t; 220 if ( !newWindow ) 221 form.target = "invokeFrame"; 222 else 223 form.target = "_blank"; 220 224 form.submit(); 221 225 } … … 227 231 <style> 228 232 #methodListWrapper { 229 width: 1 6em;233 width: 13em; 230 234 float: left; 231 235 display: inline; … … 234 238 235 239 #methodList { 236 padding-left: 15px; 240 padding-left: 10px; 241 margin-left: 15px; 237 242 } 238 243 239 244 #methodWrapper { 240 margin-left: 1 6.5em;245 margin-left: 14em; 241 246 visibility: hidden; 242 247 } … … 256 261 #methodParams { 257 262 border-collapse: collapse; 258 } 263 font-size: small; 264 } 265 266 #methodParams input { 267 font-size: 90%; 268 border: 1px solid black; 269 text-indent: 2px; 270 } 271 272 273 a { 274 color: #02f; 275 background-color: white; 276 text-decoration: underline; 277 } 278 279 a:hover { 280 color: white; 281 background-color: #02f; 282 text-decoration: none; 283 cursor:pointer; 284 } 285 259 286 </style> 260 287 … … 280 307 <div> 281 308 282 <div id="methodListWrapper"> Methods309 <div id="methodListWrapper"><h2>Methods</h2> 283 310 <ul id="methodList"> 284 311 <li><a href="#" onclick="return pwgSelectMethod(this.innerHTML)">getVersion</a></li> … … 289 316 <h2 id="methodName"></h2> 290 317 <div id="methodDetailWrapper"> 291 <div id="methodDescription"></div> 318 292 319 <table> 293 <tr> 294 <td>Request format:</td> 295 <td> 296 <select id="requestFormat"> 297 <option value="get" selected="selected">GET</option> 298 <option value="post">POST</option> 299 </select> 300 </td> 301 </tr> 302 303 <tr> 304 <td>Response format:</td> 305 <td> 306 <select id="responseFormat"> 307 <option value="rest" selected="selected">REST (xml)</option> 308 <option value="json">JSON</option> 309 <option value="php">PHP serial</option> 310 <option value="xmlrpc">XML RPC</option> 311 </select> 312 </td> 313 </tr> 320 <tr style="vertical-align:top"> 321 322 <td> 323 <div id="methodDescription"></div> 324 <table> 325 <tr> 326 <td>Request format:</td> 327 <td> 328 <select id="requestFormat"> 329 <option value="get" selected="selected">GET</option> 330 <option value="post">POST</option> 331 </select> 332 </td> 333 </tr> 334 335 <tr> 336 <td>Response format:</td> 337 <td> 338 <select id="responseFormat"> 339 <option value="rest" selected="selected">REST (xml)</option> 340 <option value="json">JSON</option> 341 <option value="php">PHP serial</option> 342 <option value="xmlrpc">XML RPC</option> 343 </select> 344 </td> 345 </tr> 346 </table> 347 <p> 348 <a href="#" onclick="return pwgInvokeMethod(false)">Invoke</a> 349 <a href="#" onclick="return pwgInvokeMethod(true)">Invoke (new Window)</a> 350 </p> 351 </td> 352 353 354 <td> 355 <table id="methodParams" border="1" cellspacing="0" cellpadding="2px"> 356 <thead> 357 <tr> 358 <td style="width:150px">Parameter</td> 359 <td>Optional</td> 360 <td>Send</td> 361 <td style="width:160px">Value</td> 362 </tr> 363 </thead> 364 <tbody> 365 </tbody> 366 </table> 367 </td> 368 369 </tr> 314 370 </table> 315 316 <div id="methodParamsWrapper"> 317 <table id="methodParams" border="1" cellspacing="0" cellpadding="2px"> 318 <thead> 319 <tr> 320 <td style="width:150px">Parameter</td> 321 <td>Optional</td> 322 <td>Send</td> 323 <td style="width:160px">Value</td> 324 </tr> 325 </thead> 326 <tbody> 327 </tbody> 328 </table> 329 </div> 330 <a href="#" onclick="return pwgInvokeMethod()">Invoke</a> 331 332 <div style="display:none"> 371 372 <div style="display:none;"> 333 373 <!-- hiddenForm for POST --> 334 374 <form method="post" action="" target="invokeFrame" id="invokeForm"> … … 337 377 </div> 338 378 339 <iframe width="100%" height="400px" id="invokeFrame" name="invokeFrame" ></iframe>379 <iframe width="100%" height="400px" id="invokeFrame" name="invokeFrame" style="clear:both"></iframe> 340 380 </div> <!-- methodDetailWrapper --> 341 381 </div> <!-- methodWrapper -->
Note: See TracChangeset
for help on using the changeset viewer.