-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcntlr.tpl
119 lines (110 loc) · 2.98 KB
/
cntlr.tpl
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<head>
<title> CntlR </title>
<script type='text/javascript' src='/static/j.js'></script>
<link rel="stylesheet" type="text/css" href="/static/foundation.css">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<div class='row'>
<div class='small-12 columns'>
<h1>CntlR</h1>
</div>
<div class='small-12 columns text-center'>
<button class='button info' id='up'>UP ⇧</button>
</div>
<div class='small-6 columns text-center'>
<button class='button info' id='left'>LEFT ⇦</button>
</div>
<div class='small-6 columns text-center'>
<button class='button info' id='right'>RIGHT ⇨</button>
</div>
<div class='small-12 columns text-center'>
<button class='button info' id='down'>DOWN ⇩</button>
</div>
<div class='small-12 columns text-center'>
<button class='button alert' id='stop'>Stop</button>
<div>
</div>
</body>
<script>
var up = 0;
var left = 0;
var right = 0;
var down = 0;
$('#stop').click(function(){
$.ajax({
type: "GET",
url : "/stop"
});
up = 0;
left = 0;
right = 0;
down = 0;
});
$('#up').click(function(){
if(up == 0){
$.ajax({
type: "GET",
url : "/up/on"
});
up = 1;
}
else{
$.ajax({
type: "GET",
url : "/up/off"
});
up = 0;
}
});
$('#left').click(function(){
if(left == 0){
$.ajax({
type: "GET",
url : "/left/on"
});
left = 1;
}
else{
$.ajax({
type: "GET",
url : "/left/off"
});
left = 0;
}
});
$('#right').click(function(){
if(right == 0){
$.ajax({
type: "GET",
url : "/right/on"
});
right = 1;
}
else{
$.ajax({
type: "GET",
url : "/right/off"
});
right = 0;
}
});
$('#down').click(function(){
if(down == 0){
$.ajax({
type: "GET",
url : "/down/on"
});
down = 1;
}
else{
$.ajax({
type: "GET",
url : "/down/off"
});
down = 0;
}
});
</script>