Changeset 25730 for trunk/tools/ws.htm


Ignore:
Timestamp:
Nov 26, 2013, 10:51:53 PM (10 years ago)
Author:
rvelices
Message:

fix adding many times post only / admin only ...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/ws.htm

    r25394 r25730  
    44  <meta charset="utf-8">
    55  <title>Piwigo web API (web-services) explorer</title>
    6  
     6
    77  <link rel="stylesheet" href="http://cdn.jsdelivr.net/tiptip/1.3/tipTip.css">
    8  
     8
    99  <style>
    1010  /* BEGIN CSS RESET
     
    1313  html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code,
    1414  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,
    1616  figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video
    1717  {margin:0;padding:0;border:0;font-size:100%;vertical-align:baseline;}
     
    2828  a {color:#247EBF;text-decoration:none;}
    2929  a:hover {color:#EB9C39;border-bottom-width:1px;border-style:dotted;text-shadow:1px 1px 0 #ddd;}
    30  
     30
    3131  blockquote {border:1px solid #cdcdcd;background:#F9F9F9;padding:8px;}
    3232  hr {margin:10px 30px;color:#fff;}
     
    7878  #testForm tr:last-child td {padding:8px 0 5px 0;}
    7979  #testForm blockquote {width:200px;}
    80  
     80
    8181  #introMessage {font-size:1.1em;}
    8282  #urlForm {margin-bottom:10px;}
     
    8787  }
    8888  a.button:hover {color:#E5FF00;}
    89  
     89
    9090  .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;}
    9191  .methodInfo:hover {border:none;text-shadow:none;background:#888;cursor:pointer;color:#fff;}
    9292  #tiptip_content { font-size:12px; }
    93  
     93
    9494  #iframeWrapper {width:100%;height:300px;padding:3px 3px 20px 3px;background:#F9F9F9;border:1px solid #cdcdcd;overflow:hidden;position:relative;}
    9595  iframe {width:100%;height:100%;background:#fff;}
    96  
     96
    9797  div.onlys {background:#faa;color:#fff;border:1px solid #f22;padding:.25em .5em;display:table;border-radius:4px;margin-bottom:0.5em;}
    9898  </style>
    99  
     99
    100100</head>
    101101
     
    109109<div id="the_methods">
    110110  <h2>Available methods</h2>
    111  
     111
    112112  <ul id="methodsList">
    113113  </ul>
     
    117117  <h2 id="methodName" style="display:none;"></h2>
    118118  <h2 id="errorWrapper" style="display:none;"></h2>
    119  
     119
    120120  <div id="the_content">
    121121    <form id="urlForm" style="display:none;">
     
    123123      <input type="submit" value="Go!">
    124124    </form>
    125    
     125
    126126    <blockquote id="introMessage">
    127127      <p>
     
    154154        <br>
    155155      </div> <!-- methodDescription -->
    156      
     156
    157157      <div id="testForm">
    158158        <h3>Test</h3>
     
    188188        </blockquote>
    189189      </div> <!-- testForm -->
    190      
     190
    191191      <div id="methodParams">
    192192        <h3>Method parameters</h3>
     
    201201            </tr>
    202202          </thead>
    203          
     203
    204204          <tbody>
    205205          </tbody>
    206          
     206
    207207          <tfoot>
    208208            <tr>
     
    215215        </table>
    216216      </div> <!-- methodParams -->
    217      
     217
    218218      <br><br>
    219      
     219
    220220      <h3>Result</h3>
    221221      <div id="iframeWrapper">
     
    226226      </div>
    227227    </form> <!-- iframeWrapper -->
    228    
     228
    229229    <!-- hidden form for POST submition -->
    230230    <form method="post" action="" target="" id="invokeForm" style="display:none;"></form>
    231    
     231
    232232  </div> <!-- the_content -->
    233233
     
    241241<script src="https://cdn.jsdelivr.net/tiptip/1.3/jquery.tipTip.minified.js"></script>
    242242
    243 <script> 
     243<script>
    244244// global vars
    245245var cachedMethods = new Array;
     
    301301  $("#the_page").css('height', 'auto');
    302302  $("#the_methods").css('height', 'auto');
    303  
     303
    304304  min_h = $(window).height()-$("#the_header").outerHeight()-$("#the_footer").outerHeight()-3;
    305305  h = Math.max(min_h, Math.max($("#the_methods").height(), $("#the_page").height()));
    306  
     306
    307307  $("#the_page").css('height', h);
    308308  $("#the_methods").css('height', h);
     
    337337    resp = {"stat": "ko", "result": "null"};
    338338  }
    339  
     339
    340340  return resp.result;
    341341}
     
    344344function getMethodList() {
    345345  resetDisplay();
    346  
     346
    347347  $.ajax({
    348348    type: "GET",
     
    351351  }).done(function(result) {
    352352    result = parsePwgJSON(result);
    353    
     353
    354354    if (result!=null) {
    355355      methods = result.methods;
    356      
     356
    357357      var ml = '';
    358358      for (var i=0; i<methods.length; i++)
     
    361361      }
    362362      $("#methodsList").html(ml).show();
    363      
     363
    364364      adaptHeight();
    365      
     365
    366366      // trigger method selection
    367367      $("#methodsList li a").click(function() {
     
    378378  $("#introMessage").hide();
    379379  $("#tiptip_holder").fadeOut(200);
    380  
     380
    381381  if (cachedMethods[ methodName ]) {
    382382    fillNewMethod(methodName);
     
    387387      url: ws_url,
    388388      data: { format: "json", method: "reflection.getMethodDetails", methodName: methodName }
    389     }).done(function(result) { 
     389    }).done(function(result) {
    390390      result = parsePwgJSON(result);
    391    
     391
    392392      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                                }
    393405        cachedMethods[ methodName ] = result;
    394406        fillNewMethod(methodName);
     
    403415function fillNewMethod(methodName) {
    404416  resetDisplay();
    405  
     417
    406418  method = cachedMethods[ methodName ];
    407  
     419
    408420  $("#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
    423422  if (method.description != "") {
    424423    $("#methodDescription blockquote").html(method.description);
    425424    $("#methodDescription").show();
    426425  }
    427  
     426
    428427  $("#requestFormat").val(method.options.post_only ? 'post' : 'get');
    429  
     428
    430429  var methodParams = '';
    431430  if (method.params && method.params.length>0) {
     
    437436          info = param.info == null ? '' : '<a class="methodInfo" title="'+ param.info.replace(/"/g, '&quot;') + '">i</a>',
    438437          type = '';
    439      
     438
    440439      if (param.type.match(/bool/)) type+= '<span class=type>B</span>';
    441440      if (param.type.match(/int/)) type+= '<span class=type>I</span>';
     
    443442      if (param.type.match(/positive/)) type+= '<span class=subtype>+</span>';
    444443      if (param.type.match(/notnull/)) type+= '<span class=subtype>&oslash;</span>';
    445      
     444
    446445      // if an array is direclty printed, the delimiter is a comma where we use a pipe
    447446      if (typeof defaultValue == 'object') {
     
    461460    methodParams = '<tr><td colspan="4">This method takes no parameters</td></tr>';
    462461  }
    463  
     462
    464463  $("#methodParams tbody").html(methodParams);
    465   $("#methodWrapper").show(); 
    466  
     464  $("#methodWrapper").show();
     465
    467466  adaptHeight();
    468  
     467
    469468  // trigger field modification
    470469  $("input.methodParameterValue").change(function() {
    471470    $("input.methodParameterSend[data-id='"+ $(this).data('id') +"']").attr('checked', 'checked');
    472471  });
    473  
     472
    474473  // tiptip
    475474  $(".methodInfo").tipTip({
     
    485484
    486485  var reqUrl = ws_url +"?format="+ $("#responseFormat").val();
    487  
     486
    488487  // GET
    489488  if ($("#requestFormat").val() == 'get') {
    490489    reqUrl+= "&method="+ methodName;
    491    
     490
    492491    for (var i=0; i<method.params.length; i++) {
    493492      if (! $("input.methodParameterSend[data-id='"+ i +"']").is(":checked")) {
     
    496495
    497496      var paramValue = $("input.methodParameterValue[data-id='"+ i +"']").val();
    498      
     497
    499498      var paramSplitted = paramValue.split('|');
    500499      if (method.params[i].acceptArray &&  paramSplitted.length > 1) {
     
    507506      }
    508507    }
    509    
     508
    510509    if (newWindow) {
    511510      window.open(reqUrl);
     
    519518    var form = $("#invokeForm");
    520519    form.attr('action', reqUrl);
    521    
     520
    522521    var t = '<input type="hidden" name="method" value="'+ methodName +'">';
    523    
     522
    524523    for (var i=0; i<method.params.length; i++) {
    525524      if (! $("input.methodParameterSend[data-id='"+ i +"']").is(":checked")) {
     
    539538      }
    540539    }
    541    
     540
    542541    form.html(t);
    543542    form.attr('target', newWindow ? "_blank" : "invokeFrame");
    544543    form.submit();
    545544  }
    546  
     545
    547546  return false;
    548547}
Note: See TracChangeset for help on using the changeset viewer.