Skip to content

Commit

Permalink
copied everything needed from game1
Browse files Browse the repository at this point in the history
  • Loading branch information
selma-lindfors committed Jul 29, 2019
1 parent cb78761 commit b843daa
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 232 deletions.
87 changes: 53 additions & 34 deletions game.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,62 @@
<body>
<div class="container">
<div id="loader"></div>
<div id="segment-index" class="flex-column flex-center hidden">
<h1>Choose a segment!</h1>
<ul id="all-btns"> </ul>
<ul id="segment-buttons" class="window-column">
</ul>
</div>

<div id="game" class="hidden">
<div id="hud">
<div id="hud-item">
<p class="hud-prefix"></p>
<h1 id="questionCounter" class="hud-main-text"></h1></div>
<div id="hud-item">
<div id="segment-index" class="flex-column flex-center hidden">
<h1>Choose a segment!</h1>
<ul id="all-btns"> </ul>
<ul id="segment-buttons" class="window-column">
</ul>
</div>

<div id="game" class="hidden">
<div id="hud">
<div id="hud-item">
<p class="hud-prefix"></p>
<h1 id="score" class="hud-main-text"></h1>
<h1 id="questionCounter" class="hud-main-text"></h1></div>
<div id="hud-item">
<p class="hud-prefix"></p>
<h1 id="score" class="hud-main-text"></h1>
<h4 id="contentName"></h4>
<a id="episodeurl" href="url" target="_blank" ><h3 id="episodeName"></h3></a>
<h2 id="question"></h2>
<div id="choice-box">
<div class="choice-container">
<p class="choice-prefix">1</p>
<p class="choice-text" data-number="1"></p>
</div>
<div class="choice-container">
<p class="choice-prefix">2</p>
<p class="choice-text" data-number="2"></p>
</div>
<div class="choice-container">
<p class="choice-prefix">3</p>
<p class="choice-text" data-number="3"></p>
</div>
<div class="choice-container">
<p class="choice-prefix">4</p>
<p class="choice-text" data-number="4"></p>
</div>

</div>
<form id="answer-form" class="hidden">
<input
type="text"
name="answer"
id="answer"
placeholder="answer"
/>
<button
type="submit"
class="btn"
id="saveAnswerButton"
disabled
>
Submit
</button>
</form>
</div>
</div>
</div>
<h4 id="contentName"></h4>
<a id="episodeurl" href="url" target="_blank" ><h3 id="episodeName"></h3></a>
<h2 id="question"></h2>

<div class="choice-container">
<p class="choice-prefix">1</p>
<p class="choice-text" data-number="1"></p>
</div>
<div class="choice-container">
<p class="choice-prefix">2</p>
<p class="choice-text" data-number="2"></p>
</div>
<div class="choice-container">
<p class="choice-prefix">3</p>
<p class="choice-text" data-number="3"></p>
</div>
<div class="choice-container">
<p class="choice-prefix">4</p>
<p class="choice-text" data-number="4"></p>
</div>
</div>
</div>
</div>
Expand Down
29 changes: 25 additions & 4 deletions game.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const contentId = params.contentId;
const contributed = params.contributed;
const segmentBox = document.getElementById("segment-index");
const segmentButtons = document.getElementById("segment-buttons");
const choiceBox = document.getElementById("choice-box");
const answerForm = document.getElementById("answer-form");
const saveAnswerBtn = document.getElementById("saveAnswerButton");
const answer = document.getElementById("answer");

// state
let currentQuestion = {};
Expand Down Expand Up @@ -121,10 +125,27 @@ const getNewQuestion = () => {
contentNameText.innerText = currentQuestion.content;
question.innerText = currentQuestion.question;
urlNameText.href = currentQuestion.url;
choices.forEach(choice => {
const number = choice.dataset["number"];
choice.innerText = currentQuestion["choice" + number];
});

if (currentQuestion.open === "TRUE") {
answerForm.classList.remove("hidden");
choiceBox.classList.add("hidden");
answer.addEventListener(
"keyup",
() => (saveAnswerBtn.disabled = !answer.value)
);
saveAnswerBtn.addEventListener("click", e => {
e.preventDefault();
console.log(
answer.value === currentQuestion["choice" + currentQuestion.answer]
);
getNewQuestion();
});
} else {
choices.forEach(choice => {
const number = choice.dataset["number"];
choice.innerText = currentQuestion["choice" + number];
});
}

availableQuestions.splice(questionIndex, 1);
acceptingAnswers = true;
Expand Down
194 changes: 0 additions & 194 deletions game1.js

This file was deleted.

0 comments on commit b843daa

Please sign in to comment.