From 57fa6a0ced8a0d82f998197f2037ee8a707c4e18 Mon Sep 17 00:00:00 2001 From: Richard Date: Sun, 11 Dec 2016 10:21:04 -0600 Subject: [PATCH 1/5] Drum kit --- 01 - JavaScript Drum Kit/index-START.html | 40 ++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..0b2a2b216f 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -59,8 +59,46 @@ +let keys = document.getElementsByClassName('key'); +let keyCode = ''; +let audioElement; + +window.onkeydown = function(e){ + + // get keycode + keyCode = e.keyCode; + + // get key with key code + let key = document.querySelector('[data-key="'+keyCode+'"].key'); + + // don't do anything if the key doesn't exist + if(!key) return; + + // get audio with key code + audioElement = document.querySelector('audio[data-key="'+keyCode+'"]') + + // add class to key + key.className = key.className + ' playing'; + // play audio + audioElement.currentTime = 0; + audioElement.play(); + + // remove class from key + setTimeout(function(){ + key.classList.remove('playing'); + }, 100); + +} + +function playSound( audioEl ) { + console.log(audioEl) + audioEl.play(); +} + + + + From 5a606efc3cefec1859c1132c71e8d58f39f7fb3e Mon Sep 17 00:00:00 2001 From: Richard Date: Sun, 11 Dec 2016 10:58:57 -0600 Subject: [PATCH 2/5] clock --- 02 - JS + CSS Clock/index-START.html | 55 +++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..b35f097a18 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -18,7 +18,8 @@ From 5f18f7d320e5b4ba21b466682edca88fe1ce2e67 Mon Sep 17 00:00:00 2001 From: Richard Date: Sun, 11 Dec 2016 11:30:46 -0600 Subject: [PATCH 3/5] change css variables with javascript --- 03 - CSS Variables/index-START.html | 31 ++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index bf0f33e3ba..eeb195cf2f 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -15,7 +15,7 @@

Update CSS Variables with JS

- + @@ -25,6 +25,24 @@

Update CSS Variables with JS

/* misc styles, nothing to do with CSS variables */ + :root { + + --base: red; + --spacing: 10px; + --blur: 10px; + + } + + img { + padding: var(--spacing); + background-color:var(--base); + filter: blur(var(--blur)); + } + + .hl { + color: var(--base); + } + body { text-align: center; @@ -53,6 +71,17 @@

Update CSS Variables with JS

From 1aa686cab828f727fbab0e21d8011a0b1d7e3da3 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 13 Dec 2016 21:58:47 -0600 Subject: [PATCH 4/5] -m --- 04 - Array Cardio Day 1/index-START.html | 51 +++++++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 6e28e357d0..6c2a3bda7c 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -28,28 +28,75 @@ // 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 <= 1599); + console.table(fifteen); + // Array.prototype.map() // 2. Give us an array of the inventory first and last names + const names = inventors.map(inventor=> `${inventor.first}, ${inventor.last}` ); + console.log(names) + // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest - + + const oldYoung = inventors.sort((a,b) => (a.year > b.year) ? 1 : -1 ); + console.table(oldYoung) + // Array.prototype.reduce() // 4. How many years did all the inventors live? + const totalYears = inventors.reduce(function(total, inventor){ + return total + (inventor.passed - inventor.year); + }, 0); + console.log(totalYears) + + + inventors.forEach( inventor => inventor.totalLife = inventor.passed - inventor.year ) // 5. Sort the inventors by years lived + const orderedByYearsLived = inventors.sort((a,b) => { + const lastGuy = a.passed - a.year; + const nextGuy = b.passed - b.year; + return lastGuy > nextGuy ? -1 : 1; + }); + console.table(orderedByYearsLived) + + // 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 links = Array.from(document.querySelectorAll('.mw-category a')); + // const de = links + // .map(link => link.innerText) + // .filter(name => name.includes('de')) // 7. sort Exercise // Sort the people alphabetically by last name + const alpha = people.sort( (a,b) => { + const [ alast, afirst ] = a.split(', '); + const [ blast, bfirst ] = b.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 sums = data.reduce((start, el) => { + // console.log(start) + // return Object{el} = data.includes(el).length + if(!start[el]){ + start[el] = 0; + } + start[el]++; + return start; + }, {}) + console.log(sums) + + + From e21925305b88b1a3b6877ec3193cadbe732632a6 Mon Sep 17 00:00:00 2001 From: Richard Date: Wed, 14 Dec 2016 18:47:48 -0600 Subject: [PATCH 5/5] panel gallery --- 04 - Array Cardio Day 1/index-START.html | 2 -- 05 - Flex Panel Gallery/index-START.html | 39 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 6c2a3bda7c..1d7c745889 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -85,8 +85,6 @@ const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ]; const sums = data.reduce((start, el) => { - // console.log(start) - // return Object{el} = data.includes(el).length if(!start[el]){ start[el] = 0; } diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index e1d643ad5c..9cc6436710 100644 --- a/05 - Flex Panel Gallery/index-START.html +++ b/05 - Flex Panel Gallery/index-START.html @@ -24,6 +24,9 @@ .panels { min-height:100vh; overflow: hidden; + display: flex; + align-items: stretch; + } .panel { @@ -41,6 +44,12 @@ font-size: 20px; background-size:cover; background-position:center; + flex: 1; + justify-content: center; + align-items: center; + display: flex; + flex-direction: column; + } @@ -54,8 +63,17 @@ margin:0; width: 100%; transition:transform 0.5s; + display: flex; + align-items: center; + justify-content: center; + flex: 1 0 auto; } + .panel > *:first-child { transform: translateY(-100%); } + .panel > *:last-child { transform: translateY(100%); } + .panel.open-active > *:first-child { transform: translateY(0); } + .panel.open-active > *:last-child { transform: translateY(0); } + .panel p { text-transform: uppercase; font-family: 'Amatic SC', cursive; @@ -67,6 +85,7 @@ } .panel.open { + flex: 5; font-size:40px; } @@ -75,6 +94,7 @@ text-decoration: none; } + @@ -108,6 +128,25 @@