let song;
let pointCount = 0;
document.addEventListener('keydown', function(event) {
if (event.key === 'Enter') {
document.getElementById('myButton').click();
}
});
/*function addPoint() {
pointCount ++;
document.getElementById('points').
}*/
function playRandomDisneySong() {
document.getElementById('triviaAnswer').value = '';
document.getElementById('output').textContent = '';
const songFolder = 'Disney Songs';
const songs = [
'101 Dalmatians/cruella_de_vil.mp3',
'101 Dalmatians/dalmatian_plantation.mp3',
'101 Dalmatians/kanine_krunchies.mp3',
'Aladdin/a_whole_new_world.mp3',
'Aladdin/arabian_nights.mp3',
'Aladdin/friend_like_me.mp3',
'Aladdin/one_jump_ahead.mp3',
'Aladdin/prince_ali.mp3',
'Aladdin/speechless.mp3',
'Alice In Wonderland/im_late.mp3',
'Alice In Wonderland/main_title.mp3',
'Alice In Wonderland/the_unbirthday_song.mp3',
'Alice In Wonderland/the_walrus_and_the_carpenter.mp3',
'Atlantis The Lost Empire/main_title.mp3',
'Bambi/lets_sing_a_gay_little_spring_song.mp3',
'Bambi/little_april_shower.mp3',
'Bambi/where_the_dream_takes_you.mp3',
'Beauty And The Beast/aria.mp3',
'Beauty And The Beast/beauty_and_the_beast_finale.mp3',
'Beauty And The Beast/beauty_and_the_beast.mp3',
'Beauty And The Beast/belle_reprise.mp3',
'Beauty And The Beast/belle.mp3',
'Beauty And The Beast/days_in_the_sun.mp3',
'Beauty And The Beast/evermore.mp3',
'Beauty And The Beast/gaston.mp3',
'Beauty And The Beast/how_does_a_moment_last_forever_montmartre.mp3',
'Beauty And The Beast/how_does_a_moment_last_forever.mp3',
'Beauty And The Beast/something_there.mp3',
'Beauty And The Beast/the_mob_song.mp3',
'Big Hero 6/immortals.mp3',
'Bolt/barking_at_the_moon.mp3',
'Bolt/i_thought_i_lost_you.mp3',
'Brother Bear/great_spirits.mp3',
'Brother Bear/look_through_my_eyes.mp3',
'Brother Bear/no_way_out.mp3',
'Brother Bear/on_my_way.mp3',
'Brother Bear/transformation.mp3',
'Brother Bear/welcome.mp3',
'Chicken Little/aint_no_mountain_high_enough.mp3',
'Chicken Little/all_i_know.mp3',
'Chicken Little/its_the_end_of_the_world_as_we_know_it.mp3',
'Chicken Little/one_little_slip.mp3',
'Chicken Little/shake_a_tail_feather.mp3',
'Chicken Little/stir_it_up.mp3',
];
const randomIndex = Math.floor(Math.random() * songs.length);
const randomSong = songs[randomIndex];
const audioPlayer = document.getElementById('audioPlayer');
const audioSource = document.getElementById('audioSource');
audioSource.src = `${songFolder}/${randomSong}`;
audioPlayer.load();
audioPlayer.play();
song = randomSong.toLowerCase();
}
// Automatically play a random Disney song when the page loads
window.onload = playRandomDisneySong;
function checkAnswer(){
const inputField = document.getElementById('triviaAnswer').value;
const index = song.indexOf('/');
const nameMovie = song.substring(0, index);
const outputElement = document.getElementById('output');
if(inputField.toLowerCase() == nameMovie){
pointCount = pointCount + 1;
outputElement.textContent = 'You are correct!';
document.getElementById('audioPlayer').pause();
document.getElementById('points').textContent = 'Points: ' + pointCount;
setTimeout(playRandomDisneySong, 5000);
}else{
pointCount --;
outputElement.textContent = 'You are incorrect!';
document.getElementById('triviaAnswer').value = '';
document.getElementById('points').textContent = 'Points: ' + pointCount;
}
}
function toggleButton() {
var button = document.getElementById('playButton');
if (button.classList.contains('play')) {
button.classList.remove('play');
button.innerHTML = '▌▌'; // Unicode for pause symbol
document.getElementById('audioPlayer').play();
} else {
button.classList.add('play');
button.innerHTML = '►'; // Unicode for play symbol
document.getElementById('audioPlayer').pause();
}
}
top of page
bottom of page