[20192] | 1 | <!DOCTYPE html> |
---|
[25394] | 2 | <html lang="en" dir="ltr"> |
---|
[1698] | 3 | <head> |
---|
[25394] | 4 | <meta charset="utf-8"> |
---|
[18079] | 5 | <title>Piwigo web API (web-services) explorer</title> |
---|
[25730] | 6 | |
---|
[25394] | 7 | <link rel="stylesheet" href="http://cdn.jsdelivr.net/tiptip/1.3/tipTip.css"> |
---|
[25730] | 8 | |
---|
[25394] | 9 | <style> |
---|
[18079] | 10 | /* BEGIN CSS RESET |
---|
| 11 | http://meyerweb.com/eric/tools/css/reset |
---|
| 12 | v2.0 | 20110126 | License: none (public domain) */ |
---|
| 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 | 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, |
---|
[25730] | 15 | fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, |
---|
[18079] | 16 | figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video |
---|
| 17 | {margin:0;padding:0;border:0;font-size:100%;vertical-align:baseline;} |
---|
[1698] | 18 | |
---|
[18079] | 19 | article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {display:block;} |
---|
| 20 | body {line-height:1.1;} |
---|
| 21 | blockquote, q {quotes:none;} |
---|
| 22 | blockquote:before, blockquote:after, q:before, q:after {content:'';content:none;} |
---|
| 23 | table {border-collapse:collapse;border-spacing:0;} |
---|
| 24 | /* END CSS RESET */ |
---|
[1698] | 25 | |
---|
[18079] | 26 | html {font-family:"Corbel","Lucida Grande","Verdana",sans-serif;color:#222;font-size:13px;} |
---|
[1698] | 27 | |
---|
[18079] | 28 | a {color:#247EBF;text-decoration:none;} |
---|
[23714] | 29 | a:hover {color:#EB9C39;border-bottom-width:1px;border-style:dotted;text-shadow:1px 1px 0 #ddd;} |
---|
[25730] | 30 | |
---|
[18079] | 31 | blockquote {border:1px solid #cdcdcd;background:#F9F9F9;padding:8px;} |
---|
| 32 | hr {margin:10px 30px;color:#fff;} |
---|
| 33 | ul {margin-left:25px;} |
---|
| 34 | p {margin:8px 0;} |
---|
[1698] | 35 | |
---|
[23714] | 36 | h1 {color:#fff;font-size:26px;padding:10px 15px;text-shadow:1px 1px 0 #999; |
---|
| 37 | background:#45484d;background:linear-gradient(to bottom, #45484d 0%,#333333 100%); |
---|
[18079] | 38 | } |
---|
[23714] | 39 | h2 {color:#fff;font-size:20px;padding:5px 10px;text-shadow:1px 1px 0 #555; |
---|
| 40 | background:#f2a841;background:linear-gradient(to bottom, #f2a841 0%,#ef6b13 100%); |
---|
[18079] | 41 | } |
---|
| 42 | h2#errorWrapper {color:#F42C00;font-weight:normal; |
---|
[23714] | 43 | background:#eaeaea;background:linear-gradient(to bottom, #eaeaea 0%, #afafaf 100%); |
---|
[18079] | 44 | } |
---|
| 45 | h3 {display:inline-block;padding:5px 10px;color:#555;font-weight:bold;text-align:center; |
---|
[23714] | 46 | border-radius:8px 8px 0 0;text-shadow:1px 1px 0 #bbb; |
---|
| 47 | background:#f2f2f2;background:linear-gradient(to bottom, #f2f2f2 0%,#cecece 100%); |
---|
[18079] | 48 | } |
---|
[1698] | 49 | |
---|
[18079] | 50 | #the_header {border-bottom:1px solid #cdcdcd;margin-bottom:1px;} |
---|
| 51 | #the_footer {background:#EAEAEA;border-top:1px solid #cdcdcd;padding:10px;clear:both;} |
---|
[1698] | 52 | |
---|
[18079] | 53 | #the_methods {width:250px;float:left;border-style:solid;border-color:#cdcdcd;border-width:1px 1px 0 0; |
---|
| 54 | background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAADCAIAAADZSiLoAAAAH0lEQVQImSXHMQEAMAwCMOrfK0jIjuVL2gLBzyHJtgd7wBdU3Vt/7AAAAABJRU5ErkJggg==); |
---|
| 55 | } |
---|
[25077] | 56 | #methodsList {font-size:1.1em;margin:5px 0 10px 10px;list-style:none;} |
---|
| 57 | #methodsList li:before {content:"\203A\00A0";font-weight:bold;color:#EB9C39;font-size:1.1em;} |
---|
| 58 | #methodsList li:hover:before {content:"\00A0\203A";} |
---|
[1698] | 59 | |
---|
[18079] | 60 | #the_page {margin-left:252px;border-style:solid;border-color:#cdcdcd;border-width:1px 0 0 1px;} |
---|
| 61 | #the_content {padding:10px;} |
---|
[1698] | 62 | |
---|
[25394] | 63 | #methodParams {margin-right:230px;} |
---|
[18079] | 64 | #methodParams thead td {background:#DEE3E9;font-weight:bold;padding:2px 5px;} |
---|
| 65 | #methodParams td {padding:2px;border:1px solid #cdcdcd;vertical-align:middle;} |
---|
| 66 | #methodParams tbody tr:nth-child(even) {background:#f7f7f7;} |
---|
| 67 | #methodParams tbody tr td:first-child {font-family:monospace;font-size:0.95em;} |
---|
| 68 | #methodParams td.mini {width:0px;text-align:center;} |
---|
| 69 | #methodParams tfoot {font-size:0.95em;} |
---|
| 70 | #methodParams td.input {text-align:center;} |
---|
[23714] | 71 | #methodParams td.input input[type="text"] {width:97%;font-size:0.9em;background:#f7f7f7;border:1px solid #ccc;border-radius:2px;} |
---|
[18079] | 72 | #methodParams td.input input[type="text"]:hover, #methodParams td.input input[type="text"]:focus {border-color:#C7E2F1;border-top-color:#96BCD7;background:#fff;} |
---|
[25077] | 73 | #methodParams .type {display:inline-block;width:16px;height:16px;font-size:12px;line-height:16px;background:#ddd;border-radius:8px;font-weight:bold;text-align:center;color:#222;} |
---|
| 74 | #methodParams .subtype {vertical-align:super;} |
---|
[1698] | 75 | |
---|
[25394] | 76 | #testForm {float:right;} |
---|
[18079] | 77 | #testForm td {padding:2px 0;} |
---|
| 78 | #testForm tr:last-child td {padding:8px 0 5px 0;} |
---|
| 79 | #testForm blockquote {width:200px;} |
---|
[25730] | 80 | |
---|
[18079] | 81 | #introMessage {font-size:1.1em;} |
---|
| 82 | #urlForm {margin-bottom:10px;} |
---|
| 83 | |
---|
| 84 | a.button {color:#fff;padding:3px 8px;border:1px solid #91bb5c;font-size:0.9em;margin-right:3px;display:inline-block; |
---|
[23714] | 85 | border-radius:5px;text-shadow:1px 1px 0 #666; |
---|
| 86 | background:#84bb3c;background:linear-gradient(to bottom, #84bb3c 0%, #3f5a1d 100%); |
---|
[1698] | 87 | } |
---|
[18079] | 88 | a.button:hover {color:#E5FF00;} |
---|
[25730] | 89 | |
---|
[20750] | 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 | .methodInfo:hover {border:none;text-shadow:none;background:#888;cursor:pointer;color:#fff;} |
---|
[25077] | 92 | #tiptip_content { font-size:12px; } |
---|
[25730] | 93 | |
---|
[18079] | 94 | #iframeWrapper {width:100%;height:300px;padding:3px 3px 20px 3px;background:#F9F9F9;border:1px solid #cdcdcd;overflow:hidden;position:relative;} |
---|
| 95 | iframe {width:100%;height:100%;background:#fff;} |
---|
[25730] | 96 | |
---|
[25394] | 97 | div.onlys {background:#faa;color:#fff;border:1px solid #f22;padding:.25em .5em;display:table;border-radius:4px;margin-bottom:0.5em;} |
---|
[18079] | 98 | </style> |
---|
[25730] | 99 | |
---|
[18079] | 100 | </head> |
---|
[1698] | 101 | |
---|
[18079] | 102 | <body> |
---|
[25394] | 103 | <a name="top"></a> |
---|
[1698] | 104 | |
---|
[18079] | 105 | <div id="the_header"> |
---|
| 106 | <h1>Piwigo web API (web-services) explorer</h1> |
---|
| 107 | </div> <!-- the_header --> |
---|
[1698] | 108 | |
---|
[18079] | 109 | <div id="the_methods"> |
---|
| 110 | <h2>Available methods</h2> |
---|
[25730] | 111 | |
---|
[18079] | 112 | <ul id="methodsList"> |
---|
| 113 | </ul> |
---|
| 114 | </div> <!-- the_methods --> |
---|
[1698] | 115 | |
---|
[18079] | 116 | <div id="the_page"> |
---|
| 117 | <h2 id="methodName" style="display:none;"></h2> |
---|
| 118 | <h2 id="errorWrapper" style="display:none;"></h2> |
---|
[25730] | 119 | |
---|
[18079] | 120 | <div id="the_content"> |
---|
| 121 | <form id="urlForm" style="display:none;"> |
---|
| 122 | <input type="text" name="ws_url" size="60"> |
---|
| 123 | <input type="submit" value="Go!"> |
---|
| 124 | </form> |
---|
[25730] | 125 | |
---|
[18079] | 126 | <blockquote id="introMessage"> |
---|
| 127 | <p> |
---|
| 128 | <b>API = Application Programming Interface.</b><br> |
---|
| 129 | This is the way other applications can communicate with Piwigo. This feature is also know as Web Services. |
---|
| 130 | </p> |
---|
[1698] | 131 | |
---|
[18079] | 132 | <p>Examples:</p> |
---|
| 133 | <ul> |
---|
| 134 | <li>Wordpress (web blog software) can display random photos from a Piwigo gallery in its sidebar</li> |
---|
| 135 | <li>Lightroom (photo management software for desktop) can create albums and upload photos to Piwigo</li> |
---|
| 136 | </ul> |
---|
[1698] | 137 | |
---|
[18079] | 138 | <p> |
---|
| 139 | This page lists all API methods available on your Piwigo installation, part of the Piwigo core or added by third-party plugins. |
---|
| 140 | For each method you can consult required and optional parameters, and even test them in direct live! |
---|
| 141 | </p> |
---|
[1698] | 142 | |
---|
[18079] | 143 | <p> |
---|
| 144 | For more information you can consult our Wiki <a href="http://piwigo.org/doc/doku.php?id=dev:webapi:start" target="_blank">Piwigo Web API</a> and <a href="http://piwigo.org/forum" target="_blank">our forums</a>. |
---|
| 145 | </p> |
---|
| 146 | </blockquote> <!-- introMessage --> |
---|
[1852] | 147 | |
---|
[1698] | 148 | |
---|
[18079] | 149 | <form id="methodWrapper" style="display:none;"> |
---|
| 150 | <div id="methodDescription" style="display:none;"> |
---|
| 151 | <h3>Description</h3> |
---|
| 152 | <blockquote> |
---|
| 153 | </blockquote> |
---|
[18732] | 154 | <br> |
---|
[18079] | 155 | </div> <!-- methodDescription --> |
---|
[25730] | 156 | |
---|
[18079] | 157 | <div id="testForm"> |
---|
| 158 | <h3>Test</h3> |
---|
| 159 | <blockquote> |
---|
| 160 | <table> |
---|
| 161 | <tr> |
---|
| 162 | <td>Request format :</td> |
---|
| 163 | <td> |
---|
| 164 | <select id="requestFormat"> |
---|
[25394] | 165 | <option value="get" selected>GET</option> |
---|
[18079] | 166 | <option value="post">POST</option> |
---|
| 167 | </select> |
---|
| 168 | </td> |
---|
| 169 | </tr> |
---|
| 170 | <tr> |
---|
| 171 | <td>Response format :</td> |
---|
| 172 | <td> |
---|
| 173 | <select id="responseFormat"> |
---|
[25394] | 174 | <option value="rest" selected>REST (xml)</option> |
---|
[18079] | 175 | <option value="json">JSON</option> |
---|
| 176 | <option value="php">PHP serial</option> |
---|
| 177 | <option value="xmlrpc">XML RPC</option> |
---|
| 178 | </select> |
---|
| 179 | </td> |
---|
| 180 | </tr> |
---|
| 181 | <tr> |
---|
| 182 | <td colspan="2"> |
---|
| 183 | <a href="#" class="button" id="invokeMethod">INVOKE</a> |
---|
| 184 | <a href="#" class="button" id="invokeMethodBlank">INVOKE (new window)</a> |
---|
| 185 | </td> |
---|
| 186 | </tr> |
---|
| 187 | </table> |
---|
| 188 | </blockquote> |
---|
| 189 | </div> <!-- testForm --> |
---|
[25730] | 190 | |
---|
[25394] | 191 | <div id="methodParams"> |
---|
| 192 | <h3>Method parameters</h3> |
---|
| 193 | <table> |
---|
| 194 | <thead> |
---|
| 195 | <tr> |
---|
| 196 | <td style="width:150px;">Name</td> |
---|
| 197 | <td class="mini">Extra</td> |
---|
| 198 | <td class="mini">Type</td> |
---|
| 199 | <td style="width:300px;">Value</td> |
---|
| 200 | <td class="mini">Send</td> |
---|
| 201 | </tr> |
---|
| 202 | </thead> |
---|
[25730] | 203 | |
---|
[25394] | 204 | <tbody> |
---|
| 205 | </tbody> |
---|
[25730] | 206 | |
---|
[25394] | 207 | <tfoot> |
---|
| 208 | <tr> |
---|
| 209 | <td colspan="5"> |
---|
| 210 | <b>*</b>: required, <b>?</b>: optional, <b>[]</b>: can be an array (use a pipe | to split values)<br> |
---|
| 211 | <b>B</b>: boolean, <b>I</b>: integer, <b>F</b>: float, <b>+</b>: positive, <b>ø</b>: not null |
---|
| 212 | </td> |
---|
| 213 | </tr> |
---|
| 214 | </tfoot> |
---|
| 215 | </table> |
---|
| 216 | </div> <!-- methodParams --> |
---|
[25730] | 217 | |
---|
[18732] | 218 | <br><br> |
---|
[25730] | 219 | |
---|
[18079] | 220 | <h3>Result</h3> |
---|
| 221 | <div id="iframeWrapper"> |
---|
| 222 | <iframe src="" id="invokeFrame" name="invokeFrame"></iframe> |
---|
[25394] | 223 | <a href="#iframe-bottom" id="increaseIframe"><b>↓</b> increase height</a> • |
---|
| 224 | <a href="#iframe-bottom" id="decreaseIframe"><b>↑</b> decrease height</a> |
---|
| 225 | <a name="iframe-bottom"></a> |
---|
[18079] | 226 | </div> |
---|
| 227 | </form> <!-- iframeWrapper --> |
---|
[25730] | 228 | |
---|
[18079] | 229 | <!-- hidden form for POST submition --> |
---|
| 230 | <form method="post" action="" target="" id="invokeForm" style="display:none;"></form> |
---|
[25730] | 231 | |
---|
[18079] | 232 | </div> <!-- the_content --> |
---|
[2134] | 233 | |
---|
[18079] | 234 | </div> <!-- the_page --> |
---|
[1698] | 235 | |
---|
[18079] | 236 | <div id="the_footer"> |
---|
[20192] | 237 | Copyright © 2002-2013 <a href="http://piwigo.org">Piwigo Team</a> |
---|
[18079] | 238 | </div> <!-- the_footer --> |
---|
[1698] | 239 | |
---|
[25394] | 240 | <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> |
---|
| 241 | <script src="https://cdn.jsdelivr.net/tiptip/1.3/jquery.tipTip.minified.js"></script> |
---|
[1698] | 242 | |
---|
[25730] | 243 | <script> |
---|
[18079] | 244 | // global vars |
---|
| 245 | var cachedMethods = new Array; |
---|
| 246 | var ws_url = "http://"; |
---|
[1852] | 247 | |
---|
[18079] | 248 | // automatic detection of ws_url |
---|
| 249 | match = document.location.toString().match(/^(https?.*\/)tools\/ws\.html?/); |
---|
| 250 | if (match==null) { |
---|
| 251 | askForUrl(); |
---|
| 252 | } |
---|
| 253 | else { |
---|
| 254 | ws_url = match[1]+'ws.php'; |
---|
| 255 | getMethodList(); |
---|
| 256 | } |
---|
[1852] | 257 | |
---|
[18079] | 258 | // manual set of ws_url |
---|
| 259 | $("#urlForm").submit(function() { |
---|
| 260 | ws_url = $(this).children("input[name='ws_url']").val(); |
---|
| 261 | getMethodList(); |
---|
[1698] | 262 | return false; |
---|
[18079] | 263 | }); |
---|
[1698] | 264 | |
---|
[18079] | 265 | // invoke buttons |
---|
| 266 | $("#invokeMethod").click(function() { |
---|
| 267 | invokeMethod($("#methodName").html(), false); |
---|
| 268 | return false; |
---|
| 269 | }); |
---|
| 270 | $("#invokeMethodBlank").click(function() { |
---|
| 271 | invokeMethod($("#methodName").html(), true); |
---|
| 272 | return false; |
---|
| 273 | }); |
---|
[1698] | 274 | |
---|
[18079] | 275 | // resizable iframe |
---|
| 276 | $("#increaseIframe").click(function() { |
---|
| 277 | $("#iframeWrapper").css('height', $("#iframeWrapper").height()+100); |
---|
| 278 | adaptHeight(); |
---|
| 279 | }); |
---|
| 280 | $("#decreaseIframe").click(function() { |
---|
| 281 | if ($("#iframeWrapper").height() > 200) { |
---|
| 282 | $("#iframeWrapper").css('height', $("#iframeWrapper").height()-100); |
---|
| 283 | adaptHeight(); |
---|
| 284 | } |
---|
| 285 | }); |
---|
| 286 | |
---|
| 287 | // mask all wrappers |
---|
| 288 | function resetDisplay() { |
---|
| 289 | $("#errorWrapper").hide(); |
---|
| 290 | $("#methodWrapper").hide(); |
---|
| 291 | $("#methodName").hide(); |
---|
| 292 | $("#urlForm").hide(); |
---|
[25394] | 293 | $("#methodDescription blockquote").empty(); |
---|
[18079] | 294 | $("#methodDescription").hide(); |
---|
| 295 | $("#invokeFrame").attr('src',''); |
---|
[1698] | 296 | } |
---|
| 297 | |
---|
[18079] | 298 | // give the same size to methods list and main page |
---|
| 299 | function adaptHeight() |
---|
| 300 | { |
---|
| 301 | $("#the_page").css('height', 'auto'); |
---|
| 302 | $("#the_methods").css('height', 'auto'); |
---|
[25730] | 303 | |
---|
[18079] | 304 | min_h = $(window).height()-$("#the_header").outerHeight()-$("#the_footer").outerHeight()-3; |
---|
| 305 | h = Math.max(min_h, Math.max($("#the_methods").height(), $("#the_page").height())); |
---|
[25730] | 306 | |
---|
[18079] | 307 | $("#the_page").css('height', h); |
---|
| 308 | $("#the_methods").css('height', h); |
---|
[1698] | 309 | } |
---|
| 310 | |
---|
[18079] | 311 | // display error wrapper |
---|
| 312 | function displayError(error) { |
---|
| 313 | resetDisplay(); |
---|
| 314 | $("#errorWrapper").html("<b>Error:</b> "+ error).show(); |
---|
| 315 | adaptHeight(); |
---|
[1698] | 316 | } |
---|
| 317 | |
---|
[18079] | 318 | // display ws_url form |
---|
| 319 | function askForUrl() { |
---|
[25077] | 320 | displayError("can't contact web-services, please give absolute url to 'ws.php'"); |
---|
[18079] | 321 | if ($("#urlForm input[name='ws_url']").val() == "") { |
---|
| 322 | $("#urlForm input[name='ws_url']").val(ws_url); |
---|
| 323 | } |
---|
| 324 | $("#urlForm").show(); |
---|
[1698] | 325 | } |
---|
| 326 | |
---|
[18079] | 327 | // parse Piwigo JSON |
---|
| 328 | function parsePwgJSON(json) { |
---|
| 329 | try { |
---|
| 330 | resp = jQuery.parseJSON(json); |
---|
| 331 | if (resp==null | resp.result==null | resp.stat==null | resp.stat!='ok') { |
---|
| 332 | throw new Error(); |
---|
| 333 | } |
---|
| 334 | } |
---|
| 335 | catch(e) { |
---|
| 336 | displayError("unable to parse JSON string"); |
---|
| 337 | resp = {"stat": "ko", "result": "null"}; |
---|
| 338 | } |
---|
[25730] | 339 | |
---|
[18079] | 340 | return resp.result; |
---|
[1698] | 341 | } |
---|
| 342 | |
---|
[18079] | 343 | // fetch methods list |
---|
| 344 | function getMethodList() { |
---|
| 345 | resetDisplay(); |
---|
[25730] | 346 | |
---|
[18079] | 347 | $.ajax({ |
---|
| 348 | type: "GET", |
---|
| 349 | url: ws_url, |
---|
| 350 | data: { format: "json", method: "reflection.getMethodList" } |
---|
| 351 | }).done(function(result) { |
---|
| 352 | result = parsePwgJSON(result); |
---|
[25730] | 353 | |
---|
[18079] | 354 | if (result!=null) { |
---|
| 355 | methods = result.methods; |
---|
[25730] | 356 | |
---|
[18079] | 357 | var ml = ''; |
---|
| 358 | for (var i=0; i<methods.length; i++) |
---|
| 359 | { |
---|
[25394] | 360 | ml += '<li><a href="#top">'+ methods[i]+'</a></li>'; |
---|
[18079] | 361 | } |
---|
| 362 | $("#methodsList").html(ml).show(); |
---|
[25730] | 363 | |
---|
[18079] | 364 | adaptHeight(); |
---|
[25730] | 365 | |
---|
[18079] | 366 | // trigger method selection |
---|
| 367 | $("#methodsList li a").click(function() { |
---|
| 368 | selectMethod($(this).html()); |
---|
| 369 | }); |
---|
| 370 | } |
---|
| 371 | }).error(function(jqXHR, textStatus, errorThrown) { |
---|
| 372 | askForUrl(); |
---|
| 373 | }); |
---|
[1698] | 374 | } |
---|
[1849] | 375 | |
---|
[18079] | 376 | // select method |
---|
| 377 | function selectMethod(methodName) { |
---|
| 378 | $("#introMessage").hide(); |
---|
[23322] | 379 | $("#tiptip_holder").fadeOut(200); |
---|
[25730] | 380 | |
---|
[18079] | 381 | if (cachedMethods[ methodName ]) { |
---|
| 382 | fillNewMethod(methodName); |
---|
| 383 | } |
---|
| 384 | else { |
---|
| 385 | $.ajax({ |
---|
| 386 | type: "GET", |
---|
| 387 | url: ws_url, |
---|
| 388 | data: { format: "json", method: "reflection.getMethodDetails", methodName: methodName } |
---|
[25730] | 389 | }).done(function(result) { |
---|
[18079] | 390 | result = parsePwgJSON(result); |
---|
[25730] | 391 | |
---|
[18079] | 392 | if (result!=null) { |
---|
[25730] | 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 | } |
---|
[18079] | 405 | cachedMethods[ methodName ] = result; |
---|
| 406 | fillNewMethod(methodName); |
---|
| 407 | } |
---|
| 408 | }).error(function(jqXHR, textStatus, errorThrown) { |
---|
| 409 | displayError("unknown error"); |
---|
| 410 | }); |
---|
| 411 | } |
---|
[1849] | 412 | } |
---|
| 413 | |
---|
[18079] | 414 | // display method details |
---|
| 415 | function fillNewMethod(methodName) { |
---|
| 416 | resetDisplay(); |
---|
[25730] | 417 | |
---|
[18079] | 418 | method = cachedMethods[ methodName ]; |
---|
[25730] | 419 | |
---|
[18079] | 420 | $("#methodName").html(method.name).show(); |
---|
[25730] | 421 | |
---|
[18079] | 422 | if (method.description != "") { |
---|
| 423 | $("#methodDescription blockquote").html(method.description); |
---|
| 424 | $("#methodDescription").show(); |
---|
| 425 | } |
---|
[25730] | 426 | |
---|
[25394] | 427 | $("#requestFormat").val(method.options.post_only ? 'post' : 'get'); |
---|
[25730] | 428 | |
---|
[18079] | 429 | var methodParams = ''; |
---|
| 430 | if (method.params && method.params.length>0) { |
---|
| 431 | for (var i=0; i<method.params.length; i++) { |
---|
[25077] | 432 | var param = method.params[i], |
---|
| 433 | isOptional = param.optional, |
---|
| 434 | acceptArray = param.acceptArray, |
---|
| 435 | defaultValue = param.defaultValue == null ? '' : param.defaultValue, |
---|
| 436 | info = param.info == null ? '' : '<a class="methodInfo" title="'+ param.info.replace(/"/g, '"') + '">i</a>', |
---|
| 437 | type = ''; |
---|
[25730] | 438 | |
---|
[25077] | 439 | if (param.type.match(/bool/)) type+= '<span class=type>B</span>'; |
---|
| 440 | if (param.type.match(/int/)) type+= '<span class=type>I</span>'; |
---|
| 441 | if (param.type.match(/float/)) type+= '<span class=type>F</span>'; |
---|
| 442 | if (param.type.match(/positive/)) type+= '<span class=subtype>+</span>'; |
---|
| 443 | if (param.type.match(/notnull/)) type+= '<span class=subtype>ø</span>'; |
---|
[25730] | 444 | |
---|
[18079] | 445 | // if an array is direclty printed, the delimiter is a comma where we use a pipe |
---|
| 446 | if (typeof defaultValue == 'object') { |
---|
| 447 | defaultValue = defaultValue.join('|'); |
---|
| 448 | } |
---|
[1849] | 449 | |
---|
[18079] | 450 | methodParams+= '<tr>'+ |
---|
[25077] | 451 | '<td>'+ param.name + info +'</td>'+ |
---|
[18079] | 452 | '<td class="mini">'+ (isOptional ? '?':'*') + (acceptArray ? ' []':'') +'</td>'+ |
---|
[25077] | 453 | '<td class="mini">'+ type +'</td>'+ |
---|
[18079] | 454 | '<td class="input"><input type="text" class="methodParameterValue" data-id="'+ i +'" value="'+ defaultValue +'"></td>'+ |
---|
| 455 | '<td class="mini"><input type="checkbox" class="methodParameterSend" data-id="'+ i +'" '+ (isOptional ? '':'checked="checked"') +'></td>'+ |
---|
| 456 | '</tr>'; |
---|
| 457 | } |
---|
| 458 | } |
---|
| 459 | else { |
---|
| 460 | methodParams = '<tr><td colspan="4">This method takes no parameters</td></tr>'; |
---|
| 461 | } |
---|
[25730] | 462 | |
---|
[18079] | 463 | $("#methodParams tbody").html(methodParams); |
---|
[25730] | 464 | $("#methodWrapper").show(); |
---|
| 465 | |
---|
[18079] | 466 | adaptHeight(); |
---|
[25730] | 467 | |
---|
[18079] | 468 | // trigger field modification |
---|
| 469 | $("input.methodParameterValue").change(function() { |
---|
| 470 | $("input.methodParameterSend[data-id='"+ $(this).data('id') +"']").attr('checked', 'checked'); |
---|
| 471 | }); |
---|
[25730] | 472 | |
---|
[20750] | 473 | // tiptip |
---|
| 474 | $(".methodInfo").tipTip({ |
---|
| 475 | maxWidth:"300px", |
---|
| 476 | defaultPosition:"right", |
---|
| 477 | delay:0 |
---|
| 478 | }); |
---|
[1849] | 479 | } |
---|
| 480 | |
---|
[18079] | 481 | // invoke method |
---|
| 482 | function invokeMethod(methodName, newWindow) { |
---|
| 483 | var method = cachedMethods[ methodName ]; |
---|
[1849] | 484 | |
---|
[18079] | 485 | var reqUrl = ws_url +"?format="+ $("#responseFormat").val(); |
---|
[25730] | 486 | |
---|
[18079] | 487 | // GET |
---|
| 488 | if ($("#requestFormat").val() == 'get') { |
---|
| 489 | reqUrl+= "&method="+ methodName; |
---|
[25730] | 490 | |
---|
[18079] | 491 | for (var i=0; i<method.params.length; i++) { |
---|
| 492 | if (! $("input.methodParameterSend[data-id='"+ i +"']").is(":checked")) { |
---|
| 493 | continue; |
---|
| 494 | } |
---|
[1698] | 495 | |
---|
[18079] | 496 | var paramValue = $("input.methodParameterValue[data-id='"+ i +"']").val(); |
---|
[25730] | 497 | |
---|
[18079] | 498 | var paramSplitted = paramValue.split('|'); |
---|
| 499 | if (method.params[i].acceptArray && paramSplitted.length > 1) { |
---|
| 500 | $.each(paramSplitted, function(v) { |
---|
| 501 | reqUrl+= '&'+ method.params[i].name +'[]='+ paramSplitted[v]; |
---|
| 502 | }); |
---|
| 503 | } |
---|
| 504 | else { |
---|
| 505 | reqUrl+= '&'+ method.params[i].name +'='+ paramValue; |
---|
| 506 | } |
---|
| 507 | } |
---|
[25730] | 508 | |
---|
[18079] | 509 | if (newWindow) { |
---|
| 510 | window.open(reqUrl); |
---|
| 511 | } |
---|
| 512 | else { |
---|
| 513 | $("#invokeFrame").attr('src', reqUrl); |
---|
| 514 | } |
---|
| 515 | } |
---|
| 516 | // POST |
---|
| 517 | else { |
---|
| 518 | var form = $("#invokeForm"); |
---|
| 519 | form.attr('action', reqUrl); |
---|
[25730] | 520 | |
---|
[18079] | 521 | var t = '<input type="hidden" name="method" value="'+ methodName +'">'; |
---|
[25730] | 522 | |
---|
[18079] | 523 | for (var i=0; i<method.params.length; i++) { |
---|
| 524 | if (! $("input.methodParameterSend[data-id='"+ i +"']").is(":checked")) { |
---|
| 525 | continue; |
---|
| 526 | } |
---|
[1698] | 527 | |
---|
[18079] | 528 | var paramValue = $("input.methodParameterValue[data-id='"+ i +"']").val(); |
---|
[1698] | 529 | |
---|
[18079] | 530 | var paramSplitted = paramValue.split('|'); |
---|
| 531 | if (method.params[i].acceptArray && paramSplitted.length > 1) { |
---|
| 532 | $.each(paramSplitted, function(v) { |
---|
| 533 | t+= '<input type="hidden" name="'+ method.params[i].name +'[]" value="'+ paramSplitted[v] +'">'; |
---|
| 534 | }); |
---|
| 535 | } |
---|
| 536 | else { |
---|
| 537 | t+= '<input type="hidden" name="'+ method.params[i].name +'" value="'+ paramValue +'">'; |
---|
| 538 | } |
---|
| 539 | } |
---|
[25730] | 540 | |
---|
[18079] | 541 | form.html(t); |
---|
| 542 | form.attr('target', newWindow ? "_blank" : "invokeFrame"); |
---|
| 543 | form.submit(); |
---|
| 544 | } |
---|
[25730] | 545 | |
---|
[18079] | 546 | return false; |
---|
| 547 | } |
---|
[1698] | 548 | </script> |
---|
| 549 | |
---|
| 550 | </body> |
---|
[25394] | 551 | </html> |
---|