aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2013-11-26 21:51:53 +0000
committerrvelices <rv-github@modusoptimus.com>2013-11-26 21:51:53 +0000
commitfd38fa8fb531008a5914f63ba8881e7a5ff42330 (patch)
treece89b62e626ecc6ce1ca5eef3bf814cac976a303
parent45afbb48fb9b18ccc8d4ca792cc64a23ec3bb6db (diff)
fix adding many times post only / admin only ...
git-svn-id: http://piwigo.org/svn/trunk@25730 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--tools/ws.htm129
1 files changed, 64 insertions, 65 deletions
diff --git a/tools/ws.htm b/tools/ws.htm
index 567bee5d5..1c55b59cb 100644
--- a/tools/ws.htm
+++ b/tools/ws.htm
@@ -3,16 +3,16 @@
<head>
<meta charset="utf-8">
<title>Piwigo web API (web-services) explorer</title>
-
+
<link rel="stylesheet" href="http://cdn.jsdelivr.net/tiptip/1.3/tipTip.css">
-
+
<style>
/* BEGIN CSS RESET
http://meyerweb.com/eric/tools/css/reset
v2.0 | 20110126 | License: none (public domain) */
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code,
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,
- fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed,
+ fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video
{margin:0;padding:0;border:0;font-size:100%;vertical-align:baseline;}
@@ -27,7 +27,7 @@
a {color:#247EBF;text-decoration:none;}
a:hover {color:#EB9C39;border-bottom-width:1px;border-style:dotted;text-shadow:1px 1px 0 #ddd;}
-
+
blockquote {border:1px solid #cdcdcd;background:#F9F9F9;padding:8px;}
hr {margin:10px 30px;color:#fff;}
ul {margin-left:25px;}
@@ -77,7 +77,7 @@
#testForm td {padding:2px 0;}
#testForm tr:last-child td {padding:8px 0 5px 0;}
#testForm blockquote {width:200px;}
-
+
#introMessage {font-size:1.1em;}
#urlForm {margin-bottom:10px;}
@@ -86,17 +86,17 @@
background:#84bb3c;background:linear-gradient(to bottom, #84bb3c 0%, #3f5a1d 100%);
}
a.button:hover {color:#E5FF00;}
-
+
.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;}
.methodInfo:hover {border:none;text-shadow:none;background:#888;cursor:pointer;color:#fff;}
#tiptip_content { font-size:12px; }
-
+
#iframeWrapper {width:100%;height:300px;padding:3px 3px 20px 3px;background:#F9F9F9;border:1px solid #cdcdcd;overflow:hidden;position:relative;}
iframe {width:100%;height:100%;background:#fff;}
-
+
div.onlys {background:#faa;color:#fff;border:1px solid #f22;padding:.25em .5em;display:table;border-radius:4px;margin-bottom:0.5em;}
</style>
-
+
</head>
<body>
@@ -108,7 +108,7 @@
<div id="the_methods">
<h2>Available methods</h2>
-
+
<ul id="methodsList">
</ul>
</div> <!-- the_methods -->
@@ -116,13 +116,13 @@
<div id="the_page">
<h2 id="methodName" style="display:none;"></h2>
<h2 id="errorWrapper" style="display:none;"></h2>
-
+
<div id="the_content">
<form id="urlForm" style="display:none;">
<input type="text" name="ws_url" size="60">
<input type="submit" value="Go!">
</form>
-
+
<blockquote id="introMessage">
<p>
<b>API = Application Programming Interface.</b><br>
@@ -153,7 +153,7 @@
</blockquote>
<br>
</div> <!-- methodDescription -->
-
+
<div id="testForm">
<h3>Test</h3>
<blockquote>
@@ -187,7 +187,7 @@
</table>
</blockquote>
</div> <!-- testForm -->
-
+
<div id="methodParams">
<h3>Method parameters</h3>
<table>
@@ -200,10 +200,10 @@
<td class="mini">Send</td>
</tr>
</thead>
-
+
<tbody>
</tbody>
-
+
<tfoot>
<tr>
<td colspan="5">
@@ -214,9 +214,9 @@
</tfoot>
</table>
</div> <!-- methodParams -->
-
+
<br><br>
-
+
<h3>Result</h3>
<div id="iframeWrapper">
<iframe src="" id="invokeFrame" name="invokeFrame"></iframe>
@@ -225,10 +225,10 @@
<a name="iframe-bottom"></a>
</div>
</form> <!-- iframeWrapper -->
-
+
<!-- hidden form for POST submition -->
<form method="post" action="" target="" id="invokeForm" style="display:none;"></form>
-
+
</div> <!-- the_content -->
</div> <!-- the_page -->
@@ -240,7 +240,7 @@
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/tiptip/1.3/jquery.tipTip.minified.js"></script>
-<script>
+<script>
// global vars
var cachedMethods = new Array;
var ws_url = "http://";
@@ -300,10 +300,10 @@ function adaptHeight()
{
$("#the_page").css('height', 'auto');
$("#the_methods").css('height', 'auto');
-
+
min_h = $(window).height()-$("#the_header").outerHeight()-$("#the_footer").outerHeight()-3;
h = Math.max(min_h, Math.max($("#the_methods").height(), $("#the_page").height()));
-
+
$("#the_page").css('height', h);
$("#the_methods").css('height', h);
}
@@ -336,33 +336,33 @@ function parsePwgJSON(json) {
displayError("unable to parse JSON string");
resp = {"stat": "ko", "result": "null"};
}
-
+
return resp.result;
}
// fetch methods list
function getMethodList() {
resetDisplay();
-
+
$.ajax({
type: "GET",
url: ws_url,
data: { format: "json", method: "reflection.getMethodList" }
}).done(function(result) {
result = parsePwgJSON(result);
-
+
if (result!=null) {
methods = result.methods;
-
+
var ml = '';
for (var i=0; i<methods.length; i++)
{
ml += '<li><a href="#top">'+ methods[i]+'</a></li>';
}
$("#methodsList").html(ml).show();
-
+
adaptHeight();
-
+
// trigger method selection
$("#methodsList li a").click(function() {
selectMethod($(this).html());
@@ -377,7 +377,7 @@ function getMethodList() {
function selectMethod(methodName) {
$("#introMessage").hide();
$("#tiptip_holder").fadeOut(200);
-
+
if (cachedMethods[ methodName ]) {
fillNewMethod(methodName);
}
@@ -386,10 +386,22 @@ function selectMethod(methodName) {
type: "GET",
url: ws_url,
data: { format: "json", method: "reflection.getMethodDetails", methodName: methodName }
- }).done(function(result) {
+ }).done(function(result) {
result = parsePwgJSON(result);
-
+
if (result!=null) {
+ if (result.options.post_only || result.options.admin_only) {
+ var onlys = '<div class="onlys">';
+ if (result.options.post_only) {
+ onlys+= 'POST only. ';
+ }
+ if (result.options.admin_only) {
+ onlys+= 'Admin only. ';
+ }
+ onlys+= '</div>';
+
+ result.description = onlys + result.description;
+ }
cachedMethods[ methodName ] = result;
fillNewMethod(methodName);
}
@@ -402,31 +414,18 @@ function selectMethod(methodName) {
// display method details
function fillNewMethod(methodName) {
resetDisplay();
-
+
method = cachedMethods[ methodName ];
-
+
$("#methodName").html(method.name).show();
-
- if (method.options.post_only || method.options.admin_only) {
- var onlys = '<div class="onlys">';
- if (method.options.post_only) {
- onlys+= 'POST only. ';
- }
- if (method.options.admin_only) {
- onlys+= 'Admin only. ';
- }
- onlys+= '</div>';
-
- method.description = onlys + method.description;
- }
-
+
if (method.description != "") {
$("#methodDescription blockquote").html(method.description);
$("#methodDescription").show();
}
-
+
$("#requestFormat").val(method.options.post_only ? 'post' : 'get');
-
+
var methodParams = '';
if (method.params && method.params.length>0) {
for (var i=0; i<method.params.length; i++) {
@@ -436,13 +435,13 @@ function fillNewMethod(methodName) {
defaultValue = param.defaultValue == null ? '' : param.defaultValue,
info = param.info == null ? '' : '<a class="methodInfo" title="'+ param.info.replace(/"/g, '&quot;') + '">i</a>',
type = '';
-
+
if (param.type.match(/bool/)) type+= '<span class=type>B</span>';
if (param.type.match(/int/)) type+= '<span class=type>I</span>';
if (param.type.match(/float/)) type+= '<span class=type>F</span>';
if (param.type.match(/positive/)) type+= '<span class=subtype>+</span>';
if (param.type.match(/notnull/)) type+= '<span class=subtype>&oslash;</span>';
-
+
// if an array is direclty printed, the delimiter is a comma where we use a pipe
if (typeof defaultValue == 'object') {
defaultValue = defaultValue.join('|');
@@ -460,17 +459,17 @@ function fillNewMethod(methodName) {
else {
methodParams = '<tr><td colspan="4">This method takes no parameters</td></tr>';
}
-
+
$("#methodParams tbody").html(methodParams);
- $("#methodWrapper").show();
-
+ $("#methodWrapper").show();
+
adaptHeight();
-
+
// trigger field modification
$("input.methodParameterValue").change(function() {
$("input.methodParameterSend[data-id='"+ $(this).data('id') +"']").attr('checked', 'checked');
});
-
+
// tiptip
$(".methodInfo").tipTip({
maxWidth:"300px",
@@ -484,18 +483,18 @@ function invokeMethod(methodName, newWindow) {
var method = cachedMethods[ methodName ];
var reqUrl = ws_url +"?format="+ $("#responseFormat").val();
-
+
// GET
if ($("#requestFormat").val() == 'get') {
reqUrl+= "&method="+ methodName;
-
+
for (var i=0; i<method.params.length; i++) {
if (! $("input.methodParameterSend[data-id='"+ i +"']").is(":checked")) {
continue;
}
var paramValue = $("input.methodParameterValue[data-id='"+ i +"']").val();
-
+
var paramSplitted = paramValue.split('|');
if (method.params[i].acceptArray && paramSplitted.length > 1) {
$.each(paramSplitted, function(v) {
@@ -506,7 +505,7 @@ function invokeMethod(methodName, newWindow) {
reqUrl+= '&'+ method.params[i].name +'='+ paramValue;
}
}
-
+
if (newWindow) {
window.open(reqUrl);
}
@@ -518,9 +517,9 @@ function invokeMethod(methodName, newWindow) {
else {
var form = $("#invokeForm");
form.attr('action', reqUrl);
-
+
var t = '<input type="hidden" name="method" value="'+ methodName +'">';
-
+
for (var i=0; i<method.params.length; i++) {
if (! $("input.methodParameterSend[data-id='"+ i +"']").is(":checked")) {
continue;
@@ -538,12 +537,12 @@ function invokeMethod(methodName, newWindow) {
t+= '<input type="hidden" name="'+ method.params[i].name +'" value="'+ paramValue +'">';
}
}
-
+
form.html(t);
form.attr('target', newWindow ? "_blank" : "invokeFrame");
form.submit();
}
-
+
return false;
}
</script>