From 22cdd9bad008cb833f7b514975d86c9058108289 Mon Sep 17 00:00:00 2001 From: offirgolan Date: Sat, 17 Dec 2016 11:47:10 +1300 Subject: [PATCH 1/6] Add finished exercises 1-3 --- 01 - JavaScript Drum Kit/index-START.html | 18 ++++++++++++++++ 02 - JS + CSS Clock/index-START.html | 20 ++++++++++++++++++ 03 - CSS Variables/index-START.html | 25 +++++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..57ef66fc07 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -58,7 +58,25 @@ diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..5eef2dba9a 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -61,12 +61,32 @@ background:black; position: absolute; top:50%; + transform: rotate(90deg); + transform-origin: 100%; + transition: all 0.05s; + transition-timing-function: cubic-bezier(0, 2.68, 0.58, 1); } diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index 7171607a8b..2d35b08793 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 8e0e875b78a36caa2172aa7d6c1f44d9f82e44ef Mon Sep 17 00:00:00 2001 From: offirgolan Date: Mon, 2 Jan 2017 20:47:19 -0800 Subject: [PATCH 2/6] Add exercises 4-6 --- 04 - Array Cardio Day 1/index-START.html | 39 +++++++++++++++++++++++- 05 - Flex Panel Gallery/index-START.html | 31 ++++++++++++++++++- 06 - Type Ahead/index-START.html | 32 +++++++++++++++++++ 3 files changed, 100 insertions(+), 2 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index eec0ffc31d..de277088b8 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -31,28 +31,65 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + const excer1 = inventors.filter(i => i.year >= 1500 && i.year < 1600); + console.log(excer1); // Array.prototype.map() // 2. Give us an array of the inventors' first and last names + const excer2 = inventors.map(i => `${i.first} ${i.last}`); + console.log(excer2); // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + const excer3 = inventors.sort((a, b) => a.year > b.year ? 1 : -1); + console.table(excer3); // Array.prototype.reduce() // 4. How many years did all the inventors live? + const excer4 = inventors.reduce((total, i) => { + return total += (i.passed - i.year); + }, 0); + console.log(excer4); // 5. Sort the inventors by years lived + const excer5 = inventors.sort((a, b) => { + const aLived = a.passed - a.year; + const bLived = b.passed - b.year; + + return aLived > bLived ? -1 : 1; + }); + console.table(excer5); // 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 excer6 = Array.from(document.querySelectorAll('.mw-category li')) + .map(b => b.textContent) + .filter(b => b.includes('de')); + console.log(excer6); // 7. sort Exercise // Sort the people alphabetically by last name + const excer7 = people.sort((a, b) => { + const [aLast] = a.split(','); + const [bLast] = b.split(','); + + return aLast.localeCompare(bLast); + }); + console.log(excer7); // 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 excer8 = data.reduce((hash, str) => { + if (hash[str]) { + hash[str]++; + } else { + hash[str] = 1; + } + + return hash; + }, {}); + console.log(excer8); diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index e1d643ad5c..a74d20a844 100644 --- a/05 - Flex Panel Gallery/index-START.html +++ b/05 - Flex Panel Gallery/index-START.html @@ -24,6 +24,7 @@ .panels { min-height:100vh; overflow: hidden; + display: flex; } .panel { @@ -41,6 +42,10 @@ font-size: 20px; background-size:cover; background-position:center; + flex: 1; + justify-content: center; + display: flex; + flex-direction: column; } @@ -50,12 +55,22 @@ .panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); } .panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); } + /* Flex Items */ .panel > * { margin:0; width: 100%; transition:transform 0.5s; + 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; @@ -67,6 +82,7 @@ } .panel.open { + flex: 5; font-size:40px; } @@ -107,10 +123,23 @@ + function toggleOpen() { + this.classList.toggle('open'); + } + function toggleActive(e) { + if (e.propertyName.includes('flex')) { + this.classList.toggle('open-active'); + } + } + panels.forEach(panel => { + panel.addEventListener('click', toggleOpen); + panel.addEventListener('transitionend', toggleActive); + }); + diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 1436886918..01eab4ae6c 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -16,7 +16,39 @@ From 3b99bc4f957fe598eed1f64e31e11b8db9bcfbbe Mon Sep 17 00:00:00 2001 From: offirgolan Date: Tue, 3 Jan 2017 18:47:30 -0800 Subject: [PATCH 3/6] Exercises 7-10 --- 07 - Array Cardio Day 2/index-START.html | 15 ++++++- 08 - Fun with HTML5 Canvas/index-START.html | 43 +++++++++++++++++++ .../index-START.html | 16 +++++++ 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 969566ff78..6140948043 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -25,17 +25,30 @@ ]; // Some and Every Checks + const now = new Date(); + // Array.prototype.some() // is at least one person 19 or older? + const some = people.some(p => now.getFullYear() - p.year >= 19); + console.log(some); + // Array.prototype.every() // is everyone 19 or older? + const every = people.every(p => now.getFullYear() - p.year >= 19); + console.log(every); // 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 find = comments.find(c => c.id === 823423); + console.log(find); // Array.prototype.findIndex() // Find the comment with this ID - // delete the comment with the ID of 823423 + const findIndex = comments.findIndex(c => c.id === 823423); + console.log(findIndex); + // delete the comment with the ID of 823423 + comments.splice(findIndex, 1); + console.log(comments); diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html index 37c148df07..cdf33fc778 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -7,6 +7,49 @@