From 7c578acd976534c055e9a204bd53a39a89f3b4bc Mon Sep 17 00:00:00 2001 From: Joel Brewster Date: Sun, 29 Jan 2017 14:52:58 +1100 Subject: [PATCH 01/32] Add event listener to print out keycoade --- 01 - JavaScript Drum Kit/index-START.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..5179766a65 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -58,6 +58,10 @@ From d3d56c0f61114e3879fc660932c0611ec1194c2a Mon Sep 17 00:00:00 2001 From: Joel Brewster Date: Sun, 29 Jan 2017 15:02:28 +1100 Subject: [PATCH 02/32] set audio time to 0 play samples on keypress --- 01 - JavaScript Drum Kit/index-START.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 5179766a65..13b8bce6f4 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -60,7 +60,9 @@ From 270ae85b24034e223f2b4982ed7b2e0a72f840cf Mon Sep 17 00:00:00 2001 From: Joel Brewster Date: Sun, 29 Jan 2017 15:07:52 +1100 Subject: [PATCH 03/32] add class playing to .key --- 01 - JavaScript Drum Kit/index-START.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 13b8bce6f4..ededc526a0 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -60,9 +60,12 @@ From 8b9fa1c97ea04db1c9479c0dc9912485f22c8676 Mon Sep 17 00:00:00 2001 From: Joel Brewster Date: Sun, 29 Jan 2017 15:12:41 +1100 Subject: [PATCH 04/32] transition end events --- 01 - JavaScript Drum Kit/index-START.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index ededc526a0..179022376b 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -68,6 +68,12 @@ key.classList.add('playing'); }); + function removeTransition(e) { + console.log(e); + } + const keys = document.querySelectorAll('.key'); + keys.forEach(key => key.addEventListener('transitionend', removeTransition)); + From 9a61cfb9948a00e47f91e961df33238bfbffb0b3 Mon Sep 17 00:00:00 2001 From: Joel Brewster Date: Sun, 29 Jan 2017 15:21:51 +1100 Subject: [PATCH 05/32] remove transition effect when transform is done --- 01 - JavaScript Drum Kit/index-START.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 179022376b..4887afeb14 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -69,7 +69,8 @@ }); function removeTransition(e) { - console.log(e); + if(e.propertyName !== 'transform') return; // skip if it's not transform + this.classList.remove('playing'); } const keys = document.querySelectorAll('.key'); keys.forEach(key => key.addEventListener('transitionend', removeTransition)); From 76130d55fa352c7a6e791d58418199b3c84c1b30 Mon Sep 17 00:00:00 2001 From: Joel Brewster Date: Sun, 29 Jan 2017 15:35:48 +1100 Subject: [PATCH 06/32] moved style into head because syntastic kept giving me errors --- 02 - JS and CSS Clock/index-START.html | 112 ++++++++++++------------- 1 file changed, 55 insertions(+), 57 deletions(-) diff --git a/02 - JS and CSS Clock/index-START.html b/02 - JS and CSS Clock/index-START.html index 2712384201..bcb891fa67 100644 --- a/02 - JS and CSS Clock/index-START.html +++ b/02 - JS and CSS Clock/index-START.html @@ -1,73 +1,71 @@ - - - JS + CSS Clock - - + + + JS + CSS Clock + + + - +
+
+
+
+
+
+
- - + + From 54eac1980e9db797a0796e3d9ac6f38454983b28 Mon Sep 17 00:00:00 2001 From: Joel Brewster Date: Sun, 29 Jan 2017 15:42:40 +1100 Subject: [PATCH 07/32] Add transition effects and console log seconds with setInterval --- 02 - JS and CSS Clock/index-START.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/02 - JS and CSS Clock/index-START.html b/02 - JS and CSS Clock/index-START.html index bcb891fa67..fa96de3ce0 100644 --- a/02 - JS and CSS Clock/index-START.html +++ b/02 - JS and CSS Clock/index-START.html @@ -49,6 +49,10 @@ background:black; position: absolute; top:50%; + transform-origin: 100%; + transform: rotate(90deg); + transition: all 0.05; + transition-timing-function: cubic-bezier(0.1, 2.2, 0.38, 1); } @@ -64,7 +68,12 @@ From d5b0904bbe0d7479abc6fb1fd4097aecd9665652 Mon Sep 17 00:00:00 2001 From: Joel Brewster Date: Sun, 29 Jan 2017 15:49:54 +1100 Subject: [PATCH 08/32] second hand rotate --- 02 - JS and CSS Clock/index-START.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/02 - JS and CSS Clock/index-START.html b/02 - JS and CSS Clock/index-START.html index fa96de3ce0..4e1e568cbe 100644 --- a/02 - JS and CSS Clock/index-START.html +++ b/02 - JS and CSS Clock/index-START.html @@ -68,9 +68,13 @@ From 7b795b220d6aca815582a85638947609bad63939 Mon Sep 17 00:00:00 2001 From: Joel Brewster Date: Sun, 29 Jan 2017 16:03:16 +1100 Subject: [PATCH 10/32] oops, fix for hour hand --- 02 - JS and CSS Clock/index-START.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/02 - JS and CSS Clock/index-START.html b/02 - JS and CSS Clock/index-START.html index 20becb1e53..683d133a10 100644 --- a/02 - JS and CSS Clock/index-START.html +++ b/02 - JS and CSS Clock/index-START.html @@ -86,8 +86,8 @@ console.log("Minutes:" + minutes); - const hours = now.getHours(); - const hoursDegrees = ((hours / 60) * 360) + 90; + const hours = now.getMinutes(); + const hoursDegrees = ((mins / 12) * 360) + 90; hourHand.style.transform = `rotate(${minutesDegrees}deg)`; console.log("hour: " + hours); } From 3157ce08755617d0a7b0dd38cfff1da87e7b6b26 Mon Sep 17 00:00:00 2001 From: Joel Brewster Date: Mon, 30 Jan 2017 12:08:31 +1100 Subject: [PATCH 11/32] refactor to remove syntastic errors --- 03 - CSS Variables/index-START.html | 33 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index ca2b59d077..a9db1a995a 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -3,22 +3,6 @@ Scoped CSS Variables and JS - - -

Update CSS Variables with JS

- -
- - - - - - - - -
- - + + +

Update CSS Variables with JS

+ +
+ + + + + + + + +
+ + + From 688ef5344f1a3609a7e34e4eb5af7bf3fa6614a2 Mon Sep 17 00:00:00 2001 From: Joel Brewster Date: Mon, 30 Jan 2017 12:13:58 +1100 Subject: [PATCH 12/32] Added root styles --- 03 - CSS Variables/index-START.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index a9db1a995a..583cbc24d2 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -5,6 +5,21 @@ Scoped CSS Variables and JS + +
@@ -107,6 +134,19 @@
From fa9ea3b39b9e950b40b3956bab75ad6c2a6acae5 Mon Sep 17 00:00:00 2001 From: Joel Brewster Date: Thu, 2 Feb 2017 11:58:42 +1100 Subject: [PATCH 29/32] son with type ahead matches TODO: redo --- 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..b97ebc38b1 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -16,6 +16,44 @@ From d01edf89207aced1804e9845a5907f89f382b94a Mon Sep 17 00:00:00 2001 From: Joel Brewster Date: Tue, 21 Feb 2017 11:46:07 +1100 Subject: [PATCH 30/32] Free time! 04-07 review --- 04 - Array Cardio Day 1/index-FINISHED.html | 15 +----- 06 - Type Ahead/#index-START.html# | 60 +++++++++++++++++++++ 07 - Array Cardio Day 2/index-START.html | 29 ++++++++++ 3 files changed, 90 insertions(+), 14 deletions(-) create mode 100644 06 - Type Ahead/#index-START.html# diff --git a/04 - Array Cardio Day 1/index-FINISHED.html b/04 - Array Cardio Day 1/index-FINISHED.html index ede883f1f9..6f383a497a 100644 --- a/04 - Array Cardio Day 1/index-FINISHED.html +++ b/04 - Array Cardio Day 1/index-FINISHED.html @@ -72,20 +72,7 @@ // 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 = Array.from(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 diff --git a/06 - Type Ahead/#index-START.html# b/06 - Type Ahead/#index-START.html# new file mode 100644 index 0000000000..b97ebc38b1 --- /dev/null +++ b/06 - Type Ahead/#index-START.html# @@ -0,0 +1,60 @@ + + + + + Type Ahead 👀 + + + + +
+ +
    +
  • Filter for a city
  • +
  • or a state
  • +
+
+ + + diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 969566ff78..3adb2f2732 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -26,11 +26,40 @@ // Some and Every Checks // Array.prototype.some() // is at least one person 19 or older? + + const isAdult = people.som(function() { + const currentYear = (new Date()).getFullYear(); + if(person.year - person.year >= 19) { + return true; + } + }); + // REDO + const isAdult = people.some(person => { + const currentYear = (new(Date()).getFullYear(); + return currentYear - person.year >= 19; + ) + }; + // REDO AGAIN + const isAdult = people.some(person => ((new Date()).getFullYear()) - person.year >= 19); + console.log({allAdults}) + + // Array.prototype.every() // is everyone 19 or older? + const isAdult = 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(function(comment) { + if(comment.id === 823423) { + return true + } + }); + + // REDO + const comment = comments.find(comment => comment.id === 823423); +) // Array.prototype.findIndex() // Find the comment with this ID From 180a1dccce792ab0a0898c5cc1f00c2620363951 Mon Sep 17 00:00:00 2001 From: Joel Brewster Date: Tue, 21 Feb 2017 11:48:36 +1100 Subject: [PATCH 31/32] Spread operator (review) --- 07 - Array Cardio Day 2/index-START.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 3adb2f2732..dcb080744c 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -64,6 +64,15 @@ // 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); + + //comments.splice(index, 1); + //Review from vid + const newComments = [ + ...comments.slice(0, index), + ...comments.slice(index + 1) + ]; From f616c15fda537f793de54af3b87848c877e54c8d Mon Sep 17 00:00:00 2001 From: Joel Brewster Date: Tue, 21 Feb 2017 13:52:06 +1100 Subject: [PATCH 32/32] Canvas fun --- 08 - Fun with HTML5 Canvas/index-START.html | 33 ++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html index 37c148df07..4b73c5cb8b 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -7,8 +7,39 @@ +const canvas = document.querySelector('#draw'); +const ctx = canvas.getContext('2d'); +canvas.width = window.innerWidth; +canvas.height = window.innerHeight; +ctx.strokeStyle = '#ff0000'; +ctx.lineJoin = 'round'; +ctx.lineCap = 'round'; +ctx.lineWidth = 2; + +let isDrawing = false; +let lastX = 0; +let lastY = 0; + + function draw(e) { + if (!isDrawing) return; // stop the fn from running when they are not moused down + ctx.beginPath(); + // start from + ctx.moveTo(lastX, lastY); + // go to + ctx.lineTo(e.offsetX, e.offsetY); + ctx.stroke(); + [lastX, lastY] = [e.offsetX, e.offsetY]; + } + canvas.addEventListener('mousedown', (e) => { + isDrawing = true; + [lastX, lastY] = [e.offsetX, e.offsetY]; + }); + + canvas.addEventListener('mousemove', draw); + canvas.addEventListener('mouseup', () => isDrawing = false); + canvas.addEventListener('mouseout', () => isDrawing = false); +