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

82
game.js
View File

@ -220,36 +220,70 @@ 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>";
}
state.incorrectAnswers.forEach(ans => { if (guessReverseFlag()) {
var tr = document.createElement('tr'); state.incorrectAnswers.forEach(ans => {
console.log(ans) var tr = document.createElement('tr');
console.log(ans)
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.appendChild(document.createElement('td'))
if (guessFlag()) tr.lastChild.innerHTML = getImageURLFromCountryCode(ans.answer.code); tr.lastChild.innerHTML = getImageURLFromCountryCode(ans.answer.code);
else tr.lastChild.innerHTML = ans.answer.answer;
tr.appendChild(document.createElement('td')) tr.appendChild(document.createElement('td'))
if (guessFlag()) tr.lastChild.innerHTML = getImageURLFromCountryCode(ans.options[ans.userAnswer].code); tr.lastChild.innerHTML = getImageURLFromCountryCode(ans.options[ans.userAnswer].code);
else tr.lastChild.innerHTML = ans.options[ans.userAnswer].answer;
incorrectAnswersTable.appendChild(tr); incorrectAnswersTable.appendChild(tr);
}) })
if (state.incorrectAnswers.length <= 0) if (state.incorrectAnswers.length <= 0)
incorrectAnswersTable.innerHTML = "no incorrect answers! go you!"; incorrectAnswersTable.innerHTML = "no incorrect answers! go you!";
state.correctAnswers.forEach(ans => { state.correctAnswers.forEach(ans => {
var tr = document.createElement('tr'); var tr = document.createElement('tr');
tr.appendChild(document.createElement('td')) tr.appendChild(document.createElement('td'))
tr.lastChild.innerHTML = ans.question.countryname tr.lastChild.innerHTML = getImageURLFromCountryCode(ans.question.code);
tr.appendChild(document.createElement('td')) tr.appendChild(document.createElement('td'))
if (guessFlag()) tr.lastChild.innerHTML = getImageURLFromCountryCode(ans.answer.code); tr.lastChild.innerHTML = ans.answer.countryname;
else tr.lastChild.innerHTML = ans.answer.answer; correctAnswersTable.appendChild(tr);
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'))
if (guessFlag()) tr.lastChild.innerHTML = getImageURLFromCountryCode(ans.answer.code);
else tr.lastChild.innerHTML = ans.answer.answer;
tr.appendChild(document.createElement('td'))
if (guessFlag()) tr.lastChild.innerHTML = getImageURLFromCountryCode(ans.options[ans.userAnswer].code);
else tr.lastChild.innerHTML = ans.options[ans.userAnswer].answer;
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 = ans.question.countryname
tr.appendChild(document.createElement('td'))
if (guessFlag()) tr.lastChild.innerHTML = getImageURLFromCountryCode(ans.answer.code);
else tr.lastChild.innerHTML = ans.answer.capital;
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 :')";