-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
273 lines (260 loc) · 9.81 KB
/
index.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Music Hounds</title>
<link href='sp://import/css/adam.css' rel='stylesheet' />
<link href='sp://import/css/shared.css' rel='stylesheet' />
<link href='sp://import/css/api.css' rel='stylesheet' />
<link href='sp:/css/main.css' rel='stylesheet' />
</head>
<body>
<div id='Header'>
<div id='Notifcations'>
<!-- spotify:app:musichounds -->
</div>
<img id='Logo' src='sp:/images/logo.png' />
<h1>Music Hounds</h1>
</div>
<div id='Content'>
<div id='Homepage'>
<div class='capsule' id='JoinGame'>
<h2>Join a Game</h2>
<table id='LobbyGameTable'>
<tr>
<td>Room Name</td>
<td>Artist / Genre</td>
<td>
Current
<br />
Round
</td>
<td>
High
<br />
Score
</td>
<td></td>
</tr>
<tr>
<td>The best room ever!</td>
<td>A: Drake</td>
<td>1</td>
<td>0</td>
<td>
<a href='#1'>Join</a>
</td>
</tr>
<tr>
<td>Hot like Fiya!</td>
<td>G: Hip Hop</td>
<td>1</td>
<td>0</td>
<td>
<a href='#1'>Join</a>
</td>
</tr>
</table>
</div>
<div class='capsule' id='CreateGame'>
<h2>Create New Game</h2>
<div class='new_game_param'>
<label>Style</label>
<select id='ngpStyle'>
<option value=''>Any</option>
<option value='bluegrass'>Bluegrass</option>
<option value='country'>Country</option>
<option value='dance'>Dance</option>
<option value='grunge'>Grunge</option>
<option value='old school'>Old School</option>
<option value='pop'>Pop</option>
<option value='punk'>Punk</option>
<option value='r&b'>R&B</option>
<option value='rock'>Rock</option>
<option value='ska'>Aka</option>
<option value='soul'>Soul</option>
</select>
</div>
<div class='new_game_param separator'>
- OR -
</div>
<div class='new_game_param'>
<label>Artist</label>
<select id='ngpArtist'>
<option value=''>Any</option>
<option value='Adele'>Adele</option>
<option value='Billy Joel'>Billy Joel</option>
<option value='Bon Jovi'>Bon Jovi</option>
<option value='Bruno Mars'>Bruno Mars</option>
<option value='Coldplay'>Coldplay</option>
<option value='Drake'>Drake</option>
<option value='Kelly Clarkson'>Kelly Clarkson</option>
<option value='Kylie Minogue'>Kylie Minogue</option>
<option value='Lil Wayne'>Lil' Wayne</option>
<option value='LMFAO'>LMFAO</option>
<option value='Madonna'>Madonna</option>
<option value='Nicki Minaj'>Nicki Minaj</option>
<option value='Rihanna'>Rihanna</option>
<option value='Tribe Called Quest'>A Tribe Called Quest</option>
<option value='U2'>U2</option>
<option value='Whitney Houston'>Whitney Houston</option>
<option value='Young Jezzy'>Young Jezzy</option>
</select>
</div>
<button class='new-button' id='btnCreateGame'>Create New Game</button>
</div>
<br style='clear:both;' />
</div>
<div class='capsule' id='PlayGame'>
<ul class='capsule' id='Players'>
<li class='current_player' id='player_3'>
<button class='new-button' id='LeaveRoom' value='leave'>Leave Room</button>
<div class='name'>player_x4f23</div>
<div class='points message'>10</div>
</li>
<li id='player_1'>
<div class='name'>player_x4f23</div>
<div class='points message'>3</div>
</li>
<li id='player_2'>
<div class='name'>player_x4f23</div>
<div class='points message'>-2</div>
</li>
</ul>
<div id='GameBoard'>
<div id='GoalScore'>
<h3>Goal Score</h3>
<div class='message'>20</div>
</div>
<div id='CurrentRound'>
<h3>Current Round</h3>
<div class='message'>1</div>
</div>
<div id='ClueStage'>
<div id='Clue1'>
<h3>Clue 1:</h3>
<div class='message'>And bring back all of those happy days Put your trouble down It's time to celebrate Let love shine And we will find</div>
</div>
<div id='Clue2'>
<h3>Clue 2:</h3>
<div class='message'>Everybody spread the word We're gonna have a celebration All across the world In every nation It's time for the good times</div>
</div>
</div>
<div id='AnswerSpace'>
<h3>The answer is...</h3>
<div class='message'></div>
</div>
<div id='ActionButtons'>
<button class='new-button' id='btnGotIt' value='yes'>I Got It!!</button>
<button class='new-button' id='btnNoIdea' value='no'>No Idea</button>
</div>
</div>
<br style='clear:both;' />
</div>
</div>
<div id='Footer'>
<div id='Powered'>
Powered by EchoNest, Pusher, LyricFind & Spotify
</div>
<div id='Creator'>
Created by Abel Martin
</div>
</div>
<script id='TMPCreateGame' type='text/x-jquery-tmpl'></script>
<!-- -- [0] Required libraries -->
<script src='sp:/js/req/jquery-1.7.1.min.js'></script>
<script src='sp:/js/req/underscore-1.3.1.min.js'></script>
<script src='sp:/js/req/mustache-0.4.2.js'></script>
<script src='sp:/js/req/backbone-0.9.1.min.js'></script>
<script src='sp:/js/req/pusher-1.11.min.js'></script>
<!-- -- [1] API Keys -->
<script src='sp:/js/app/api_keys.js'></script>
<!-- -- [2] Models -->
<!-- -- [3] Collections -->
<!-- -- [4] Views -->
<!-- -- [5] Writers -->
<script type='text/javascript'>
//<![CDATA[
var gblSpotifyModels;
var gblCurrentTrack;
var gblPusher;
$(function(){
gblPusher = new Pusher('f741395dd9ac3fcd542b');
var channel = gblPusher.subscribe('test_channel');
channel.bind('my_event', function(data) {
$("#Notifcations").html(data);
});
var sp = getSpotifyApi(1);
gblSpotifyModels = sp.require('sp://import/scripts/api/models');
if( gblSpotifyModels.player.playing ){
gblCurrentTrack = gblSpotifyModels.player.track;
}
gblSpotifyModels.player.observe(gblSpotifyModels.EVENT.CHANGE, function(event) {
if( gblSpotifyModels.player.playing ){
console.log("1");
gblCurrentTrack = gblSpotifyModels.player.track;
console.log("2");
var lbl_track = gblCurrentTrack.data.name + " - " + gblCurrentTrack.data.artists[0].name;
console.log("3");
$("#Notifcations").html(lbl_track);
}
/*else{
$("#Notifcations").html("");
}*/
console.log("We should have updated the notification");
});
$("#LeaveRoom").click(function(){
$("#Homepage").show();
$("#PlayGame").hide();
});
if (localStorage.getItem("user_guid") == null){
localStorage.setItem( "user_guid", guid() );
}
var u_guid = localStorage.getItem("user_guid");
console.log( u_guid );
$("#btnCreateGame").click(function(){
$.when( createUser(), createRoom() ).done(function(user_data, room_data){
//data is a payload with the room chanel name.
$("#Homepage").hide();
$("#PlayGame").show();
var channel = gblPusher.subscribe(room_data.room_chanel);
channel.bind('my_event', function(data) {
$("#Notifcations").html(data);
});
});
});
});
//I got the GUID code from StackOverflow
//http://stackoverflow.com/questions/7940616/what-makes-this-pseudo-guid-generator-better-than-math-random
function S4() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}
function guid() {
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}
function createRoom(){
$.ajax({
url: "http://mhbackend.heroku.com:3000/rooms.js",
data: {
room: {artist: $("#ngpArtist").val(), style: $("#ngpStyle").val()}
},
dataType: "json",
type: "POST"
});
}
//This really has no business being here, but I need it for testing.
function createUser(){
var u_guid = localStorage.getItem("user_guid");
var player_name = "player" + u_guid.split('-')[0];
$.ajax({
url: "http://mhbackend.heroku.com:3000/users.js",
data: {
user: {guid: u_guid, name: player_name}
},
dataType: "json",
type: "POST"
});
}
//]]>
</script>
</body>
</html>