Archived
74 lines
2.4 KiB
JavaScript
74 lines
2.4 KiB
JavaScript
"use strict"
|
|
|
|
const bingo_items = [
|
|
{"title": "Punainen villakangastakki", "tooltip": ""},
|
|
{"title": "Keskeytetty suudelma", "tooltip": "" },
|
|
{"title": "Miespääosa yh", "tooltip": "" },
|
|
{"title": "Leskimies", "tooltip": "" },
|
|
{"title": "Jouluoksennus", "tooltip": "" },
|
|
{"title": "Evergreen", "tooltip": "" },
|
|
{"title": "Yritys pulassa", "tooltip": "" },
|
|
{"title": "Naispääosa pitkä blondi", "tooltip": "" },
|
|
{"title": "Joulumörkö", "tooltip": "" },
|
|
{"title": "Pääosa jumissa", "tooltip": "" },
|
|
{"title": "Kantakahvila", "tooltip": "" },
|
|
{"title": "Majatalo", "tooltip": "" },
|
|
{"title": "Miespääosa eräjorma", "tooltip": "" },
|
|
{"title": "Työkriisi", "tooltip": "" },
|
|
{"title": "Kylän joulutapahtuma", "tooltip": "" },
|
|
{"title": "Naispääosa kaupungista", "tooltip": "" },
|
|
{"title": "Naispääosan tuore ero", "tooltip": "" },
|
|
{"title": "Suuri salaisuus", "tooltip": "" },
|
|
{"title": "Himo jouluttaja", "tooltip": "" },
|
|
{"title": "Kuusen valinta", "tooltip": "" },
|
|
{"title": "Täysikuu", "tooltip": "" },
|
|
{"title": "Kuuma kaakao", "tooltip": "" },
|
|
{"title": "Punainen lava-auto", "tooltip": "" }
|
|
]
|
|
|
|
function shuffle(array) {
|
|
let currentIndex = array.length,
|
|
randomIndex;
|
|
|
|
// While there remain elements to shuffle.
|
|
while (currentIndex != 0) { // Pick a remaining element.
|
|
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
currentIndex--;
|
|
|
|
// And swap it with the current element.
|
|
[
|
|
array[currentIndex], array[randomIndex]
|
|
] = [
|
|
array[randomIndex], array[currentIndex]
|
|
];
|
|
}
|
|
|
|
return array;
|
|
}
|
|
|
|
window.onload = function () {
|
|
let shuffled_list = shuffle(bingo_items)
|
|
let i = 1
|
|
|
|
for (i = 1; i < 10; i ++) {
|
|
let button = document.getElementById("grid-item-" + i)
|
|
button.textContent = shuffled_list[i]["title"]
|
|
// console.log(button.textContent)
|
|
}
|
|
|
|
}
|
|
|
|
function toggle_button(button_id) {
|
|
let button = document.getElementById("grid-item-" + button_id)
|
|
// let status = button.className
|
|
let current_status = button.classList[1]
|
|
if (current_status == "item-button-norm") {
|
|
button.classList.remove("item-button-norm")
|
|
button.classList.add("item-button-pressed")
|
|
} else {
|
|
button.classList.remove("item-button-pressed")
|
|
button.classList.add("item-button-norm")
|
|
}
|
|
|
|
}
|