Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
281 lines (265 sloc) 16.7 KB
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width"/>
<title>y!jeopardy</title>
<link type="text/css" href="s/mobile.css" rel="stylesheet" media="screen, projection" />
<script type="text/javascript" src="a/prototype.js"></script>
<script type="text/javascript" src="a/scriptaculous/scriptaculous.js"></script>
<script type="text/javascript">
var user = {
update_game_state: function() {
new Ajax.Request('Request.php?method=get_player&r=' + Math.random(), {
onSuccess: function(transport) {
if (user.timer == 0) {
// Add timer
user.timer = setInterval(function() { user.update_game_state(); }, 1000);
}
if (transport.responseJSON.status == 'ok') {
var state = '';
state = transport.responseJSON.data.state;
active = transport.responseJSON.data.active;
if (transport.responseJSON.data.name != user.player_name) {
$('name').update('(' + transport.responseJSON.data.name + ')');
}
if (transport.responseJSON.data.score != user.score) {
$('score').update('Points: ' + transport.responseJSON.data.score);
}
user.player_id = transport.responseJSON.data.handle;
user.player_name = transport.responseJSON.data.name;
user.score = transport.responseJSON.data.score;
if (state != user.game_state || active != user.active) {
// update local variable
user.game_state = state;
user.active = active;
// display appropriate screen
user.change_screen(state, active);
}
} else {
user.change_screen('LOGIN');
}
}
});
},
change_screen: function(state, active) {
// Adjust screen
window.scrollTo(0, 1);
// Show display
this.hide_panels(state);
var message = '', buzz = false;
switch (state) {
case 'GAME_OVER':
message = 'The next game will be starting soon.';
break;
case 'LOGIN':
message = 'Welcome to Y!Jeopardy.<br />Please enter your name.';
break;
case 'ROUND_OVER':
message = 'The next round will be starting soon.';
break;
case 'ANSWER':
if (active) {
message = 'You buzzed in first!<br />Please shout your answer!';
} else {
buzz = true;
message = 'Someone else beat you. :(';
}
break;
case 'DISPLAY_QUESTION':
// Reset Buzzer
this.can_buzz = false;
$('buzzer').className = 'button';
message = 'Please wait until the button turns red to buzz-in.';
buzz = true;
break;
case 'PICK_QUESTION':
$('pick_question').update('');
if (active) {
message = 'Please choose the next question.';
this.get_questions();
} else {
message = 'Please wait for the next question.'
}
break;
case 'BUZZ_IN':
message = 'Press the red button if you know the answer.';
buzz = true;
break;
case 'PAUSED':
message = 'Game is currently paused, please wait.';
break;
}
// Add message
$('game_state').update(message);
// Add buzz button
if (buzz) {
$('buzz').show();
this.wait_buzz();
} else {
$('buzz').hide();
this.can_buzz = false;
$('buzzer').className = 'button';
}
},
hide_panels: function(active) {
active = active.toLowerCase();
$$('div.panel').each(function(panel) {
if (panel.id == active) {
panel.show();
} else {
panel.hide();
}
});
},
ajax_call: function(method) {
if (this.ajax == false) {
// prevent multiple calls
this.ajax = true;
// Remove Timer for update
clearInterval(this.timer);
this.timer = 0;
$('loader').show();
new Effect.Opacity('loader', { from: 0.0, to: 0.75, duration: 0.1 });
new Ajax.Request('Request.php?method=' + method, {
onSuccess: function(transport) {
user.ajax = false;
$('loader').hide();
new Effect.Opacity('loader', { from: 0.75, to: 0.0, duration: 0.1 });
if (transport.responseJSON.status == 'ok') {
user.update_game_state();
} else {
alert('Error: ' + transport.responseJSON.data);
}
}
});
}
},
get_questions: function() {
new Ajax.Request('Request.php?method=get_categories&r=' + Math.random(), {
onSuccess: function(transport) {
if (transport.responseJSON.status == 'ok') {
user.questions = transport.responseJSON.data;
user.show_categories(-1);
} else {
alert('Error: ' + transport.responseJSON.data);
}
}
});
},
show_categories: function(index) {
if (index == -1) {
$('pick_question').update('');
user.questions.each(function(item, i) {
$('pick_question').innerHTML += '<div class="button green" onclick="user.show_categories(' + i + ')">'
+ item['name'] + '</div>';
});
} else {
$('pick_question').update('<div class="button red" onclick="user.show_categories(-1)">Back</div>');
user.questions[index]['questions'].each(function(item, i) {
$('pick_question').innerHTML += '<div class="button ' + (item['played'] == 0?'green':'')
+ '" onclick="user.pick_question(' + item['id'] + ')">'
+ item['points'] + '</div>';
});
}
},
wait_buzz: function() {
if (this.game_state == 'BUZZ_IN' ||
this.game_state == 'DISPLAY_QUESTION' ||
this.game_state == 'ANSWER') {
new Ajax.Request('Request.php?method=wait_buzz&r=' + Math.random(), {
onSuccess: function(transport) {
if (transport.responseJSON.status == 'ok') {
if (transport.responseJSON.data.can_buzz == true) {
$('buzzer').className = 'button red';
user.can_buzz = true;
} else {
$('buzzer').className = 'button';
user.can_buzz = false;
setTimeout(function() { user.wait_buzz(); }, 500);
}
} else {
alert('Error: ' + transport.responseJSON.data);
}
}
});
}
},
pick_question: function(id) {
this.ajax_call('pick_question&id=' + id);
},
login: function() {
this.game_state = '';
this.score = -1;
this.player_name = -1;
this.player_id = -1;
this.ajax_call('new_player&name=' + $('username').value);
},
buzz: function() {
if (this.can_buzz) {
this.ajax_call('buzz');
}
},
game_state: '',
player_id: '',
player_name: '',
score: -1,
active: -1,
can_buzz: false,
questions: {},
timer: 0,
ajax: false
};
Event.observe(document, 'dom:loaded', function() {
user.update_game_state();
});
</script>
</head>
<body onload="window.scrollTo(0,1);">
<div class="container">
<div class="menu">
<div style="float:left">
Y! Jeopardy
</div>
<span id="name" style="padding-left: 10px; float:left">
</span>
<span class="button" onclick="user.change_screen('LOGIN')">
Logout
</span>
</div>
<div class="content">
<br />
<h2 id="score" style="color:#FFF;font-size:14px;"></h2>
<h2 id="game_state"></h2>
<br />
<div id="login" class="panel" style="display:none">
<fieldset class="message">
<legend></legend>
<span style="font-size:11px;font-weight:bold;">Name:</span>
<br />
<input type="text" id="username" style="width:250px;font-size:40px;font-weight:bold;border:0px;" maxlength="15" />
</fieldset>
<br />
<div class="button" onclick="user.login()">
Login
</div>
</div>
<div id="buzz" style="display: none">
<div class="button" id="buzzer" onmousedown="user.buzz()">
BUZZ-IN
</div>
<br />
</div>
<div id="paused" class="panel" style="display:none"></div>
<div id="game_over" class="panel" style="display: none"></div>
<div id="round_over" class="panel" style="display: none"></div>
<div id="pick_question" class="panel" style="display: none"></div>
<div id="display_question" class="panel" style="display: none"></div>
<div id="buzz_in" class="panel" style="display: none"></div>
<div id="answer" class="panel" style="display: none"></div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/gwzHyrNWDGLCntFv15G3MB3JVw40Tr/WLGNCnHnPrAvYsZK7Atn3gEjbNmqENTkKA4IyIqUABsRN5lKiSIgWfO5ge4vAhgROnHrgf7tjTu7mfOw5xbJJAnbqh4A87Nd/eR45rQ9XDZ796COfJducoF8KZHl5CHdAO4zA/n8IPkYHriRDZBGdgnDrtUecDdq6VQF8KVPggkBxIhBBCJ50gIccll7zBXnvwOUSEH/SV8AYAbzTo4IhIwEEhDwFKgANEmHRCxXZ6aALAJT6MaGMIPlBoA3jh7SDRG0SUsMcTnexA4SVB3DhiEJcIhMkOPfjQw4oUYRJHfwQF0YmSIdxXEIEp1cilIWu9AcmWI3Zyx4dryXFHmnd4ZxocPQQRhCFstqbnnlUFBAA7" alt="loading..." />
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.