-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.html
91 lines (83 loc) · 2.14 KB
/
home.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Chat Example</title>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script type="text/javascript">
$(function() {
function waitForSocketConnection(socket, callback){
setTimeout(
function () {
if (socket.readyState === 1) {
console.log("Connection is made")
if(callback != null){
callback();
}
return;
} else {
console.log("wait for connection...")
waitForSocketConnection(socket, callback);
}
}, 5); // wait 5 milisecond for the connection...
}
var conn = new WebSocket("ws://{{$}}/ws/music");
$("#prev").click(function() {
if (conn.readyState!=1) {
conn = new WebSocket("ws://{{$}}/ws/music");
}
waitForSocketConnection(conn, function(){conn.send('{"op":"prev"}')})
})
$("#next").click(function() {
if (conn.readyState!=1) {
conn = new WebSocket("ws://{{$}}/ws/music");
}
waitForSocketConnection(conn, function(){conn.send('{"op":"next"}')})
})
$("#play").click(function() {
if (conn.readyState!=1) {
conn = new WebSocket("ws://{{$}}/ws/music");
}
waitForSocketConnection(conn, function(){conn.send('{"op":"play"}')})
})
});
</script>
<style type="text/css">
html {
overflow: hidden;
}
body {
overflow: hidden;
padding: 0;
margin: 0;
width: 100%;
height: 100%;
background: gray;
}
#log {
background: white;
margin: 0;
padding: 0.5em 0.5em 0.5em 0.5em;
position: absolute;
top: 0.5em;
left: 0.5em;
right: 0.5em;
bottom: 3em;
overflow: auto;
}
#form {
padding: 0 0.5em 0 0.5em;
margin: 0;
position: absolute;
bottom: 1em;
left: 0px;
width: 100%;
overflow: hidden;
}
</style>
</head>
<body>
<button id="prev">Prev</button><br />
<button id="play">Play</button><br />
<button id="next">Next</button><br />
</body>
</html>