p≡p JSON adapter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
4.7 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="icon" href="/favicon.ico" type="image/vnd.microsoft.icon">
<title>Send example calls via jQuery</title>
<style type="text/css">
body { font-family:Helvetica,Arial,Sans-serif;background-color:#cde; }
table { border-collapse:collapse; }
.bigtable { border-collapse:collapse; border:2px black solid; box-shadow:4px 4px 8px #666; background-color:#ffd; margin:1em;}
td, th { border:1px black solid; vertical-align:top; padding:0.5em;}
td.right { border:0px black solid; float:right; }
td.left { border:0px black solid; align:left; }
tr.t { border-bottom:1px black solid; }
.t td,th { border:0px black solid; }
input { white-space:pre }
.smalltable { border-collapse:collapse; border:2px black inset; margin-left:1em; padding:5px;}
.smalltable td { border:none; vertical-align:top; padding:5px;}
pre.green {white-space:pre; background-color:#9d9; }
pre.red {white-space:pre; background-color:#d99; }
<script type="text/javascript" src="jquery.js"></script>
<!-- positron 2022-09-07: I hardwired this path, which is "wrong" but at least
works with the default settings. I had never been able to see this HTML
interface working!
<script type="text/javascript" src=""></script>
<script type="text/javascript" src="interactive.js"></script>
<script type="text/javascript" src="unittests.js"></script>
<script type="text/javascript" src="test-encode-decode.js"></script>
<h1>p≡p JSON Server Adapter – <span id="spn_version">(no JavaScript?)</span></h1>
<h2>1. Send example calls via jQuery</h2>
<form id="frm" name="frm">
<table class="bigtable" id="bigtable">
<tr><td>Server's Address</td><td> <input type="text" id="server" size="50" maxlength="200" value="" </td></tr>
<tr><td>Security token:</td>
<input type="text" id="security_token" size="50" maxlength="80" placeholder="see /tmp/pEp-json-token-*">
<tr><td>Function name:</td><td>
<select name="fn_name" id="fn_name" size="1" onChange="on_select_change()">
<tr><td>Parameters:</td><td id="td_param"></td></tr>
<tr><td colspan="2"> <input type="button" value="Call function!" onClick="button_click()" id="call_btn"> </td></tr>
<tr><td>Debug...</td><td id="deb"><pre id="debug">...</pre></td></tr>
<tr><td>Result:</td><td id="result"><pre id="resultpre">Banana!</pre></td></tr>
<form id="frm_2" name="frm_2">
<textarea placeholder="Just a scratchboard for text copy & paste :-)" rows="12" cols="80">
<h2>2. Open WebSocket connection</h2>
<input type="button" onClick="openWebSocket()" id="openWsBtn" value="Open WebSocket!">
<h2>3. Execute JavaScript tests</h2>
<p id='unittest_div'>(you have to activate JavaScript in your browser to see something useful here)</p>
<p>Unittest output: <textarea id='unittest_out'></textarea></p>
<h2>4. Generate documentation</h2>
<form id="frm_doc" name="frm_doc">
Select output format:
<select id="doc_format" size="1">
<option value="html" checked>HTML Table</option>
<option value="md" >Markdown Table</option>
<option value="trac" >Trac Table</option>
<button type="button" name="btn_doc" onclick="create_doc()">Create!</button></dd>
<h2>Ugly kludge</h2>
Notice that <code>pEp_functions.js</code> is loaded from the same server
providing the JSON API, and is not a file. I hardwired the URI to its default
value in the <code>&lt;script&gt;</code> element above:
In case you want to change, search for <code>KLUDGE</code> in this
(But now this nice interface at least is usable.)
To circumvent errors such as
<pre>Access to XMLHttpRequest at '' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.</pre>
I run a separate instance of my web browser, like this:
[luca@moore ~]$ chromium --no-remote --disable-web-security --user-data-dir=$HOME/.config/chromium/Default ~/pep-src/pEpJSONServerAdapter/html/index.html</pre>
--positron, 2022-09
<div id="doc_out" style="background-color:white;border:1px black solid; padding:10px;"></div>
<script type="text/javascript">