-
Notifications
You must be signed in to change notification settings - Fork 0
/
e2.html
63 lines (52 loc) · 2.35 KB
/
e2.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
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>e2</title>
<!-- <link href="jquery-ui-1.10.4.custom/css/smoothness/jquery-ui-1.10.4.custom.css" rel="stylesheet"> ignore jquery ui styles, eventually we will use bootstrap styles -->
<script src="bootstrap/js/jquery.min.js"></script> <!-- version of jquery for bootstrap -->
<script src="jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.js"></script> <!-- enough of jquery ui for dragging, no more -->
<script src="jquery.ui.touch-punch/jquery.ui.touch-punch.min.js"></script> <!-- http://touchpunch.furf.com/ -->
<style>
.draggable { position: fixed; }
</style>
<script src="config.js" ></script>
<script>
var socket;
function send() {
socket.send(JSON.stringify(world));
}
var world = {};
function logDrag(event, ui){
world[event.target.id] = ui.position;
//$.each(world,function(index,value){
//console.log(JSON.stringify(ui.position) + " " + event.target.id);
//});
//console.log(JSON.stringify(world));
send();
}
$(function() {
socket = new WebSocket("ws://localhost:"+port);
$("#world img").draggable();
$("#world img").on("dragstart", function(event, ui) { logDrag(event, ui); });
$("#world img").on("dragstop" , function(event, ui) { logDrag(event, ui); });
$("#world img").on("drag" , function(event, ui) { logDrag(event, ui); });
});
</script>
</head>
<body>
<div id="world">
<img id="x1" src="images/x.gif" style="z-index:2;" class="draggable" />
<img id="x2" src="images/x.gif" style="z-index:2;" class="draggable" />
<img id="x3" src="images/x.gif" style="z-index:2;" class="draggable" />
<img id="x4" src="images/x.gif" style="z-index:2;" class="draggable" />
<img id="x5" src="images/x.gif" style="z-index:2;" class="draggable" />
<img id="o1" src="images/o.gif" style="z-index:2;" class="draggable" />
<img id="o2" src="images/o.gif" style="z-index:2;" class="draggable" />
<img id="o3" src="images/o.gif" style="z-index:2;" class="draggable" />
<img id="o4" src="images/o.gif" style="z-index:2;" class="draggable" />
<img id="o5" src="images/o.gif" style="z-index:2;" /class="draggable" >
<img id="tttboard" src="images/tictactoe.gif" style="z-index:1;" class="draggable" />
</div>
</body>
</html>