content/hifi-content/rebecca/Trivia/podium style/trivia.html
2022-02-14 02:04:11 +01:00

278 lines
11 KiB
HTML

<html>
<head>
<title>Trivia</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Raleway:300,400,600,700" rel="stylesheet">
<style>
body {
margin: 10;
width: 100% - 10px;
font-family: 'Raleway', sans-serif;
color: #cccbcb;
background: linear-gradient(#2b2b2b, #303030);
}
.top-bar {
height: 90px;
background: linear-gradient(#2b2b2b, #303030);
font-weight: bold;
padding-left: 30px;
padding-right: 30px;
display: flex;
align-items: center;
position: fixed;
width: 480px;
top: 0;
z-index: 1;
}
.content {
margin-top: 90px;
padding: 30px;
}
input[type=button] {
font-family: 'Raleway';
font-weight: bold;
font-size: 13px;
text-transform: uppercase;
vertical-align: top;
height: 28px;
min-width: 120px;
padding: 0px 18px;
margin-right: 6px;
border-radius: 5px;
border: none;
color: #fff;
background-color: #000;
background: linear-gradient(#343434 20%, #000 100%);
cursor: pointer;
}
input[type=button].gray {
color: #121212;
background-color: #949494;
background: linear-gradient(#949494 20%, #cacaca 100%);
}
input[type=button]:enabled:hover {
background: linear-gradient(#000, #000);
border: none;
}
input[type=button].gray:enabled:hover {
background: linear-gradient(#fff, #fff);
border: none;
}
input[type=button]:active {
background: linear-gradient(#343434, #343434);
}
input[type=button].gray:active {
background: linear-gradient(#afafaf, #afafaf);
}
input[type=button]:disabled {
color: #252525;
background: linear-gradient(#575757 20%, #252525 100%);
}
input[type=button][pressed=pressed] {
color: #00b4ef;
}
.correct {
color: #00b4ef;
}
</style>
</head>
<body>
<h1>Trivia</h1>
<input type="button" class="gray" id="begin" value="Let's get started!"> </input>
<h3>Questions</h3>
<select class="gray" id="type">
<option value="anyType">Any Type</option>
<option value="multiple">Multiple Choice</option>
<option value="boolean">True or False</option>
</select>
<select id="difficulty">
<option value="anyDifficulty">Any Difficulty</option>
<option value="easy">Easy</option>
<option value="medium">Medium</option>
<option value="hard">Hard</option>
</select>
<select id="category">
<option value="anyCategory">Any Category</option>
<optgroup label="Entertainment">
<option value="9">General Knowledge</option>
<option value="10">Books</option>
<option value="11">Film</option>
<option value="12">Music</option>
<option value="13">Musicals and Theatres</option>
<option value="14">Television</option>
<option value="15">Video Games</option>
<option value="16">Board Games</option>
<option value="29">Comics</option>
<option value="31">Japanese Anime and Manga</option>
<option value="32">Cartoon and Animations</option>
</optgroup>
<option value="17">Science and Nature</option>
<optgroup label="Science">
<option value="18">Computers</option>
<option value="19">Mathematics</option>
<option value="30">Gadgets</option>
</optgroup>
<option value="25">Art</option>
<option value="26">Celebrities</option>
<option value="27">Animals</option>
<option value="28">Vehicles</option>
<option value="20">Mythology</option>
<option value="21">Sports</option>
<option value="23">History</option>
<option value="22">Geography</option>
<option value="24">Politics</option>
</select>
<p>
<input type="button" class="gray" id="newQuestion" value="Gimme A Question"> </input>
<input type="button" class="gray" id="showQuestion" value="Yes! Show it!"> </input>
<p>
<div id="question">
Here's yo question!
</div>
<p>
<div id="answer">
Here's yo answer!
</div>
<p></p>
<input type="button" class="gray" id="showCorrect" value="Show Correct Answer"> </input>
<h3>Sound Effects</h3>
<input type="button" class="gray" id="correctAnswer" value="Correct Answer"> </input>
<input type="button" class="gray" id="wrongAnswer" value="Wrong Answer"> </input>
<p>
<input type="button" class="gray" id="gameBegin" value="Begin Game"> </input>
<input type="button" class="gray" id="nextRound" value="Next Round"> </input>
<input type="button" class="gray" id="gameEnd" value="Game Over"> </input>
<p>
<input type="range" class="gray" id="volumeSlider" min="0" max="100" value="70"> </input>
<br>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
function onScriptEventReceived(event) {
if (typeof event === "string") {
triviaData = JSON.parse(event);
document.getElementById("question").innerHTML = triviaData.question;
if (triviaData.type === "multiple") {
document.getElementById("answer").innerHTML = "<p class=\"correct\">" +
triviaData.correct_answer + "<p>" +
triviaData.incorrect_answers[0] + "<p>" +
triviaData.incorrect_answers[1] + "<p>" +
triviaData.incorrect_answers[2];
} else {
document.getElementById("answer").innerHTML = triviaData.correct_answer;
}
}
}
$(document).ready(function () {
EventBridge.scriptEventReceived.connect(onScriptEventReceived);
});
$('#begin').click(function() {
var event = {
type: "begin"
};
EventBridge.emitWebEvent(JSON.stringify(event));
});
$('#type').change(function() {
var event = {
type: "type",
value: this.value
};
EventBridge.emitWebEvent(JSON.stringify(event));
});
$('#difficulty').change(function() {
var event = {
type: "difficulty",
value: this.value
};
EventBridge.emitWebEvent(JSON.stringify(event));
});
$('#category').change(function() {
var event = {
type: "category",
value: this.value
};
EventBridge.emitWebEvent(JSON.stringify(event));
});
$('#newQuestion').click(function() {
var event = {
type: "newQuestion"
};
EventBridge.emitWebEvent(JSON.stringify(event));
});
$('#showQuestion').click(function() {
var event = {
type: "showQuestion"
};
EventBridge.emitWebEvent(JSON.stringify(event));
});
$('#showCorrect').click(function() {
var event = {
type: "showCorrect"
};
EventBridge.emitWebEvent(JSON.stringify(event));
});
$('#correctAnswer').click(function() {
var event = {
type: "correctAnswer"
};
EventBridge.emitWebEvent(JSON.stringify(event));
});
$('#wrongAnswer').click(function() {
var event = {
type: "wrongAnswer"
};
EventBridge.emitWebEvent(JSON.stringify(event));
});
$('#gameBegin').click(function(){
var event = {
type: "gameBegin"
};
EventBridge.emitWebEvent(JSON.stringify(event));
});
$('#nextRound').click(function() {
var event = {
type: "nextRound"
};
EventBridge.emitWebEvent(JSON.stringify(event));
});
$('#gameEnd').click(function() {
var event = {
type: "gameEnd"
};
EventBridge.emitWebEvent(JSON.stringify(event));
});
$('#volumeSlider').change(function() {
var event = {
type: "volumeSlider",
volume: $(this).val()
};
EventBridge.emitWebEvent(JSON.stringify(event));
});
$('#backdropDown').click(function() {
var event = {
type: "backdropDown"
};
EventBridge.emitWebEvent(JSON.stringify(event));
});
$('#backdropUp').click(function() {
var event = {
type: "backdropUp"
};
EventBridge.emitWebEvent(JSON.stringify(event));
});
</script>
</body>
</html>