From 2de2047050c80621c4ed4dc065a0cd56c1fce8f7 Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Wed, 21 Dec 2016 08:14:04 -0600 Subject: [PATCH 01/41] Update script in html for drum kit and update styling --- 01 - JavaScript Drum Kit/index-START.html | 19 +++++++++++++++++++ 01 - JavaScript Drum Kit/style.css | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..65f5dd6e73 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -59,6 +59,25 @@ diff --git a/01 - JavaScript Drum Kit/style.css b/01 - JavaScript Drum Kit/style.css index 3e0a320b37..6798a9fe16 100644 --- a/01 - JavaScript Drum Kit/style.css +++ b/01 - JavaScript Drum Kit/style.css @@ -28,7 +28,7 @@ body,html { text-align: center; color:white; background:rgba(0,0,0,0.4); - text-shadow:0 0 5px black; + text-shadow: 0 0 5px black; } .playing { From 8aaebc5e671488fbb91f143830ea47acc25e49c5 Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Wed, 21 Dec 2016 09:03:10 -0600 Subject: [PATCH 02/41] Add getDate for clock functionality and style for transforms --- 02 - JS + CSS Clock/index-START.html | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..339f96763b 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -61,12 +61,40 @@ background:black; position: absolute; top:50%; + transform-origin: 100%; /*Changes the origin the transform will pivot from to the far right*/ + transform: rotate(90deg); /*So the clock starts at 12:00*/ + transition: all 0.05s; + transition-timing-function: cubic-bezier(0, 1.66, 0.58, 1); } From 26009cf0cd6be5b414fd505d635a4b75480fad89 Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Tue, 27 Dec 2016 13:28:55 -0600 Subject: [PATCH 03/41] Add functionality to CSS variables. --- 03 - CSS Variables/index-START.html | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index 7171607a8b..d317850551 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -21,6 +21,21 @@

Update CSS Variables with JS

From 9121c3b414a9def61b32330369890be3aaccc008 Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Wed, 28 Dec 2016 21:10:05 -0600 Subject: [PATCH 04/41] Completed cardio Day excercises --- 04 - Array Cardio Day 1/index-START.html | 54 +++++++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 4162bce339..105ce17126 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -33,28 +33,78 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + const bornIn1500s = inventors.filter(inventor => { + return inventor.year >= 1500 && inventor.year < 1600 ? inventor : ''; + }); + + console.table(bornIn1500s); // Array.prototype.map() // 2. Give us an array of the inventors' first and last names + const fullName = inventors.map(inventor => { + return `${inventor.first} ${inventor.last}`; + }); + + console.log('+++++++++++++++'); + console.log(fullName); // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + const firstBorn = inventors.sort((a, b) => a.year > b.year ? 1 : -1); + + console.log('+++++++++++++++'); + console.log(firstBorn); // Array.prototype.reduce() // 4. How many years did all the inventors live? + const totalYears = inventors.reduce((sum, inventor) => { + return sum + (inventor.passed - inventor.year); + }, 0); + + console.log(totalYears); // 5. Sort the inventors by years lived + const oldestFirst = inventors.sort((a, b) => { + a.yearsLived = (a.passed - a.year); + b.yearsLived = (b.passed - b.year); + return (a.passed - a.year) < (b.passed - b.year) ? 1 : -1; + }); + + console.log('+++++++++++++++'); + console.table(oldestFirst); // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name // https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris - + // const category = document.querySelector('.mw-category'); + // const links = [...category.querySelectorAll('a')]; + // const de = links + // .map(link => link.textContent) + // .filter(streetName => streetName.includes('de')); // 7. sort Exercise // Sort the people alphabetically by last name + const alphabeticSort = people.sort((prev, next) => { + const [ prevLast, prevFirst ] = prev.split(', '); + const [ nextLast, nextFirst ] = next.split(', '); + return prevLast > nextLast ? 1 : -1; + }); + console.log('+++++++++++++++'); + console.log(alphabeticSort); // 8. Reduce Exercise // Sum up the instances of each of these - const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ]; + const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'tricycle', 'tricycle', 'bike', 'walk', 'car', 'van', 'car', 'truck' ]; + + const transportation = data.reduce((obj, item) => { + if (!obj[item]) { + obj[item] = 0; + } + + obj[item]++; + return obj; + }, {}); + + console.log(transportation); From 9c8be9d09534aac8dc23ae6a35f8e4117b4dcd85 Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Thu, 29 Dec 2016 16:01:37 -0600 Subject: [PATCH 05/41] coded panel gallery based off excercise --- 05 - Flex Panel Gallery/index-START.html | 42 ++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index e1d643ad5c..611cccb6d0 100644 --- a/05 - Flex Panel Gallery/index-START.html +++ b/05 - Flex Panel Gallery/index-START.html @@ -22,13 +22,14 @@ } .panels { - min-height:100vh; + height:100vh; overflow: hidden; + display: flex; } .panel { background:#6B0F9C; - box-shadow:inset 0 0 0 5px rgba(255,255,255,0.1); + box-shadow:inset 0 0 0 2px rgba(255,255,255,0.2); color:white; text-align: center; align-items:center; @@ -41,6 +42,11 @@ font-size: 20px; background-size:cover; background-position:center; + flex: 1; + justify-content: center; + align-items: center; + display: flex; + flex-direction: column; } @@ -50,12 +56,23 @@ .panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); } .panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); } + /* flex children */ .panel > * { margin:0; width: 100%; transition:transform 0.5s; + /*border: 1px solid red;*/ + flex: 1 0 auto; + display: flex; + justify-content: center; + align-items: center; } + .panel > *:first-child { transform: translateY(-100%); } + .panel.open-active > *:first-child { transform: translateY(0); } + .panel > *:last-child { transform: translateY(100%); } + .panel.open-active > *:last-child { transform: translateY(0); } + .panel p { text-transform: uppercase; font-family: 'Amatic SC', cursive; @@ -68,6 +85,7 @@ .panel.open { font-size:40px; + flex: 5; } .cta { @@ -107,6 +125,26 @@ From ec5fe24081b89d98df350688655280d155855b22 Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Sat, 31 Dec 2016 12:20:25 -0600 Subject: [PATCH 06/41] Completed coding excercise, everything works as it should --- 06 - Type Ahead/index-START.html | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 1436886918..cfa10c96aa 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -17,6 +17,44 @@ From 1a1eda0e9ae8ebbe963a1c599a9c5b7df8286a3a Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Sat, 31 Dec 2016 13:36:40 -0600 Subject: [PATCH 07/41] completed challengefor arrays. --- 07 - Array Cardio Day 2/index-START.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 206ec31aa0..55769eb755 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -26,15 +26,30 @@ // Some and Every Checks // Array.prototype.some() // is at least one person 19? + const isAdult = people.some( person => ((new Date()).getFullYear()) - person.year >= 19 ); + + console.log({isAdult}); // Array.prototype.every() // is everyone 19? + const allAdults = people.every( person => ((new Date()).getFullYear()) - person.year >= 19 ); + + console.log({allAdults}); // Array.prototype.find() // Find is like filter, but instead returns just the one you are looking for // find the comment with the ID of 823423 + const comment = comments.find(comment => comment.id === 823423); + console.log({comment}); // Array.prototype.findIndex() // Find the comment with this ID // delete the comment with the ID of 823423 + const index = comments.findIndex(comment => comment.id === 823423); + console.log(index); + + const newComments = [ + ...comments.slice(0, index), + ...comments.slice(index + 1) + ]; From 45d3079897bb59188b2ebd6f1eb95d8d66bd6a24 Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Sat, 31 Dec 2016 16:19:48 -0600 Subject: [PATCH 08/41] Completed excercise. --- 08 - Fun with HTML5 Canvas/index-START.html | 49 +++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html index 37c148df07..5e4a2590f5 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -7,6 +7,55 @@ From 2c124c2698a2bd4e6a8a4f151466948d900827f5 Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Wed, 4 Jan 2017 12:38:15 -0600 Subject: [PATCH 20/41] Completed challenge to strip and sort names --- 17 - Sort Without Articles/index-START.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/17 - Sort Without Articles/index-START.html b/17 - Sort Without Articles/index-START.html index cfaf3e0440..aac7ecd66b 100644 --- a/17 - Sort Without Articles/index-START.html +++ b/17 - Sort Without Articles/index-START.html @@ -45,6 +45,16 @@ From ecf22dfcdb67422aa5eebd5759d80f1c4f7be39e Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Fri, 6 Jan 2017 15:00:56 -0600 Subject: [PATCH 21/41] Completed Excercise. --- .../index-START.html | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/18 - Adding Up Times with Reduce/index-START.html b/18 - Adding Up Times with Reduce/index-START.html index 3eaee0f3ef..01680b82e1 100644 --- a/18 - Adding Up Times with Reduce/index-START.html +++ b/18 - Adding Up Times with Reduce/index-START.html @@ -182,6 +182,25 @@ From cba54cf21094c0750fc55c8a50b711755434214a Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Wed, 11 Jan 2017 17:42:53 -0600 Subject: [PATCH 22/41] Completed Excercise. --- 21 - Geolocation/index-START.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/21 - Geolocation/index-START.html b/21 - Geolocation/index-START.html index d794c144ba..bd523c1d7c 100644 --- a/21 - Geolocation/index-START.html +++ b/21 - Geolocation/index-START.html @@ -65,8 +65,8 @@

speed.textContent = data.coords.speed; arrow.style.transform = `rotate(${data.coords.heading}deg)`; }, (err) => { - console.err(err); - alert('HEY! YOU GOTTA ALLOW THAT TO HAPPEN!!!'); + console.log(err); + alert("IT'S TIME TO GROW UP AND ACCEPT IT!!!"); }); From ff4f4292bb777bdda0f563124d9a4cc785276495 Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Wed, 11 Jan 2017 17:46:26 -0600 Subject: [PATCH 23/41] completed excercise. --- 10 - Hold Shift and Check Checkboxes/index-START.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/10 - Hold Shift and Check Checkboxes/index-START.html b/10 - Hold Shift and Check Checkboxes/index-START.html index 6fc6d6a9a3..854d569075 100644 --- a/10 - Hold Shift and Check Checkboxes/index-START.html +++ b/10 - Hold Shift and Check Checkboxes/index-START.html @@ -105,7 +105,7 @@ From f2ff9546c5773231a704848684cd6930f9e37e5c Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Fri, 13 Jan 2017 13:52:47 -0600 Subject: [PATCH 26/41] Completed Excercise. --- 20 - Speech Detection/index-START.html | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/20 - Speech Detection/index-START.html b/20 - Speech Detection/index-START.html index d3395cca35..d6e4f6b9a4 100644 --- a/20 - Speech Detection/index-START.html +++ b/20 - Speech Detection/index-START.html @@ -12,6 +12,31 @@ From 461620985a92ad5725671f967018e1c035dbcb35 Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Sat, 14 Jan 2017 16:21:55 -0600 Subject: [PATCH 27/41] Started excercise and committing to pull to another machine. --- 23 - Speech Synthesis/index-START.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/23 - Speech Synthesis/index-START.html b/23 - Speech Synthesis/index-START.html index e890008d36..e5a5579ec1 100644 --- a/23 - Speech Synthesis/index-START.html +++ b/23 - Speech Synthesis/index-START.html @@ -35,6 +35,8 @@

The Voiceinator 5000

const options = document.querySelectorAll('[type="range"], [name="text"]'); const speakButton = document.querySelector('#speak'); const stopButton = document.querySelector('#stop'); + + msg.text = document.querySelector('[name="text"]').value; From 1166cce4e6b80453d575c3210ccafe587fc8e18f Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Sat, 14 Jan 2017 17:37:44 -0600 Subject: [PATCH 28/41] Completed excercies. Feeling fit. --- 23 - Speech Synthesis/index-START.html | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/23 - Speech Synthesis/index-START.html b/23 - Speech Synthesis/index-START.html index e890008d36..0bf4bde38e 100644 --- a/23 - Speech Synthesis/index-START.html +++ b/23 - Speech Synthesis/index-START.html @@ -35,6 +35,39 @@

The Voiceinator 5000

const options = document.querySelectorAll('[type="range"], [name="text"]'); const speakButton = document.querySelector('#speak'); const stopButton = document.querySelector('#stop'); + msg.text = document.querySelector('[name="text"]').value; + + function populateVoices() { + voices = this.getVoices(); + voicesDropdown.innerHTML = voices + .filter(voice => voice.lang.includes('en')) + .map(voice => ``) + .join(''); + } + + function setVoice() { + msg.voice = voices.find(voice => voice.name === this.value); + toggle(); + } + + function toggle(startOver = true) { + speechSynthesis.cancel(); + if (startOver) { + speechSynthesis.speak(msg); + } + } + + function setOption() { + console.log(this.name, this.value); + msg[this.name] = this.value; + toggle(); + } + + speechSynthesis.addEventListener('voiceschanged', populateVoices); + voicesDropdown.addEventListener('change', setVoice); + options.forEach(option => option.addEventListener('change', setOption)); + speakButton.addEventListener('click', toggle); + stopButton.addEventListener('click', () => toggle(false)); From 2634f40babb3cc56c19b0b287698f372b91caa75 Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Sun, 15 Jan 2017 12:17:03 -0600 Subject: [PATCH 29/41] Updated script for sticky nav excercise. --- 24 - Sticky Nav/index-START.html | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/24 - Sticky Nav/index-START.html b/24 - Sticky Nav/index-START.html index e7bc67e9a5..4b2b1993ef 100644 --- a/24 - Sticky Nav/index-START.html +++ b/24 - Sticky Nav/index-START.html @@ -54,7 +54,18 @@

A story about getting lost.

From d1a5d946ba79c8161022e2feb129adb6f275865e Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Sun, 15 Jan 2017 13:08:19 -0600 Subject: [PATCH 30/41] Completed sticky nav excercise. --- 24 - Sticky Nav/index-START.html | 2 ++ 24 - Sticky Nav/style-START.css | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/24 - Sticky Nav/index-START.html b/24 - Sticky Nav/index-START.html index 4b2b1993ef..065f22947a 100644 --- a/24 - Sticky Nav/index-START.html +++ b/24 - Sticky Nav/index-START.html @@ -59,8 +59,10 @@

A story about getting lost.

function fixNav() { if (window.scrollY >= topOfNav) { + document.body.style.paddingTop = nav.offsetHeight + 'px'; document.body.classList.add('fixed-nav'); } else { + document.body.style.paddingTop = 0; document.body.classList.remove('fixed-nav'); } } diff --git a/24 - Sticky Nav/style-START.css b/24 - Sticky Nav/style-START.css index c6d59a31b3..a3db8925c4 100644 --- a/24 - Sticky Nav/style-START.css +++ b/24 - Sticky Nav/style-START.css @@ -23,6 +23,10 @@ body { transition: transform 0.5s; } +.fixed-nav .site-wrap { + transform: scale(1); +} + header { text-align: center; height:50vh; @@ -48,6 +52,11 @@ nav { z-index: 1; } +.fixed-nav nav { + position: fixed; + box-shadow: 0 5px rgba(0,0,0,0.1); +} + nav ul { margin: 0; padding:0; @@ -72,6 +81,10 @@ li.logo { font-size: 30px; } +.fixed-nav li.logo { + max-width: 500px; +} + li.logo a { color:black; } From 329ac07dfaaaf1c6c1a90646c7a307656f2a169d Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Sun, 15 Jan 2017 13:11:57 -0600 Subject: [PATCH 31/41] Merged from separate computer. --- 20 - Speech Detection/index-START.html | 25 ++++++++++++++++++ 23 - Speech Synthesis/index-START.html | 36 ++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/20 - Speech Detection/index-START.html b/20 - Speech Detection/index-START.html index d3395cca35..d6e4f6b9a4 100644 --- a/20 - Speech Detection/index-START.html +++ b/20 - Speech Detection/index-START.html @@ -12,6 +12,31 @@ diff --git a/23 - Speech Synthesis/index-START.html b/23 - Speech Synthesis/index-START.html index e5a5579ec1..76f7ba39d4 100644 --- a/23 - Speech Synthesis/index-START.html +++ b/23 - Speech Synthesis/index-START.html @@ -35,8 +35,44 @@

The Voiceinator 5000

const options = document.querySelectorAll('[type="range"], [name="text"]'); const speakButton = document.querySelector('#speak'); const stopButton = document.querySelector('#stop'); +<<<<<<< HEAD msg.text = document.querySelector('[name="text"]').value; +======= + msg.text = document.querySelector('[name="text"]').value; + + function populateVoices() { + voices = this.getVoices(); + voicesDropdown.innerHTML = voices + .filter(voice => voice.lang.includes('en')) + .map(voice => ``) + .join(''); + } + + function setVoice() { + msg.voice = voices.find(voice => voice.name === this.value); + toggle(); + } + + function toggle(startOver = true) { + speechSynthesis.cancel(); + if (startOver) { + speechSynthesis.speak(msg); + } + } + + function setOption() { + console.log(this.name, this.value); + msg[this.name] = this.value; + toggle(); + } + + speechSynthesis.addEventListener('voiceschanged', populateVoices); + voicesDropdown.addEventListener('change', setVoice); + options.forEach(option => option.addEventListener('change', setOption)); + speakButton.addEventListener('click', toggle); + stopButton.addEventListener('click', () => toggle(false)); +>>>>>>> 1166cce4e6b80453d575c3210ccafe587fc8e18f From 812bff9481604939693f5be0bef84396d065c1b0 Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Sun, 15 Jan 2017 19:20:58 -0600 Subject: [PATCH 32/41] completed capturing and propogation excercise. --- .../index-START.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/25 - Event Capture, Propagation, Bubbling and Once/index-START.html b/25 - Event Capture, Propagation, Bubbling and Once/index-START.html index 98f5e070c4..3b4b662e9c 100644 --- a/25 - Event Capture, Propagation, Bubbling and Once/index-START.html +++ b/25 - Event Capture, Propagation, Bubbling and Once/index-START.html @@ -39,7 +39,17 @@ From e89b578eb9649dc34d46bcebc48dedf5a55f41da Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Mon, 16 Jan 2017 12:14:09 -0600 Subject: [PATCH 33/41] Coded a replica of Stripes follow along nav. --- 26 - Stripe Follow Along Nav/index-START.html | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/26 - Stripe Follow Along Nav/index-START.html b/26 - Stripe Follow Along Nav/index-START.html index 9780d0d1ac..e251da9469 100644 --- a/26 - Stripe Follow Along Nav/index-START.html +++ b/26 - Stripe Follow Along Nav/index-START.html @@ -134,8 +134,6 @@

Cool

opacity: 1; } - - .dropdownBackground { width:100px; height:100px; @@ -208,6 +206,39 @@

Cool

From f62c5aa3928dd4d72140ab6252c51862db852b0c Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Mon, 16 Jan 2017 12:19:07 -0600 Subject: [PATCH 34/41] Added short circuit in setTimeout to fix nav containment issues. --- 26 - Stripe Follow Along Nav/index-START.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/26 - Stripe Follow Along Nav/index-START.html b/26 - Stripe Follow Along Nav/index-START.html index e251da9469..b398dd4c8d 100644 --- a/26 - Stripe Follow Along Nav/index-START.html +++ b/26 - Stripe Follow Along Nav/index-START.html @@ -212,7 +212,7 @@

Cool

function handleEnter() { this.classList.add('trigger-enter'); - setTimeout(() => this.classList.add('trigger-enter-active'), 150); + setTimeout(() => this.classList.contains('trigger-enter') && this.classList.add('trigger-enter-active'), 150); background.classList.add('open'); const dropdown = this.querySelector('.dropdown'); From 6d28ff28d33dd1b879aa223f99f5763ed5c051b4 Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Tue, 17 Jan 2017 10:43:10 -0600 Subject: [PATCH 35/41] Completed click and drag challenge. --- 27 - Click and Drag/index-START.html | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/27 - Click and Drag/index-START.html b/27 - Click and Drag/index-START.html index b8609315f7..7a3561f946 100644 --- a/27 - Click and Drag/index-START.html +++ b/27 - Click and Drag/index-START.html @@ -35,6 +35,35 @@ From 79e52b339f8fcc38b0a2605d5aad35533cce5dc3 Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Tue, 17 Jan 2017 15:43:20 -0600 Subject: [PATCH 36/41] Completed Video Speed Controller excercise. --- 28 - Video Speed Controller/index-START.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/28 - Video Speed Controller/index-START.html b/28 - Video Speed Controller/index-START.html index c4cbd4259a..39baca7d65 100644 --- a/28 - Video Speed Controller/index-START.html +++ b/28 - Video Speed Controller/index-START.html @@ -15,6 +15,23 @@ From 457f91a379d0e0a0d0955b35a678274e8ac00b1c Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Tue, 17 Jan 2017 15:51:11 -0600 Subject: [PATCH 37/41] Fix syntax error in event listener. --- 11 - Custom Video Player/scripts.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/11 - Custom Video Player/scripts.js b/11 - Custom Video Player/scripts.js index 0c0e8bb0bb..8ca475248a 100644 --- a/11 - Custom Video Player/scripts.js +++ b/11 - Custom Video Player/scripts.js @@ -46,9 +46,10 @@ video.addEventListener('timeupdate', handleProgress); toggle.addEventListener('click', togglePlay); skipButtons.forEach(button => button.addEventListener('click', skip)); ranges.forEach(range => range.addEventListener('change', handleRangeUpdate)); +ranges.forEach(range => range.addEventListener('mousemove', handleRangeUpdate)); let mouseDown = false; progress.addEventListener('click', scrub); -progress.addEventListener('mousemove', (e) => mouseDown && scrub(e)}); -progress.addEventListener('mousedown', () => mouseDown = true); -progress.addEventListener('mouseup', () => mouseDown = false); \ No newline at end of file +progress.addEventListener('mousemove', (e) => mousedown && scrub(e)); +progress.addEventListener('mousedown', () => mousedown = true); +progress.addEventListener('mouseup', () => mousedown = false); \ No newline at end of file From f81aa55f8bf56a7e6bc03ffa4c298a0abbce269b Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Sat, 21 Jan 2017 09:03:27 -0600 Subject: [PATCH 38/41] Create timer func to handle countdown. --- 29 - Countdown Timer/scripts-START.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/29 - Countdown Timer/scripts-START.js b/29 - Countdown Timer/scripts-START.js index e69de29bb2..afb97f3949 100644 --- a/29 - Countdown Timer/scripts-START.js +++ b/29 - Countdown Timer/scripts-START.js @@ -0,0 +1,20 @@ +let countdown; + +function timer(seconds) { + const now = Date.now(); + const then = now + seconds * 1000; + displayTimeLeft(seconds); + + countdown = setInterval(() => { + const secondsLeft = Math.round((then - Date.now()) / 1000); + if(secondsLeft < 0) { + clearInterval(countdown); + return; + } + displayTimeLeft(secondsLeft); + }, 1000); +} + +function displayTimeLeft(seconds) { + console.log(seconds); +} \ No newline at end of file From 001696f3ccc594174541c33cae178d0509c2be8f Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Sat, 21 Jan 2017 09:33:12 -0600 Subject: [PATCH 39/41] add funcs for displaying time left and end time. --- 29 - Countdown Timer/scripts-START.js | 29 ++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/29 - Countdown Timer/scripts-START.js b/29 - Countdown Timer/scripts-START.js index afb97f3949..a25e791a52 100644 --- a/29 - Countdown Timer/scripts-START.js +++ b/29 - Countdown Timer/scripts-START.js @@ -1,9 +1,15 @@ let countdown; +const timerDisplay = document.querySelector('.display__time-left'); +const endTime = document.querySelector('.display__end-time'); +const buttons = document.querySelectorAll('[data-time]'); function timer(seconds) { + // Clear any existing timers + clearInterval(countdown); const now = Date.now(); const then = now + seconds * 1000; displayTimeLeft(seconds); + displayEndTime(then); countdown = setInterval(() => { const secondsLeft = Math.round((then - Date.now()) / 1000); @@ -16,5 +22,26 @@ function timer(seconds) { } function displayTimeLeft(seconds) { + const minutes = Math.floor(seconds / 60); + const remainderSeconds = seconds % 60; + const display = `${minutes}:${remainderSeconds < 10 ? '0' : ''}${remainderSeconds}`; + document.title = display; + timerDisplay.textContent = display; +} + +function displayEndTime(timestamp) { + const end = new Date(timestamp); + const hour = end.getHours(); + const adjustedHour = hour > 12 ? hour - 12 : hour; + const minutes = end.getMinutes(); + const adjustedMinutes = minutes < 10 ? '0' : ''; + endTime.textContent = `The world ends at ${adjustedHour}:${adjustedMinutes}${minutes}`; +} + +function startTimer() { + const seconds = parseInt(this.dataset.time); + timer(seconds); console.log(seconds); -} \ No newline at end of file +} + +buttons.forEach(button => button.addEventListener('click', startTimer)); From 5da8ddd5d76beb8bc625592e7f646e772c0040fb Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Sat, 21 Jan 2017 09:50:56 -0600 Subject: [PATCH 40/41] Complete challenge for timer. --- 29 - Countdown Timer/scripts-START.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/29 - Countdown Timer/scripts-START.js b/29 - Countdown Timer/scripts-START.js index a25e791a52..b7fe7e2633 100644 --- a/29 - Countdown Timer/scripts-START.js +++ b/29 - Countdown Timer/scripts-START.js @@ -45,3 +45,10 @@ function startTimer() { } buttons.forEach(button => button.addEventListener('click', startTimer)); +document.customForm.addEventListener('submit', function(e) { + e.preventDefault(); + const mins = this.minutes.value; + console.log(mins); + timer(mins * 60); + this.reset(); +}); From 6b38e887f7568cf08b170d4d16ff723e2a11f062 Mon Sep 17 00:00:00 2001 From: Caden Albaugh Date: Sun, 22 Jan 2017 12:14:48 -0600 Subject: [PATCH 41/41] Coded Whack A Mole project. --- 30 - Whack A Mole/index-START.html | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/30 - Whack A Mole/index-START.html b/30 - Whack A Mole/index-START.html index 2014ff458c..9b99b79a33 100644 --- a/30 - Whack A Mole/index-START.html +++ b/30 - Whack A Mole/index-START.html @@ -36,6 +36,51 @@

Whack-a-mole! 0

const holes = document.querySelectorAll('.hole'); const scoreBoard = document.querySelector('.score'); const moles = document.querySelectorAll('.mole'); + let lastHole; + let timeUp = false; + let score = 0; + + function randomTime(min, max) { + return Math.round(Math.random() * (max - min) + min); + } + + function randomHole(holes) { + const idx = Math.floor(Math.random() * holes.length); + const hole = holes[idx]; + if (hole === lastHole) { + return randomHole(holes); + } + + lastHole = hole; + return hole; + } + + function peep() { + const time = randomTime(200, 1000); + const hole = randomHole(holes); + hole.classList.add('up'); + setTimeout(() => { + hole.classList.remove('up'); + if (!timeUp) peep(); + }, time); + } + + function startGame() { + scoreBoard.textContent = 0; + timeUp = false; + score = 0; + peep(); + setTimeout(() => timeUp = true, 10000) + } + + function bonk(e) { + if(!e.isTrusted) return; + score++; + this.classList.remove('up'); + scoreBoard.textContent = score; + } + + moles.forEach(mole => mole.addEventListener('click', bonk));