diff options
author | José Bollo <jose.bollo@iot.bzh> | 2018-10-12 18:51:31 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2018-10-12 18:53:08 +0200 |
commit | db0e6847875ee891a5d7506d267e733b91ce8e46 (patch) | |
tree | 50e331bd7ae2d817a61737d9d3d5d235caadf0b9 /test/AFB.html | |
parent | 6c9e2318d3b0905e4d5cf9223dcc879b418295f1 (diff) |
AFB.html: Allow to call any verb of any API
Change-Id: I3bfff2632d5854d5885740e55f0ec38fe3214424
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'test/AFB.html')
-rw-r--r-- | test/AFB.html | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/test/AFB.html b/test/AFB.html index b0832d9a..ef2dc586 100644 --- a/test/AFB.html +++ b/test/AFB.html @@ -27,10 +27,16 @@ function gotevent(obj) { document.getElementById("outevt").innerHTML = JSON.stringify(obj); } - function send(message) { + function sendform() { var api = document.getElementById("api").value; var verb = document.getElementById("verb").value; - ws.call(api+"/"+verb, {data:message}).then(replyok, replyerr); + var message = document.getElementById("message").value; + try { + var data = JSON.parse(message); + ws.call(api+"/"+verb, data).then(replyok, replyerr); + } catch(e) { + document.getElementById("output").innerHTML = "INVALID JSON ("+e+"): "+message; + } } </script> @@ -38,10 +44,14 @@ <h1>WebSocket Echo</h1> <div id="connected">Not Connected</div> <div id="main" style="visibility:hidden"> - API: <input type="text" id="api" value="hello" size="80"/><br/> - VERB: <input type="text" id="verb" value="ping" size="80"/><br/> - Enter Message: <input type="text" name="message" value="" size="80" onchange="send(this.value)"/><br/> - Server says... <div id="output"></div> - Events: <div id="outevt"></div> + <a href="monitoring/monitor.html" target="_blank">Monitoring</a><br/> + <form> + API: <input type="text" id="api" value="hello" size="80"/><br/> + VERB: <input type="text" id="verb" value="ping" size="80"/><br/> + DATA: <input type="text" id="message" value="" size="80" /><br/> + <input type="button" value="send" onclick="sendform()"/><br/> + Server says... <div id="output"></div> + Events: <div id="outevt"></div> + </form> </div> |