Permalink
Browse files

Merge branch 'master' of github.com:mbarton/musictionary

# By Valdemaras (2) and Michael Barton (1)
# Via Valdemaras
* 'master' of github.com:mbarton/musictionary:
  pusher presence stuff
  using list instead of map. users' list.
  Unpleasant hacks to make the demo look plausible. AWOOGA!
  • Loading branch information...
2 parents 53d23fc + 246ac23 commit 173c65a7a1f2d0d87e653752f971045309dce06d @ciudilo ciudilo committed Sep 21, 2012
Showing with 42 additions and 5 deletions.
  1. +3 −2 server.py
  2. +17 −3 static/js/fb.js
  3. +10 −0 static/js/ui.js
  4. +12 −0 templates/room.html
View
5 server.py
@@ -72,11 +72,12 @@ def room(room):
if room == "favicon.ico":
# LOL
return ""
-
+ host = False
if not room in app.rooms:
app.rooms[room] = copy.deepcopy(app.default_matrix)
+ host = True
app.users[str(room)] = []
- return render_template('room.html', matrix=json.dumps(app.rooms[room]), room=room)
+ return render_template('room.html', matrix=json.dumps(app.rooms[room]), room=room, host=host)
@app.route("/")
def index():
View
20 static/js/fb.js
@@ -2,6 +2,17 @@
MusictionaryFacebook = function(secret) {
+ confirmExit = function() {
+ if (app.currentUserId != null) {
+ var url = "player/" + MusictionaryRoom + "/" + app.currentUserId;
+ $.ajax(url, {type: "DELETE"});
+ }
+ }
+
+ window.onbeforeunload = confirmExit;
+
+
+
var self = {};
$(function(){
@@ -46,12 +57,12 @@ MusictionaryFacebook = function(secret) {
var user_info_el = $('#user_info');
- refresh_connected_users = function(ids_map) {
+ refresh_connected_users = function(ids) {
$('#connected_users').empty()
- $.each(ids_map, function(key, val) {
+ _.each(ids, function(val) {
get_user_info(val, function(user_info) {
$('#connected_users').append('<div class="user_info_item"><img src="' + user_info.pic_square + '" /><div><a href="https://www.facebook.com/'+user_info.username+'">'+user_info.name+'</a></div></div>');
- });
+ });
});
}
@@ -102,6 +113,9 @@ MusictionaryFacebook = function(secret) {
FB.Event.subscribe('auth.login', update_user_info);
FB.Event.subscribe('auth.logout', update_user_info);
+
+ app.net.channel.bind('presence', update_user_info);
+
/*FB.getLoginStatus(update_user_info);*/
};
View
10 static/js/ui.js
@@ -104,6 +104,9 @@ self.setEditing = function(index){
$(function(){
$(".trigger").live("click", function(){
+ if(MusictionaryHost == "False")
+ return
+
var instrument = $(this).parent().children(".label").html();
var index = $(this).parent().children(".trigger").index(this);
// Flip flop!
@@ -123,7 +126,14 @@ $("#stop").click(function(){
app.stop();
});
+$("#songD").click(function(){
+ $("#guesser").html("<h1>YOU ARE CORRECT ROCK ON!</h1>");
+})
+
$("body").keydown(function(ev){
+ if(MusictionaryHost == "False")
+ return
+
switch(ev.keyCode)
{
case UP_ARROW:
View
12 templates/room.html
@@ -12,6 +12,7 @@
MusictionaryMatrix = {{ matrix|safe }}
// TODO MRB: CAN U SPOT THE XSS ATTACK!
MusictionaryRoom = "{{ room|safe }}"
+ MusictionaryHost = "{{ host|safe }}"
</script>
<script type="text/javascript" src="{{ url_for('static', filename='js/secret.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', filename='js/net.js') }}"></script>
@@ -50,12 +51,23 @@ <h3 id="room_name">Room {{ room }}</h3>
<button id="stop" class="btn"><img src="{{ url_for('static', filename='img/stop.png') }}" /></button>
</div>
</div>
+ {% if host %}
<div class="span6">
<h2>Recreate <strong>Thriller - Michael Jackson</strong>!</h2>
</div>
<div class="span2">
<button id="playclip">Play Clip</button>
</div>
+ {% else %}
+ <div class="span7" id="guesser">
+ <h2>What is this tune?</h2>
+ <button id="songA">Beat It - Michael Jackson</button>
+ <button id="songB">Bangarang - Skrillex</button>
+ <button id="songC">Night Fever - The Bee Gees</button>
+ <button id="songD">Thriller - Michael Jackson</button>
+ <button id="songE">Telephone - Lady Gaga</button>
+ </div>
+ {% endif %}
</div>
</div>
</div>

0 comments on commit 173c65a

Please sign in to comment.