From 8e1c148290cb0e9380043ca371c12d604a806d85 Mon Sep 17 00:00:00 2001 From: Kdehner Date: Thu, 12 Dec 2019 10:56:08 -0700 Subject: [PATCH 1/9] Moving script to external document --- 01 - JavaScript Drum Kit/index-START.html | 4 +--- 01 - JavaScript Drum Kit/index.js | 0 2 files changed, 1 insertion(+), 3 deletions(-) create mode 100644 01 - JavaScript Drum Kit/index.js diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..3c1c42d1fa 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -57,9 +57,7 @@ - + diff --git a/01 - JavaScript Drum Kit/index.js b/01 - JavaScript Drum Kit/index.js new file mode 100644 index 0000000000..e69de29bb2 From ce8aec149695270efecae2f2fb6033455edbbaff Mon Sep 17 00:00:00 2001 From: Kdehner Date: Thu, 12 Dec 2019 12:12:21 -0700 Subject: [PATCH 2/9] Added Keypress functionality --- 01 - JavaScript Drum Kit/index.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/01 - JavaScript Drum Kit/index.js b/01 - JavaScript Drum Kit/index.js index e69de29bb2..de9b46da87 100644 --- a/01 - JavaScript Drum Kit/index.js +++ b/01 - JavaScript Drum Kit/index.js @@ -0,0 +1,25 @@ +window.addEventListener('load', () => { + + const keys = Array.from(document.getElementsByClassName('key')); + const audio = Array.from(document.getElementsByTagName('audio')); + + document.addEventListener('keydown', e => { + + const keyCode = String(e.keyCode); + const key = keys.find(key => key.dataset.key === keyCode); + const sound = audio.find(sound => sound.dataset.key === keyCode); + + if (key) { + key.classList.add('playing'); + sound.play(); + } + }); + document.addEventListener('keyup', e => { + const keyCode = String(e.keyCode); + const key = keys.find(key => key.dataset.key === keyCode); + + if (key) { + key.classList.remove('playing'); + } + }); +}); From 430841057995cf7e35aacfe456c626a38d008392 Mon Sep 17 00:00:00 2001 From: Kdehner Date: Thu, 12 Dec 2019 12:30:36 -0700 Subject: [PATCH 3/9] removed double fail. if no key dont need audio --- 01 - JavaScript Drum Kit/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/01 - JavaScript Drum Kit/index.js b/01 - JavaScript Drum Kit/index.js index de9b46da87..d61aa6e98f 100644 --- a/01 - JavaScript Drum Kit/index.js +++ b/01 - JavaScript Drum Kit/index.js @@ -7,10 +7,10 @@ window.addEventListener('load', () => { const keyCode = String(e.keyCode); const key = keys.find(key => key.dataset.key === keyCode); - const sound = audio.find(sound => sound.dataset.key === keyCode); if (key) { - key.classList.add('playing'); + const sound = audio.find(sound => sound.dataset.key === keyCode); + key.classList.add("playing"); sound.play(); } }); From d5d737b548b613cdd4f8f5e69d95187f006b8d9e Mon Sep 17 00:00:00 2001 From: Kdehner Date: Thu, 12 Dec 2019 12:31:05 -0700 Subject: [PATCH 4/9] document formatting and cleanup --- 01 - JavaScript Drum Kit/index.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/01 - JavaScript Drum Kit/index.js b/01 - JavaScript Drum Kit/index.js index d61aa6e98f..162c1d3580 100644 --- a/01 - JavaScript Drum Kit/index.js +++ b/01 - JavaScript Drum Kit/index.js @@ -1,10 +1,8 @@ -window.addEventListener('load', () => { - - const keys = Array.from(document.getElementsByClassName('key')); - const audio = Array.from(document.getElementsByTagName('audio')); - - document.addEventListener('keydown', e => { +window.addEventListener("load", () => { + const keys = Array.from(document.getElementsByClassName("key")); + const audio = Array.from(document.getElementsByTagName("audio")); + document.addEventListener("keydown", e => { const keyCode = String(e.keyCode); const key = keys.find(key => key.dataset.key === keyCode); @@ -14,12 +12,12 @@ window.addEventListener('load', () => { sound.play(); } }); - document.addEventListener('keyup', e => { + document.addEventListener("keyup", e => { const keyCode = String(e.keyCode); const key = keys.find(key => key.dataset.key === keyCode); if (key) { - key.classList.remove('playing'); + key.classList.remove("playing"); } }); }); From b8bcf7085a7326f387fdaf0cab30904061006cf7 Mon Sep 17 00:00:00 2001 From: Kdehner Date: Fri, 13 Dec 2019 10:19:09 -0700 Subject: [PATCH 5/9] Added clock functionality --- 02 - JS and CSS Clock/index-START.html | 10 +++++----- 02 - JS and CSS Clock/index.js | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 02 - JS and CSS Clock/index.js diff --git a/02 - JS and CSS Clock/index-START.html b/02 - JS and CSS Clock/index-START.html index 12f721b183..038e1df892 100644 --- a/02 - JS and CSS Clock/index-START.html +++ b/02 - JS and CSS Clock/index-START.html @@ -18,7 +18,7 @@ - + diff --git a/02 - JS and CSS Clock/index.js b/02 - JS and CSS Clock/index.js new file mode 100644 index 0000000000..27f8f57a36 --- /dev/null +++ b/02 - JS and CSS Clock/index.js @@ -0,0 +1,23 @@ +hourHand = document.querySelector('div.hour-hand'); +minuteHand = document.querySelector('div.min-hand'); +secondHand = document.querySelector('div.second-hand'); + +setInterval(setDate, 1000); + +setDate(); + +function setDate() { + + const now = new Date(); + const hours = now.getHours(); + const minutes = now.getMinutes(); + const seconds = now.getSeconds(); + + const setHour = ((hours / 12) * 360) + ((minutes/60)*30) + 90; + const setMinute = ((minutes / 60) * 360) + ((seconds/60)*6) + 90; + const setSeconds = ((seconds / 60) * 360) + 90; + + hourHand.setAttribute('style', `transform: rotate(${setHour}deg);`); + minuteHand.setAttribute('style', `transform: rotate(${setMinute}deg);`); + secondHand.setAttribute('style', `transform: rotate(${setSeconds}deg);`); +} From 608c929b11e5bad793a6b0092c549511f79520b6 Mon Sep 17 00:00:00 2001 From: Kdehner Date: Tue, 31 Dec 2019 20:02:31 -0700 Subject: [PATCH 6/9] Added CSS Variables for input fields. --- 03 - CSS Variables/index-START.html | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index 6b9b539c09..55ba6a8a9e 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -22,6 +22,22 @@

Update CSS Variables with JS

- From 01733c767c01777644b152d59959921aa6fd7d68 Mon Sep 17 00:00:00 2001 From: Kdehner Date: Tue, 31 Dec 2019 20:15:08 -0700 Subject: [PATCH 7/9] JS to updated the CSS Variables --- 03 - CSS Variables/app.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 03 - CSS Variables/app.js diff --git a/03 - CSS Variables/app.js b/03 - CSS Variables/app.js new file mode 100644 index 0000000000..551483bac7 --- /dev/null +++ b/03 - CSS Variables/app.js @@ -0,0 +1,10 @@ +const inputs = document.querySelectorAll('.controls input'); + +function handleUpdate() { + const suffix = this.dataset.sizing || ''; + + document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix); +} + +inputs.forEach(input => input.addEventListener('change', handleUpdate)); +inputs.forEach(input => input.addEventListener('mousemove', handleUpdate)); \ No newline at end of file From e82d7d3cf84608e437c4dde6c436420b2a340ed2 Mon Sep 17 00:00:00 2001 From: Kdehner Date: Thu, 2 Jan 2020 20:45:05 -0700 Subject: [PATCH 8/9] Worked through with WesBos --- 04 - Array Cardio Day 1/index-START.html | 34 +++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index eec0ffc31d..e59c8ba511 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -31,17 +31,33 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + const oldDudes = inventors.filter(inventor => inventor.year >= 1500 && inventor.year <= 1599); + console.table(oldDudes); // Array.prototype.map() // 2. Give us an array of the inventors' first and last names + const names = inventors.map(inventor => { + const firstName = inventor.first; + const lastName = inventor.last; + return `${firstName} ${lastName}`; + }) + + console.log(names); // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest - + const birthdate = inventors.sort((a, b) => a.year > b.year ? 1 : -1); + console.table(birthdate); // Array.prototype.reduce() // 4. How many years did all the inventors live? + const totalLife = inventors.reduce((total, inventor) => { + return total + (inventor.passed - inventor.year); + }, 0); + console.log(totalLife); // 5. Sort the inventors by years lived + const yearLived = inventors.sort((a, b) => (a.passed - a.year) < (b.passed - b.year) ? 1 : -1); + console.table(yearLived); // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name // https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris @@ -49,11 +65,27 @@ // 7. sort Exercise // Sort the people alphabetically by last name + const lastNames = people.sort((a, b) => { + const [aLast, aFirst] = a.split(', '); + const [bLast, bFirst] = b.split(', '); + return aLast > bLast ? 1 : -1; + }); + + console.log(lastNames); // 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 instances = data.reduce((obj, item) => { + if(!obj[item]) { + obj[item] = 0; + } + obj[item]++; + return obj; + }, {}); + console.log(instances); + From b9955c7e283067c804fca23e6004979777e2738a Mon Sep 17 00:00:00 2001 From: Kdehner Date: Thu, 2 Jan 2020 21:13:08 -0700 Subject: [PATCH 9/9] Codded along with WesBos --- 05 - Flex Panel Gallery/index-START.html | 89 +++++++++++++++++++----- 1 file changed, 73 insertions(+), 16 deletions(-) diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index 71d1c26f00..d2153ab817 100644 --- a/05 - Flex Panel Gallery/index-START.html +++ b/05 - Flex Panel Gallery/index-START.html @@ -1,10 +1,12 @@ + Flex Panels 💪 + @@ -105,10 +149,23 @@ + function toggleOpen() { + this.classList.toggle('open'); + } + function toggleActive(e) { + if (e.propertyName.includes('flex')) { + this.classList.toggle('open-active'); + } + } + pannels.forEach(panel => panel.addEventListener('click', toggleOpen)); + pannels.forEach(panel => panel.addEventListener('transitionend', toggleActive)); + + - + + \ No newline at end of file