Skip to content

Commit

Permalink
Fixed race condition causing index to fail to load
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGhostOfInky committed Mar 6, 2024
1 parent 0856a30 commit 7b6ffd6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions scripts/page-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@ import questions from "./questions.js"

const results = Object.values(questions)
.flatMap(q => Object.values(q.results)) // Get all results in a one dim array
.filter((r, i, arr)=> arr.indexOf(r)===i) // Remove repeated items
.filter((r, i, arr) => arr.indexOf(r) === i) // Remove repeated items

const langDropdown = document.getElementById("langDropdown")

langDropdown.addEventListener("change", ()=> {
langDropdown.addEventListener("change", () => {
location.href = `index.html?${langDropdown.value}`
})

i18n.$l10nLangs.forEach(lang => {
const selected = lang === i18n.$lang
langDropdown.innerHTML += `<option value="${lang}" ${selected&&"selected"}>${i18n.$l10nData[lang].lang_name}</option>`
langDropdown.innerHTML += `<option value="${lang}" ${selected && "selected"}>${i18n.$l10nData[lang].lang_name}</option>`
})

const textBody = document.getElementById("text_body")

textBody.innerHTML = i18n.ui_index_text
document.getElementById("title").innerHTML = i18n.ui_index_title
document.getElementById("text_body").innerHTML = i18n.ui_index_text
document.getElementById("startbutton").innerHTML = i18n.ui_index_start
document.getElementById("treebutton").innerHTML = i18n.ui_index_tree
document.getElementById("contacts").innerHTML = i18n.ui_index_contacts
document.getElementById("contacts_info").innerHTML = i18n.ui_index_contact_info
document.getElementById("startbutton").onclick = () => location.href = `quiz.html?${i18n.$lang}`
document.getElementById("treebutton").onclick = () => location.href = `tree.html?${i18n.$lang}`
document.getElementById("ideo_length").innerHTML = results.length
textBody.onload = () => {
document.getElementById("ideo_length").innerHTML = results.length
}

0 comments on commit 7b6ffd6

Please sign in to comment.