-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.html
More file actions
31 lines (26 loc) · 976 Bytes
/
client.html
File metadata and controls
31 lines (26 loc) · 976 Bytes
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
<html>
<head>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
jQuery(function ($) {
var ws = new WebSocket("ws://localhost:9000/api/ws");
var campaignId;
$.getJSON("http://localhost:9000/api/random")
.success(function (data) {
$("body").append("<a id='roulette' href='#'><img src='http://localhost:9000/assets/images/icons/" + data.id + ".jpg'/></a>");
campaignId = data.id;
ws.send(JSON.stringify({id: campaignId+"", incr: "views"}));
});
$("body").on('click', '#roulette', function () {
$.ajax({
type: "POST",
url: "http://localhost:9000/api/increment/clicks" + campaignId
});
ws.send(JSON.stringify({id: campaignId+"", incr: "clicks"}));
});
});
</script>
</body>
</html>