Skip to content

Commit

Permalink
Update app.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaGriffiths11 authored Sep 12, 2024
1 parent 214df12 commit 48ebb11
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions src/assets/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ import SoundEffects from '@js/SoundEffects';
sunburstSvg.style.display = 'none';
};

/** Function to be trigger before spinning */
/** Function to be triggered before spinning */
const onSpinStart = () => {
stopWinningAnimation();
drawButton.disabled = true;
settingsButton.disabled = true;
soundEffects.spin((MAX_REEL_ITEMS - 1) / 10);
};

/** Functions to be trigger after spinning */
/** Functions to be triggered after spinning */
const onSpinEnd = async () => {
confettiAnimation();
sunburstSvg.style.display = 'block';
Expand All @@ -105,11 +105,13 @@ import SoundEffects from '@js/SoundEffects';
});

const getNames = async () => {
const res = await fetch('names.txt');
const names = await res.text();
const arr = names.split('\n');
for (let i = 0; i < arr.length; i++) {
slot.names.push(arr[i]);
try {
const res = await fetch('names.txt');
const names = await res.text();
const arr = names.split('\n').filter(name => name.trim());
slot.names = arr;
} catch (error) {
console.error('Error fetching names:', error);
}
};
getNames();
Expand Down Expand Up @@ -139,22 +141,19 @@ import SoundEffects from '@js/SoundEffects';
});

// Hide fullscreen button when it is not supported
if (!(document.documentElement.requestFullscreen && document.exitFullscreen)) {
if (!document.documentElement.requestFullscreen || !document.exitFullscreen) {
fullscreenButton.remove();
} else {
// Click handler for "Fullscreen" button
fullscreenButton.addEventListener('click', () => {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen();
} else if (document.exitFullscreen) {
document.exitFullscreen();
}
});
}

// Click handler for "Fullscreen" button
fullscreenButton.addEventListener('click', () => {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen();
return;
}

if (document.exitFullscreen) {
document.exitFullscreen();
}
});

// Click handler for "Settings" button
settingsButton.addEventListener('click', onSettingsOpen);

Expand Down

0 comments on commit 48ebb11

Please sign in to comment.