From 784c97c33dd9685dd70a16b655411570ecdf6219 Mon Sep 17 00:00:00 2001 From: Monika Hoex Date: Thu, 8 Dec 2016 19:45:38 -0800 Subject: [PATCH 1/8] Build Drum Kit function --- 01 - JavaScript Drum Kit/index-START.html | 33 +++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..779d9b31cb 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -57,10 +57,39 @@ - + function playSound(e) { + const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`); + const key = document.querySelector(`.key[data-key="${e.keyCode}"]`); + + // Stop from running if no audio present + if(!audio) return; + + // Loop to start + audio.currentTime = 0; + audio.play(); + + key.classList.add('playing'); + + } + + function removeTransition(e){ + + // Skip property if not a transform + if(e.propertyName !== 'transform') return; + + this.classList.remove('playing'); + + } + + const keys = document.querySelectorAll('.key'); + keys.forEach(key => key.addEventListener('transitionend', removeTransition)); + + window.addEventListener('keydown', playSound); + + From 45b5cc145848d71b38fcde0edd3d045f4d188dee Mon Sep 17 00:00:00 2001 From: Monika Hoex Date: Sun, 11 Dec 2016 12:27:24 -0800 Subject: [PATCH 2/8] Build Clock function --- 02 - JS + CSS Clock/index-START.html | 39 +++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 259280d228..7b0817342a 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -10,7 +10,7 @@
-
+
@@ -61,12 +61,49 @@ background:black; position: absolute; top:50%; + transform-origin: 100%; + transform: rotate(90deg); + transition: all 0.05s; + transition-timing-function: cubic-bezier(0.1, 2.7, 0.5, 1); } From 3cb4c49b98193fe858a5f0ff283e9b6fbefcb797 Mon Sep 17 00:00:00 2001 From: Monika Hoex Date: Mon, 12 Dec 2016 16:19:47 -0800 Subject: [PATCH 3/8] Build CSS variable changer function --- 03 - CSS Variables/index-START.html | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index 7171607a8b..a82d9d6da0 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -22,6 +22,24 @@

Update CSS Variables with JS

From 43600ea225ba477cc62d92ef3d9eb6ce5be5ee11 Mon Sep 17 00:00:00 2001 From: Monika Hoex Date: Tue, 13 Dec 2016 19:42:18 -0800 Subject: [PATCH 4/8] Fun with Array methods --- 04 - Array Cardio Day 1/index-START.html | 62 ++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 4162bce339..9fab780b8f 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -33,29 +33,91 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + const fifteen = inventors.filter(inventor => (inventor.year >= 1500 && inventor.year < 1600)); + + console.table(fifteen); // Array.prototype.map() // 2. Give us an array of the inventors' first and last names + const fullNames = inventors.map(inventor => `${inventor.first} ${inventor.last}`); + + console.log(fullNames); + // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + // Sorted using a Ternary operator + const ordered = inventors.sort((a, b) => a.year > b.year ? 1 : -1); + + console.table(ordered); + // Array.prototype.reduce() // 4. How many years did all the inventors live? + const totalYears = inventors.reduce((total, inventor) => { + + return total + (inventor.passed - inventor.year); + + }, 0); + + console.log(totalYears); // 5. Sort the inventors by years lived + const oldest = inventors.sort(function(a, b){ + + const lastInventor = a.passed - a.year; + const nextInventor = b.passed - b.year; + + return lastInventor > nextInventor ? -1 : 1; + + }); + + console.table(oldest); // 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 alpha = people.sort((lastOne, nextOne) => { + const [aLast, aFirst] = lastOne.split(" , "); + const [bLast, bFirst] = nextOne.split(" , "); + return aLast > bLast ? 1 : -1; + }); + + console.log(alpha); // 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 transportation = data.reduce(function(object, item){ + + if(!object[item]) { + + object[item] = 0 + + } + + object[item]++ + return object; + + }, {}); + + console.log(transportation); + From a701c1239b186f58f1b101b017087a46df48b634 Mon Sep 17 00:00:00 2001 From: Monika Hoex Date: Thu, 15 Dec 2016 16:27:19 -0800 Subject: [PATCH 5/8] Build flex panel gallery --- 05 - Flex Panel Gallery/index-START.html | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index e1d643ad5c..853f23297a 100644 --- a/05 - Flex Panel Gallery/index-START.html +++ b/05 - Flex Panel Gallery/index-START.html @@ -22,11 +22,17 @@ } .panels { + display: flex; min-height:100vh; overflow: hidden; } .panel { + display: flex; + flex-direction: column; + flex: 1; + justify-content: center; + align-items: center; background:#6B0F9C; box-shadow:inset 0 0 0 5px rgba(255,255,255,0.1); color:white; @@ -51,11 +57,39 @@ .panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); } .panel > * { + display: flex; + flex: 1 0 auto; + justify-content: center; + align-items: center; margin:0; width: 100%; transition:transform 0.5s; } + .panel > *:first-child { + + transform: translateY(-100%); + + } + + .panel.open > *:first-child { + + transform: translateY(0); + + } + + .panel > *:last-child { + + transform: translateY(100%); + + } + + .panel.open > *:last-child { + + transform: translateY(0); + + } + .panel p { text-transform: uppercase; font-family: 'Amatic SC', cursive; @@ -67,6 +101,7 @@ } .panel.open { + flex: 5; font-size:40px; } @@ -108,6 +143,24 @@ From 948fb9df00a621bc138916520c81d570c63ce71a Mon Sep 17 00:00:00 2001 From: Monika Hoex Date: Thu, 15 Dec 2016 16:58:39 -0800 Subject: [PATCH 6/8] Build location picker --- 06 - Type Ahead/index-START.html | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 1436886918..46a074b18b 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -17,6 +17,54 @@ From aa278d5000aeeb9afea77b3c546c0139b56f19bc Mon Sep 17 00:00:00 2001 From: Monika Hoex Date: Fri, 13 Jan 2017 14:39:29 -0800 Subject: [PATCH 7/8] Fun with more Array methods --- 07 - Array Cardio Day 2/index-START.html | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 206ec31aa0..9f6560611a 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -26,16 +26,56 @@ // Some and Every Checks // Array.prototype.some() // is at least one person 19? + + const isAdult = people.some(person => { + + const currentYear = (new Date().getFullYear()); + return currentYear - person.year >= 19; + + }); + + console.log({isAdult}); + // Array.prototype.every() // is everyone 19? + const allAdults = people.every(person => { + + const currentYear = (new Date().getFullYear()); + return currentYear - 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(function(comment){ + + if(comment.id === 823423) { + + return true + + } + + }); + + 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 a1064df0d18899948d0740b57ae519d24c2b58fc Mon Sep 17 00:00:00 2001 From: Monika Hoex Date: Fri, 13 Jan 2017 15:08:02 -0800 Subject: [PATCH 8/8] Build canvas painter --- 08 - Fun with HTML5 Canvas/index-START.html | 77 +++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html index 37c148df07..41ffdd4464 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -7,6 +7,83 @@