This repository has been archived by the owner on Dec 12, 2017. It is now read-only.
/
echo-endpoint.html
53 lines (53 loc) · 1.63 KB
/
echo-endpoint.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE HTML>
<html>
<head>
<title>Echo Endpoint</title>
<meta charset="UTF-8">
<style type="text/css">
.hidden { display: none; }
div { border: 1px solid silver; }
</style>
<script src="js/jquery-3.1.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var doSayDirectives = function(d){
d.directives.forEach(function(dir){
if (dir.name === "say") {
$("#say").append(dir.options.something).append($("<br>"));
$(".hidden").removeClass("hidden");
}
});
};
$("#hello-world").click(function(){
var eci = $("#eci").val();
var url = "sky/event/"+eci+"/hello-name/echo/hello";
$.getJSON(url,doSayDirectives);
});
$("#echo-message").click(function(ev){
ev.preventDefault();
var eci = $("#eci").val();
var m = $("#input").val();
var url = "sky/event/"+eci+"/echo-message/echo/message?input="+m;
$.getJSON(url,doSayDirectives);
});
$("#clear").click(function(){
$("#say").text("");
$(".output").addClass("hidden");
});
});
</script>
</head>
<body>
<input id="eci" placeholder="eci" size="25">
<br>
<button id="hello-world">Hello World</button>
<br>
<form>
<input id="input" name="input" placeholder="message" size="40">
<button id="echo-message">Echo Message</button>
</form>
<p id="heading" class="hidden output">Response(s)</p>
<div id="say" class="hidden output"></div>
<button id="clear" class="hidden output">Clear</button>
</body>
</html>