fill game
This commit is contained in:
parent
daccb1d5c4
commit
24f29512e5
|
@ -1,5 +1,5 @@
|
||||||
[
|
[
|
||||||
{ "question": "Как овас?",
|
{ "text": "Как овас?",
|
||||||
"tier": 1000,
|
"tier": 1000,
|
||||||
"answers": [ { "text": "Орчин хорошо",
|
"answers": [ { "text": "Орчин хорошо",
|
||||||
"right": true },
|
"right": true },
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
{ "text": "Не хорошо" },
|
{ "text": "Не хорошо" },
|
||||||
{ "text": "Исвинизие?" }
|
{ "text": "Исвинизие?" }
|
||||||
] },
|
] },
|
||||||
{ "question": "где выхад?",
|
{ "text": "где выхад?",
|
||||||
"tier": 2000,
|
"tier": 2000,
|
||||||
"answers": [ { "text": "Я вы́йду о вас" },
|
"answers": [ { "text": "Я вы́йду о вас" },
|
||||||
{ "text": "Я не снаю" },
|
{ "text": "Я не снаю" },
|
||||||
|
|
10
index.html
10
index.html
|
@ -25,19 +25,19 @@
|
||||||
<ul id="players">
|
<ul id="players">
|
||||||
</ul>
|
</ul>
|
||||||
<p id="tier">
|
<p id="tier">
|
||||||
30,000
|
0
|
||||||
</p>
|
</p>
|
||||||
<div id="question">
|
<div id="question">
|
||||||
<p>Welches Land erlaubt Filesharing für private Zwecke straffrei?</p>
|
<p>Welches Land erlaubt Filesharing für private Zwecke straffrei?</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="answers">
|
<div id="answers">
|
||||||
<ul>
|
<ul>
|
||||||
<li>Montenegro</li>
|
<li id="answer0">Montenegro</li>
|
||||||
<li class="selected">China</li>
|
<li id="answer1">China</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul>
|
<ul>
|
||||||
<li class="wrong">Deutschland</li>
|
<li id="answer2">Deutschland</li>
|
||||||
<li class="right">Brasilien</li>
|
<li id="answer3">Brasilien</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
49
quiz.js
49
quiz.js
|
@ -1,3 +1,9 @@
|
||||||
|
var keyHandler;
|
||||||
|
$(document).bind('keydown', function(event) {
|
||||||
|
if (keyHandler)
|
||||||
|
keyHandler(String.fromCharCode(event.keyCode));
|
||||||
|
});
|
||||||
|
|
||||||
$(window).bind('load', function() {
|
$(window).bind('load', function() {
|
||||||
$('#game').hide();
|
$('#game').hide();
|
||||||
$('#scoreboard').hide();
|
$('#scoreboard').hide();
|
||||||
|
@ -37,7 +43,7 @@ function loadQuizData(done) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var playerNames = [];
|
var playerNames = [], playerScores = [];
|
||||||
|
|
||||||
function startQuiz() {
|
function startQuiz() {
|
||||||
var i;
|
var i;
|
||||||
|
@ -54,18 +60,51 @@ function startQuiz() {
|
||||||
continue; // skip empty players
|
continue; // skip empty players
|
||||||
|
|
||||||
playerNames[i] = name;
|
playerNames[i] = name;
|
||||||
|
playerScores[i] = 0;
|
||||||
$('#scoreboard dl').append('<dt></dt><dd>0</dd>');
|
$('#scoreboard dl').append('<dt></dt><dd>0</dd>');
|
||||||
$('#scoreboard dl dt').last().text(name);
|
$('#scoreboard dl dt').last().text(name);
|
||||||
$('#players').append('<li class="player'+i+'"><span class="name"></span><span class="score">0</span></li>');
|
$('#players').append('<li class="player'+i+'"><span class="name"></span><span class="score">0</span></li>');
|
||||||
$('#players li.player'+i+' span.name').text(name);
|
$('#players li.player'+i+' span.name').text(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#setup').fadeOut(100, function() {
|
$('#setup').fadeOut(700, function() {
|
||||||
switchToScoreboard();
|
switchToScoreboard();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchToScoreboard() {
|
function switchToScoreboard() {
|
||||||
$('#scoreboard').fadeIn(300, function() {
|
keyHandler = function(key) {
|
||||||
});
|
if (key === ' ') {
|
||||||
}
|
$('#scoreboard').fadeOut(500, function() {
|
||||||
|
switchToGame();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$('#scoreboard').fadeIn(300);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Game screen is the one with the question in question
|
||||||
|
function switchToGame() {
|
||||||
|
var i, q = questions[currentQuestion];
|
||||||
|
|
||||||
|
$('#tier').text(q.tier);
|
||||||
|
|
||||||
|
$('#question').empty();
|
||||||
|
if (q.text) {
|
||||||
|
$('#question').append('<p></p>');
|
||||||
|
$('#question p').text(q.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i = 0; i < 4; i++) {
|
||||||
|
var answer = q.answers[i];
|
||||||
|
var li = $('#answers li').eq(i);
|
||||||
|
li.text(answer.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
keyHandler = function(key) {
|
||||||
|
};
|
||||||
|
|
||||||
|
// Instantly show the question:
|
||||||
|
$('#game').show();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue