Skip to content

Commit

Permalink
Add sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
gurbaxani committed Sep 15, 2024
1 parent 39ade33 commit 988ce55
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
19 changes: 18 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
document.addEventListener('DOMContentLoaded', function () {
// Elements for random suggestions
// Elements for random suggestions
const resultDiv = document.getElementById('result');
const objects = ['Book', 'Chair', 'Laptop', 'Pen', 'Phone', 'Sock', 'Table', 'Umbrella', 'Wallet', 'Watch'];
const relationships = ['Friend', 'Parent', 'Sibling', 'Colleague', 'Neighbor', 'Partner', 'Mentor', 'Student', 'Boss', 'Customer'];
Expand Down Expand Up @@ -79,4 +79,21 @@ document.addEventListener('DOMContentLoaded', function () {

// Initial display update for the timer
updateDisplay();

// Add sound effect functionality
const bellSound = new Audio('sounds/bell.mp3'); // Update the path as needed

resultDiv.addEventListener('click', function() {
bellSound.currentTime = 0; // Restart the audio from the beginning
bellSound.play(); // Play the sound effect
});

const buzzerSound = new Audio('sounds/buzzer.mp3');

timerDisplay.addEventListener('click', function() {
buzzerSound.currentTime = 0;
buzzerSound.play();
});


});
Binary file added sounds/bell.mp3
Binary file not shown.
Binary file added sounds/buzzer.mp3
Binary file not shown.
4 changes: 4 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@
height: 40px;
transition: background-color 0.3s ease; /* Smooth transition for hover effect */
}

#result {
cursor: pointer; /* Change cursor to indicate it's clickable */
}

0 comments on commit 988ce55

Please sign in to comment.