visual tweaks

This commit is contained in:
Akbar Rahman 2022-01-14 02:05:45 +00:00
parent 36805a64a6
commit 8af47e5abc
Signed by: alvierahman90
GPG Key ID: 20609519444A1269

36
game.js
View File

@ -220,7 +220,12 @@ function displayEndScreen() {
clearInterval(gameTimeIntervalId); clearInterval(gameTimeIntervalId);
if (guessReverseFlag() || guessFlag()) {
incorrectAnswersTable.innerHTML = "<tr> <th> country </th> <th> answer </th> <th> your answer </th> </tr>";
correctAnswersTable.innerHTML = "<tr> <th> flag </th> <th> country </th> </tr>";
}
if (guessReverseFlag()) {
state.incorrectAnswers.forEach(ans => { state.incorrectAnswers.forEach(ans => {
var tr = document.createElement('tr'); var tr = document.createElement('tr');
console.log(ans) console.log(ans)
@ -228,6 +233,34 @@ function displayEndScreen() {
tr.appendChild(document.createElement('td')) tr.appendChild(document.createElement('td'))
tr.lastChild.innerHTML = ans.question.countryname tr.lastChild.innerHTML = ans.question.countryname
tr.appendChild(document.createElement('td'))
tr.lastChild.innerHTML = getImageURLFromCountryCode(ans.answer.code);
tr.appendChild(document.createElement('td'))
tr.lastChild.innerHTML = getImageURLFromCountryCode(ans.options[ans.userAnswer].code);
incorrectAnswersTable.appendChild(tr);
})
if (state.incorrectAnswers.length <= 0)
incorrectAnswersTable.innerHTML = "no incorrect answers! go you!";
state.correctAnswers.forEach(ans => {
var tr = document.createElement('tr');
tr.appendChild(document.createElement('td'))
tr.lastChild.innerHTML = getImageURLFromCountryCode(ans.question.code);
tr.appendChild(document.createElement('td'))
tr.lastChild.innerHTML = ans.answer.countryname;
correctAnswersTable.appendChild(tr);
})
} else {
state.incorrectAnswers.forEach(ans => {
var tr = document.createElement('tr');
console.log(ans)
tr.appendChild(document.createElement('td'))
if (guessCountry()) tr.lastChild.innerHTML = ans.question.capital
else tr.lastChild.innerHTML = ans.question.countryname
tr.appendChild(document.createElement('td')) tr.appendChild(document.createElement('td'))
if (guessFlag()) tr.lastChild.innerHTML = getImageURLFromCountryCode(ans.answer.code); if (guessFlag()) tr.lastChild.innerHTML = getImageURLFromCountryCode(ans.answer.code);
else tr.lastChild.innerHTML = ans.answer.answer; else tr.lastChild.innerHTML = ans.answer.answer;
@ -247,9 +280,10 @@ function displayEndScreen() {
tr.lastChild.innerHTML = ans.question.countryname tr.lastChild.innerHTML = ans.question.countryname
tr.appendChild(document.createElement('td')) tr.appendChild(document.createElement('td'))
if (guessFlag()) tr.lastChild.innerHTML = getImageURLFromCountryCode(ans.answer.code); if (guessFlag()) tr.lastChild.innerHTML = getImageURLFromCountryCode(ans.answer.code);
else tr.lastChild.innerHTML = ans.answer.answer; else tr.lastChild.innerHTML = ans.answer.capital;
correctAnswersTable.appendChild(tr); correctAnswersTable.appendChild(tr);
}) })
}
if (state.correctAnswers.length <= 0) if (state.correctAnswers.length <= 0)
correctAnswersTable.innerHTML = "no correct answers. better luck next time :')"; correctAnswersTable.innerHTML = "no correct answers. better luck next time :')";