Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Unit Tests # name of the test

on: [push] # the Github Action will activate "on" the event that you "push" to the repo

jobs: # the things being executed
tests: # the name of your status check, will become important when you do branch protection
runs-on: ubuntu-latest # which device on Github's server that you are running the Actions on
steps:
- uses: actions/checkout@v4 # using version 4 of Actions
- name: Install Dependencies
run: npm install
- name: Unit Test
run: npm test ./__tests__/sum.test.js # the actual testing line
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
.DS_Store
node_modules/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Lab 5 - Starter

Name - Saksham Rai
65 changes: 61 additions & 4 deletions assets/scripts/expose.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,64 @@
// expose.js

window.addEventListener('DOMContentLoaded', init);

function init() {
// TODO
}
const imgElement = document.querySelector('img');
const hornSelect = document.getElementById('horn-select');
const volumeSlider = document.getElementById('volume');
const volumeIcon = document.querySelector('#volume-controls img');
const audioElement = document.querySelector('audio');
const playButton = document.querySelector('button');
const jsConfetti = new JSConfetti();

const hornData = {
'air-horn': {
img: 'assets/images/air-horn.svg',
sound: 'assets/audio/air-horn.mp3'
},
'car-horn': {
img: 'assets/images/car-horn.svg',
sound: 'assets/audio/car-horn.mp3'
},
'party-horn': {
img: 'assets/images/party-horn.svg',
sound: 'assets/audio/party-horn.mp3'
}
};

hornSelect.addEventListener('change', function () {
const selectedHorn = hornData[this.value];
if (selectedHorn) {
imgElement.src = selectedHorn.img;
imgElement.alt = `Image of ${this.value}`;
audioElement.src = selectedHorn.sound;
}
});

volumeSlider.addEventListener('input', function () {
const volume = parseInt(this.value, 10);
updateVolumeIcon(volume);
audioElement.volume = volume / 100.0;
});

function updateVolumeIcon(volume) {
if (volume === 0) {
volumeIcon.src = 'assets/icons/volume-level-0.svg';
volumeIcon.alt = 'Mute';
} else if (volume < 33) {
volumeIcon.src = 'assets/icons/volume-level-1.svg';
volumeIcon.alt = 'Low volume';
} else if (volume < 67) {
volumeIcon.src = 'assets/icons/volume-level-2.svg';
volumeIcon.alt = 'Medium volume';
} else {
volumeIcon.src = 'assets/icons/volume-level-3.svg';
volumeIcon.alt = 'High volume';
}
}

playButton.addEventListener('click', function () {
if (hornSelect.value === 'party-horn') {
jsConfetti.addConfetti();
}
audioElement.play();
});
}
Loading