-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
138 lines (123 loc) · 4.62 KB
/
index.html
File metadata and controls
138 lines (123 loc) · 4.62 KB
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
<html>
<head>
<title>No mercy...</title>
<link rel="stylesheet" type="text/css" href="/style">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="/simplesocket"></script>
<script type="text/javascript">
var commands = {};
commands["reload"] = function( msgJson ){ $('link[href="/style"]').attr('href','/style'); };
commands["setBackground"] = function( msgJson ){ $("body").css("background-image","url('"+msgJson.data+"')"); };
commands["setActiveShow"] = function( msgJson ){
for(i = 0; i < 10; i++)
{
$("#show"+i).removeClass("showActive");
$("#show"+i).addClass("showInactive");
}
$("#show"+msgJson.data).addClass("showActive");
};
commands["setSchedule"] = function( msgJson ){
var scheduleJson = JSON.parse( msgJson.data );
jQuery('#schedule').html('');
var longestNameIndex = 0;
var longestName = 0;
jQuery.each(scheduleJson.shows, function(i, val) {
var nameLength = val.name.length;
if( val.name && nameLength > longestName )
{
longestName = val.name.length;
longestNameIndex = i;
}
});
var showIndex = 0;
jQuery.each(scheduleJson.shows, function(i, val) {
if( val.name )
{
var spacing = " ";
var nameLength = val.name.length;
for(i = 0; i < 3 + longestName - nameLength; i = i + 1)
{
spacing += "-"
}
spacing += " ";
jQuery('#schedule').append('<p id="show'+showIndex+'" class="showInactive">'+val.name + spacing + val.time + '</p>');
showIndex++;
}
});
};
commands["setMetaData"] = function( msgJson ){
metaDataJson = JSON.parse( msgJson.data );
jQuery('#nowPlaying').html('');
if( metaDataJson.type == 'spotify' )
{
jQuery('#nowPlaying').append( '<iframe src="https://open.spotify.com/embed/track/'+metaDataJson.id+'" width="300" height="380" frameborder="0" allowtransparency="true"></iframe>' );
}
};
var currentFirework = 0;
commands["spawnFireworks"] = function( msgJson ){
var fireworks = $('#fireworks'+currentFirework);
currentFirework = (currentFirework + 1) % 20;
fireworks.show();
fireworks.css({top: msgJson.data.positionY + $(window).height() / 2, left: msgJson.data.positionX + $(window).width() / 2, position: "absolute" });
setTimeout(function() {
fireworks.attr('src', '/fireworks?hack='+currentFirework);
}, 0);
};
function runCommand( msgJson ) {
if( msgJson.type in commands )
{
commands[msgJson.type](msgJson);
}
else
{
alert( "not found: " + msgJson.type );
}
}
var webSocket = $.simpleWebSocket({ url: '<websocket_server>' });
webSocket.connect();
webSocket.isConnected(function(connected) {
webSocket.send('connected');
});
webSocket.listen(function(msgString) {
var msgJson = JSON.parse( msgString );
runCommand( msgJson );
});
$(document).click(function(e){
var center_x = $(window).width() / 2;
var center_y = $(window).height() / 2;
webSocket.send( JSON.stringify({ type : 'spawnFireworks', data : { positionX : e.pageX - center_x - 125, positionY : e.pageY - center_y - 125 } }) );
});
</script>
</head>
<body>
<img id="fireworks0" class="fireworks" src="/fireworks">
<img id="fireworks1" class="fireworks" src="/fireworks">
<img id="fireworks2" class="fireworks" src="/fireworks">
<img id="fireworks3" class="fireworks" src="/fireworks">
<img id="fireworks4" class="fireworks" src="/fireworks">
<img id="fireworks5" class="fireworks" src="/fireworks">
<img id="fireworks6" class="fireworks" src="/fireworks">
<img id="fireworks7" class="fireworks" src="/fireworks">
<img id="fireworks8" class="fireworks" src="/fireworks">
<img id="fireworks9" class="fireworks" src="/fireworks">
<img id="fireworks10" class="fireworks" src="/fireworks">
<img id="fireworks11" class="fireworks" src="/fireworks">
<img id="fireworks12" class="fireworks" src="/fireworks">
<img id="fireworks13" class="fireworks" src="/fireworks">
<img id="fireworks14" class="fireworks" src="/fireworks">
<img id="fireworks15" class="fireworks" src="/fireworks">
<img id="fireworks16" class="fireworks" src="/fireworks">
<img id="fireworks17" class="fireworks" src="/fireworks">
<img id="fireworks18" class="fireworks" src="/fireworks">
<img id="fireworks19" class="fireworks" src="/fireworks">
<div id="stream">
<audio controls autoplay>
<source src="<stream_ip>" id="audio" type="audio/mpeg">
</audio>
</div>
<div id="schedule">
</div>
<div id="nowPlaying">
</div>
</body>
</html>