forked from blamonet/rokuremote.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
roku_remote.html
202 lines (175 loc) · 7.8 KB
/
roku_remote.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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<html>
<head>
<title>
Roku JavaScript Remote
</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript">
roku_ip_address = '10.0.1.15';
roku_port = '8060';
function roku_keyboard() {
// http://:8060/keypress/Lit_r // sending an r
}
function roku_app_launch(id) {
var api_url = 'http://' + roku_ip_address + ":" + roku_port + "/launch/" + id;
$.post(api_url);
$('#myModal').modal('hide')
}
function roku_command(cmd) {
var api_url = 'http://' + roku_ip_address + ":" + roku_port + '/keypress/' + cmd;
$.support.cors = true;
$.post(api_url);
}
$(document).keydown(function(e) {
switch(e.which) {
case 37:
roku_command('Left');
break;
case 38:
roku_command('Up');
break;
case 39:
roku_command('Right');
break;
case 40:
roku_command('Down');
break;
case 13:
roku_command('Select');
break;
case 66:
roku_command('Back');
break;
case 32:
roku_command('Play');
break;
case 72:
roku_command('Home');
break;
default: return;
}
e.preventDefault();
});
$(document).ready(function () {
var api_url = 'http://' + roku_ip_address + ":" + roku_port + "/query/apps";
$.ajax({
type: "GET",
url: api_url,
dataType: "xml",
success: appParser
});
});
function appParser(data) {
$(data).find("app").each(function () {
app_img = 'http://'+roku_ip_address+':8060/query/icon/'+$(this).attr('id');
$("#roku-apps").append('<a class="app" href="javascript:roku_app_launch(' + $(this).attr('id') + ')"><img src="' + app_img + '" /></a>');
});
}
</script>
<style type="text/css">
.remote {
width: 200px;
margin: 20px auto;
border: 1px solid #333;
background-color: black;
padding: 20px 20px 20px 15px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.purple_btn {
background-color: #bbaaee;
border: 1px solid #bbaaee;
}
.app img {
width:175px;
border-radius: 5px;
margin:7px;
}
.app {
}
</style>
</head>
<body>
<div class="remote container">
<div class="col-xs-12 row">
<div class="col-xs-4">
<button class="btn btn-default" onclick="javascript:roku_command('Back')"><i class="glyphicon glyphicon-arrow-left"></i></button>
</div>
<div class="col-xs-4"> </div>
<div class="col-xs-4">
<button class="btn btn-default" onclick="javascript:roku_command('Home')"><i class="glyphicon glyphicon-home"></i></button>
</div>
</div>
<div class="col-xs-12 row" style="margin-top:10px">
<div class="col-xs-4"> </div>
<div class="col-xs-4">
<button class="btn btn-default purple_btn" onclick="javascript:roku_command('Up')"><i class="glyphicon glyphicon-chevron-up"></i></button>
</div>
<div class="col-xs-4"> </div>
</div>
<div class="col-xs-12 row">
<div class="col-xs-4">
<button class="btn btn-default purple_btn" onclick="javascript:roku_command('Left')"><i class="glyphicon glyphicon-chevron-left"></i></button>
</div>
<div class="col-xs-4"> </div>
<div class="col-xs-4">
<button class="btn btn-default purple_btn" onclick="javascript:roku_command('Right')"><i class="glyphicon glyphicon-chevron-right"></i></button>
</div>
</div>
<div class="col-xs-12 row">
<div class="col-xs-4"> </div>
<div class="col-xs-4">
<button class="btn btn-default purple_btn" onclick="javascript:roku_command('Down')"><i class="glyphicon glyphicon-chevron-down"></i></button>
</div>
<div class="col-xs-4"> </div>
</div>
<div class="col-xs-12 row" style="margin-top:10px">
<div class="col-xs-4">
<button class="btn btn-default" onclick="javascript:roku_command('InstantReplay')"><i class="glyphicon glyphicon-repeat"></i></button>
</div>
<div class="col-xs-4">
<button class="btn btn-default" onclick="javascript:roku_command('Select')"><span style="font-size:10px">OK</span></button>
</div>
<div class="col-xs-4">
<button class="btn btn-default" onclick="javascript:roku_command('Info')"><i class="glyphicon glyphicon-asterisk"></i></button>
</div>
</div>
<div class="col-xs-12 row" style="margin-top:10px">
<div class="col-xs-4">
<button class="btn btn-default" onclick="javascript:roku_command('Rev')"><i class="glyphicon glyphicon-backward"></i></button>
</div>
<div class="col-xs-4">
<button class="btn btn-default" onclick="javascript:roku_command('Play')"><i class="glyphicon glyphicon-play"></i></button>
</div>
<div class="col-xs-4">
<button class="btn btn-default" onclick="javascript:roku_command('Fwd')"><i class="glyphicon glyphicon-forward"></i></button>
</div>
</div>
<div class="col-xs-12 row" style="margin-top:50px">
</div>
<div class="row text-center">
<button class="btn btn-default purple_btn" data-toggle="modal" data-target="#myModal"><span style="font-size:10px">APPS</span></button>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Your Roku Apps</h4>
</div>
<div class="modal-body" id="roku-apps">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</body>
</html>