Changeset 25730 for trunk/tools/ws.htm
- Timestamp:
- Nov 26, 2013, 10:51:53 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/ws.htm
r25394 r25730 4 4 <meta charset="utf-8"> 5 5 <title>Piwigo web API (web-services) explorer</title> 6 6 7 7 <link rel="stylesheet" href="http://cdn.jsdelivr.net/tiptip/1.3/tipTip.css"> 8 8 9 9 <style> 10 10 /* BEGIN CSS RESET … … 13 13 html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, 14 14 del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, 15 fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, 15 fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, 16 16 figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video 17 17 {margin:0;padding:0;border:0;font-size:100%;vertical-align:baseline;} … … 28 28 a {color:#247EBF;text-decoration:none;} 29 29 a:hover {color:#EB9C39;border-bottom-width:1px;border-style:dotted;text-shadow:1px 1px 0 #ddd;} 30 30 31 31 blockquote {border:1px solid #cdcdcd;background:#F9F9F9;padding:8px;} 32 32 hr {margin:10px 30px;color:#fff;} … … 78 78 #testForm tr:last-child td {padding:8px 0 5px 0;} 79 79 #testForm blockquote {width:200px;} 80 80 81 81 #introMessage {font-size:1.1em;} 82 82 #urlForm {margin-bottom:10px;} … … 87 87 } 88 88 a.button:hover {color:#E5FF00;} 89 89 90 90 .methodInfo {float:right;display:inline-block;width:16px;height:16px;font-size:12px;line-height:16px;background:#555;border-radius:8px;font-family:"Times New Roman",sans-serif;font-style:italic;font-weight:bold;text-align:center;color:#fff;} 91 91 .methodInfo:hover {border:none;text-shadow:none;background:#888;cursor:pointer;color:#fff;} 92 92 #tiptip_content { font-size:12px; } 93 93 94 94 #iframeWrapper {width:100%;height:300px;padding:3px 3px 20px 3px;background:#F9F9F9;border:1px solid #cdcdcd;overflow:hidden;position:relative;} 95 95 iframe {width:100%;height:100%;background:#fff;} 96 96 97 97 div.onlys {background:#faa;color:#fff;border:1px solid #f22;padding:.25em .5em;display:table;border-radius:4px;margin-bottom:0.5em;} 98 98 </style> 99 99 100 100 </head> 101 101 … … 109 109 <div id="the_methods"> 110 110 <h2>Available methods</h2> 111 111 112 112 <ul id="methodsList"> 113 113 </ul> … … 117 117 <h2 id="methodName" style="display:none;"></h2> 118 118 <h2 id="errorWrapper" style="display:none;"></h2> 119 119 120 120 <div id="the_content"> 121 121 <form id="urlForm" style="display:none;"> … … 123 123 <input type="submit" value="Go!"> 124 124 </form> 125 125 126 126 <blockquote id="introMessage"> 127 127 <p> … … 154 154 <br> 155 155 </div> <!-- methodDescription --> 156 156 157 157 <div id="testForm"> 158 158 <h3>Test</h3> … … 188 188 </blockquote> 189 189 </div> <!-- testForm --> 190 190 191 191 <div id="methodParams"> 192 192 <h3>Method parameters</h3> … … 201 201 </tr> 202 202 </thead> 203 203 204 204 <tbody> 205 205 </tbody> 206 206 207 207 <tfoot> 208 208 <tr> … … 215 215 </table> 216 216 </div> <!-- methodParams --> 217 217 218 218 <br><br> 219 219 220 220 <h3>Result</h3> 221 221 <div id="iframeWrapper"> … … 226 226 </div> 227 227 </form> <!-- iframeWrapper --> 228 228 229 229 <!-- hidden form for POST submition --> 230 230 <form method="post" action="" target="" id="invokeForm" style="display:none;"></form> 231 231 232 232 </div> <!-- the_content --> 233 233 … … 241 241 <script src="https://cdn.jsdelivr.net/tiptip/1.3/jquery.tipTip.minified.js"></script> 242 242 243 <script> 243 <script> 244 244 // global vars 245 245 var cachedMethods = new Array; … … 301 301 $("#the_page").css('height', 'auto'); 302 302 $("#the_methods").css('height', 'auto'); 303 303 304 304 min_h = $(window).height()-$("#the_header").outerHeight()-$("#the_footer").outerHeight()-3; 305 305 h = Math.max(min_h, Math.max($("#the_methods").height(), $("#the_page").height())); 306 306 307 307 $("#the_page").css('height', h); 308 308 $("#the_methods").css('height', h); … … 337 337 resp = {"stat": "ko", "result": "null"}; 338 338 } 339 339 340 340 return resp.result; 341 341 } … … 344 344 function getMethodList() { 345 345 resetDisplay(); 346 346 347 347 $.ajax({ 348 348 type: "GET", … … 351 351 }).done(function(result) { 352 352 result = parsePwgJSON(result); 353 353 354 354 if (result!=null) { 355 355 methods = result.methods; 356 356 357 357 var ml = ''; 358 358 for (var i=0; i<methods.length; i++) … … 361 361 } 362 362 $("#methodsList").html(ml).show(); 363 363 364 364 adaptHeight(); 365 365 366 366 // trigger method selection 367 367 $("#methodsList li a").click(function() { … … 378 378 $("#introMessage").hide(); 379 379 $("#tiptip_holder").fadeOut(200); 380 380 381 381 if (cachedMethods[ methodName ]) { 382 382 fillNewMethod(methodName); … … 387 387 url: ws_url, 388 388 data: { format: "json", method: "reflection.getMethodDetails", methodName: methodName } 389 }).done(function(result) { 389 }).done(function(result) { 390 390 result = parsePwgJSON(result); 391 391 392 392 if (result!=null) { 393 if (result.options.post_only || result.options.admin_only) { 394 var onlys = '<div class="onlys">'; 395 if (result.options.post_only) { 396 onlys+= 'POST only. '; 397 } 398 if (result.options.admin_only) { 399 onlys+= 'Admin only. '; 400 } 401 onlys+= '</div>'; 402 403 result.description = onlys + result.description; 404 } 393 405 cachedMethods[ methodName ] = result; 394 406 fillNewMethod(methodName); … … 403 415 function fillNewMethod(methodName) { 404 416 resetDisplay(); 405 417 406 418 method = cachedMethods[ methodName ]; 407 419 408 420 $("#methodName").html(method.name).show(); 409 410 if (method.options.post_only || method.options.admin_only) { 411 var onlys = '<div class="onlys">'; 412 if (method.options.post_only) { 413 onlys+= 'POST only. '; 414 } 415 if (method.options.admin_only) { 416 onlys+= 'Admin only. '; 417 } 418 onlys+= '</div>'; 419 420 method.description = onlys + method.description; 421 } 422 421 423 422 if (method.description != "") { 424 423 $("#methodDescription blockquote").html(method.description); 425 424 $("#methodDescription").show(); 426 425 } 427 426 428 427 $("#requestFormat").val(method.options.post_only ? 'post' : 'get'); 429 428 430 429 var methodParams = ''; 431 430 if (method.params && method.params.length>0) { … … 437 436 info = param.info == null ? '' : '<a class="methodInfo" title="'+ param.info.replace(/"/g, '"') + '">i</a>', 438 437 type = ''; 439 438 440 439 if (param.type.match(/bool/)) type+= '<span class=type>B</span>'; 441 440 if (param.type.match(/int/)) type+= '<span class=type>I</span>'; … … 443 442 if (param.type.match(/positive/)) type+= '<span class=subtype>+</span>'; 444 443 if (param.type.match(/notnull/)) type+= '<span class=subtype>ø</span>'; 445 444 446 445 // if an array is direclty printed, the delimiter is a comma where we use a pipe 447 446 if (typeof defaultValue == 'object') { … … 461 460 methodParams = '<tr><td colspan="4">This method takes no parameters</td></tr>'; 462 461 } 463 462 464 463 $("#methodParams tbody").html(methodParams); 465 $("#methodWrapper").show(); 466 464 $("#methodWrapper").show(); 465 467 466 adaptHeight(); 468 467 469 468 // trigger field modification 470 469 $("input.methodParameterValue").change(function() { 471 470 $("input.methodParameterSend[data-id='"+ $(this).data('id') +"']").attr('checked', 'checked'); 472 471 }); 473 472 474 473 // tiptip 475 474 $(".methodInfo").tipTip({ … … 485 484 486 485 var reqUrl = ws_url +"?format="+ $("#responseFormat").val(); 487 486 488 487 // GET 489 488 if ($("#requestFormat").val() == 'get') { 490 489 reqUrl+= "&method="+ methodName; 491 490 492 491 for (var i=0; i<method.params.length; i++) { 493 492 if (! $("input.methodParameterSend[data-id='"+ i +"']").is(":checked")) { … … 496 495 497 496 var paramValue = $("input.methodParameterValue[data-id='"+ i +"']").val(); 498 497 499 498 var paramSplitted = paramValue.split('|'); 500 499 if (method.params[i].acceptArray && paramSplitted.length > 1) { … … 507 506 } 508 507 } 509 508 510 509 if (newWindow) { 511 510 window.open(reqUrl); … … 519 518 var form = $("#invokeForm"); 520 519 form.attr('action', reqUrl); 521 520 522 521 var t = '<input type="hidden" name="method" value="'+ methodName +'">'; 523 522 524 523 for (var i=0; i<method.params.length; i++) { 525 524 if (! $("input.methodParameterSend[data-id='"+ i +"']").is(":checked")) { … … 539 538 } 540 539 } 541 540 542 541 form.html(t); 543 542 form.attr('target', newWindow ? "_blank" : "invokeFrame"); 544 543 form.submit(); 545 544 } 546 545 547 546 return false; 548 547 }
Note: See TracChangeset
for help on using the changeset viewer.