Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nathan #40

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Lab 5 - Starter

Danny Quang, Nathan Karter
30 changes: 28 additions & 2 deletions assets/scripts/explore.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,31 @@
window.addEventListener('DOMContentLoaded', init);

function init() {
// TODO
}

const synth = window.speechSynthesis;
let voices = [];

const voiceSelect = document.querySelector('select');
const inputTxt = document.querySelector('textarea');

function populateVoiceList() {

voices = synth.getVoices();

for (let i = 0; i < voices.length ; i++) {
const option = document.createElement('option');
option.textContent = `${voices[i].name} (${voices[i].lang})`;

if (voices[i].default) {
option.textContent += ' — DEFAULT';
}

option.setAttribute('data-lang', voices[i].lang);
option.setAttribute('data-name', voices[i].name);
voiceSelect.appendChild(option);
}
}

populateVoiceList();
alert(voices.length);
}
68 changes: 68 additions & 0 deletions assets/scripts/expose.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,72 @@ window.addEventListener('DOMContentLoaded', init);

function init() {
// TODO
const jsConfetti = new JSConfetti()
const selector = document.getElementById('horn-select');
selector.addEventListener('change', function() {
let option = selector.value;
//alert(option);
if (option == 'air-horn') {
document.querySelector('img').src = 'assets/images/air-horn.svg';
document.querySelector('audio').src = 'assets/audio/air-horn.mp3';
} else if (option == 'party-horn') {
document.querySelector('img').src = 'assets/images/party-horn.svg';
document.querySelector('audio').src = 'assets/audio/party-horn.mp3';
} else if (option == 'car-horn') {
document.querySelector('img').src = 'assets/images/car-horn.svg';
document.querySelector('audio').src = 'assets/audio/car-horn.mp3';
}
})

const sound = document.querySelector('button');
sound.addEventListener('click', function() {
let option = selector.value;
let music = null;
if (option == 'air-horn') {
music = new Audio('assets/audio/air-horn.mp3');
} else if (option == 'party-horn') {
music = new Audio('assets/audio/party-horn.mp3');

jsConfetti.addConfetti()
} else if (option == 'car-horn') {
music = new Audio('assets/audio/car-horn.mp3');
}
// const volume_controls = document.getElementsByClassName("img")[1];
// volume_controls.addEventListener('input', function() {
// alert(volume_controls.src);
// })

const volume_slider = document.getElementById('volume');
let volval = volume_slider.value;

const volIcon = document.getElementsByTagName("img")[1];
volume_slider.addEventListener('change', function(e) {
volval = e.currentTarget.value;
if (volval == 0) {
volIcon.src = 'assets/icons/volume-level-0.svg';
}
if (volval >=1 && volval < 33) {
volIcon.src = 'assets/icons/volume-level-1.svg';
}
if (volval >=33 && volval < 67) {
volIcon.src = 'assets/icons/volume-level-2.svg';
}
if (volval >=67) {
volIcon.src = 'assets/icons/volume-level-3.svg';
}
})

music.volume = volval/100;

music.play();
})



// const sound = document.querySelector('button');
// sound.addEventListener('click', function() {
// let option = selector.value;
// alert(option)
// })

}