Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
323 lines (299 sloc) 17 KB
<?php
include 'login.php';
?>
<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 admin =
{
update_game_state: function() {
new Ajax.Request('Request.php?method=get_game_state&r=' + Math.random(),
{
onSuccess: function(transport) {
if (transport.responseJSON.status == 'ok') {
if (admin.timer == 0) {
// Add timer
admin.timer = setInterval(function() { admin.update_game_state(); }, 1000);
}
var state = '', player = '';
state = transport.responseJSON.data.game_state;
if (transport.responseJSON.data.handle) {
player = transport.responseJSON.data.name + ' ('
+ transport.responseJSON.data.handle + ')';
}
if (state != admin.game_state || player != admin.active_player) {
// update dom
if (player != '') {
$('game_state').update(state);
$('game_data').update(player);
} else {
$('game_state').update(state);
$('game_data').update('');
}
}
if (state != admin.game_state) {
// display appropriate screen
admin.change_screen(state);
// update local variable
admin.game_state = state;
}
} else {
alert('Error: ' + transport.responseJSON.data);
}
}
});
},
update_answer: function() {
new Ajax.Request('Request.php?wssid=<?php echo ADMIN_SECRET; ?>&method=get_answer&r=' + Math.random(), {
onSuccess: function(transport) {
if (transport.responseJSON.status == 'ok') {
if (admin.game_state != 'ANSWER') {
alert('Answer: ' + transport.responseJSON.data.answer);
} else {
$('answer_text').update(transport.responseJSON.data.answer);
}
} else {
alert('Error: ' + transport.responseJSON.data);
}
}
});
},
change_screen: function(state) {
// show display
this.hide_panels(state);
switch (state) {
case 'ANSWER':
this.update_answer();
break;
case 'PICK_QUESTION':
case 'BUZZ_IN':
// Add timer
this.timer = setInterval(function() { admin.update_game_state(); }, 500);
break;
}
},
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, params, callback) {
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 });
params = Object.extend(params || {},
{
wssid: '<?php echo ADMIN_SECRET; ?>',
method: method,
r: Math.random()
});
new Ajax.Request('Request.php',
{
parameters: params,
onSuccess: function(transport)
{
admin.ajax = false;
$('loader').hide();
new Effect.Opacity('loader', { from: 0.75, to: 0.0, duration: 0.1 });
if (transport.responseJSON.status == 'ok') {
// if no callback assume it's regular call and something happened on the server
if (!callback) {
admin.update_game_state();
} else { // but if there is one let them decide what to do
callback(transport.responseJSON.data);
}
} else {
alert('Error: ' + transport.responseJSON.data);
}
}
});
}
},
pause_game: function() {
this.ajax_call('pause_game');
},
start_game: function() {
this.ajax_call('start_round');
},
reset_score: function() {
this.ajax_call('scores_clear');
},
reset_game: function() {
this.ajax_call('reset_game');
},
start_round: function() {
this.ajax_call('next_round');
},
skip_player: function() {
this.ajax_call('new_active_player');
},
skip_question: function() {
this.ajax_call('skip_question');
this.update_answer();
},
start_buzzing: function() {
this.ajax_call('start_buzzing');
},
answer_right: function() {
this.ajax_call('answer_right');
},
answer_wrong: function() {
this.ajax_call('answer_wrong');
},
update_players_list: function(data)
{
var container = $('remove_players').update();
data.each(function(pl)
{
container.insert('<span id="player_'+pl.id+'" class="player">'+pl.name+'</span>');
});
},
show_remove_players: function()
{
// show display
this.ajax_call('show_remove_players', {}, function(data)
{
this.update_players_list(data);
// some dirty magic here – it's 5am and stuff
$('action_button').insert({after: '<span id="action_back" class="button" onclick="admin.done_remove_players()">Done</span>'}).hide();
this.rm_handle = $('remove_players').on('click', 'span.player', function(e, el)
{
var id = el.id.substr(7);
if (id) this.remove_player(id);
}.bind(this));
// show off
$('paused').hide();
$('remove_players').show();
}.bind(this));
},
remove_player: function(id)
{
this.ajax_call('remove_player', {id: id}, function(data)
{
this.update_players_list(data);
}.bind(this));
},
done_remove_players: function()
{
if (this.rm_handle) this.rm_handle.stop();
if ($('action_back')) $('action_back').remove();
$('action_button').show();
$('paused').show();
$('remove_players').hide().update();
},
game_state: '',
active_player: '',
timer: 0,
ajax: false
};
Event.observe(document, 'dom:loaded', function() {
admin.update_game_state();
});
</script>
</head>
<body onload="setInterval(function() { window.scrollTo(0, 1) }, 1000);">
<div class="container">
<div class="menu">
<div id="game_state" style="float:left">
Loading...
</div>
<span id="action_button" class="button" onclick="admin.pause_game()">
Pause
</span>
</div>
<div class="content">
<br />
<h2 id="game_data"></h2>
<br />
<div id="paused" class="panel" style="display: none">
<div class="button" onclick="admin.pause_game()">
Resume Game
</div>
<br />
<br />
<br />
<div class="button" onclick="admin.reset_score()">
Reset Score
</div>
<br />
<div class="button" onclick="admin.show_remove_players()">
Remove Players
</div>
<br />
<br />
<br />
<div class="button danger" onclick="admin.reset_game()">
Reset Game
</div>
</div>
<div id="remove_players" class="panel" style="display: none">
</div>
<div id="game_over" class="panel" style="display: none">
<div class="button" onclick="admin.start_game()">
Start Game
</div>
<br />
<div class="button" onclick="admin.reset_game()">
Reset Game
</div>
</div>
<div id="round_over" class="panel" style="display: none">
<div class="button" onclick="admin.start_round()">
Start Next Round
</div>
</div>
<div id="pick_question" class="panel" style="display: none">
<div class="button" onclick="admin.skip_player()">
Skip Player
</div>
</div>
<div id="display_question" class="panel" style="display: none">
<div class="button" onclick="admin.start_buzzing()">
Begin Buzzing
</div>
</div>
<div id="buzz_in" class="panel" style="display: none">
<div class="button" onclick="admin.skip_question()">
Skip Question
</div>
</div>
<div id="answer" class="panel" style="display: none">
<fieldset class="message">
<legend></legend>
<span style="font-size:11px;font-weight:bold;">Answer:</span>
<br />
<span id="answer_text" style="padding-left: 5px;">
</span>
</fieldset>
<br />
<div class="button green" onclick="admin.answer_right()">
Answer Right
</div>
<br />
<div class="button red" onclick="admin.answer_wrong()">
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