From e2d8582d28e81cf7bd19c6c449735c4efb4a0dfa Mon Sep 17 00:00:00 2001 From: mjdude Date: Tue, 20 Dec 2016 22:05:04 +0000 Subject: [PATCH 01/36] added event listener for keydown --- 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..1c0b6038ea 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -58,6 +58,10 @@ From 0ad59cd67bbca5c49baa31365615ff0127cde4f8 Mon Sep 17 00:00:00 2001 From: mjdude Date: Tue, 20 Dec 2016 22:13:43 +0000 Subject: [PATCH 02/36] rewind audio element to beginning --- 01 - JavaScript Drum Kit/index-START.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 1c0b6038ea..2061926f58 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -60,7 +60,11 @@ From f38f88462cf064eb686f6201e7238f897d67f7c7 Mon Sep 17 00:00:00 2001 From: mjdude Date: Tue, 20 Dec 2016 22:37:20 +0000 Subject: [PATCH 03/36] added key selection --- 01 - JavaScript Drum Kit/index-START.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 2061926f58..f275a34bcf 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -60,6 +60,8 @@ From e468cc0f9ff52e07a938c742355b7d25bb895269 Mon Sep 17 00:00:00 2001 From: mjdude Date: Wed, 21 Dec 2016 14:37:02 +0000 Subject: [PATCH 05/36] added transform for clock hands --- 02 - JS + CSS Clock/index-START.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..8a2efcb785 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -61,6 +61,10 @@ background:black; position: absolute; top:50%; + transform-origin: 100%; + transform: rotate(90deg); + transition: all 0.05s; + transition-timing-function: cubic-bezier(0.68, -0.55, 0.27, 1.55); } From 38981a1538f7c77ba3e8de6f96c9130e281b44c5 Mon Sep 17 00:00:00 2001 From: mjdude Date: Wed, 21 Dec 2016 15:02:20 +0000 Subject: [PATCH 06/36] added transform for hours, and minutes --- 02 - JS + CSS Clock/index-START.html | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 8a2efcb785..32e660f829 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -70,8 +70,32 @@ From 4a6c74a0c235bdf357bb5d901fb205d5ac5020f1 Mon Sep 17 00:00:00 2001 From: mjdude Date: Wed, 21 Dec 2016 15:06:17 +0000 Subject: [PATCH 07/36] added comment --- 02 - JS + CSS Clock/index-START.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 32e660f829..5efd64a07a 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -77,7 +77,7 @@ function setDate() { const now = new Date(); - // seconds + // seconds , add 90 so it starts vertically const seconds = now.getSeconds(); const secondsDegrees = ((seconds / 60) * 360) + 90; secondHand.style.transform = `rotate(${secondsDegrees}deg)`; From 13f389bded2ac75a60889073e122c6d658a532b6 Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 22 Dec 2016 10:49:48 +0000 Subject: [PATCH 08/36] defined root variables in css (different to scss) --- 03 - CSS Variables/index-START.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index 7171607a8b..0271021820 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -21,7 +21,21 @@

Update CSS Variables with JS

From d9d9634197639d23c3e93a9370494f0068ec86d4 Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 22 Dec 2016 11:08:19 +0000 Subject: [PATCH 10/36] dynamically update variables, select suffix --- 03 - CSS Variables/index-START.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index d21a0479f7..78a8cbbbcc 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -33,7 +33,7 @@

Update CSS Variables with JS

filter: blur(var(--blur)); } - .h1 { + .hl { color: var(--base); } /* @@ -65,11 +65,14 @@

Update CSS Variables with JS

const inputs = document.querySelectorAll('.controls input'); function handleUpdate(){ - console.log(this.value); + const suffix = this.dataset.sizing || ''; + document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix); } inputs.forEach((input) => { input.addEventListener('change', handleUpdate); + input.addEventListener('mousemove', handleUpdate); + }) From 4c26708ba31f7cb702c3707052a25749bdb99c22 Mon Sep 17 00:00:00 2001 From: mjdude Date: Fri, 23 Dec 2016 15:44:52 +0000 Subject: [PATCH 11/36] finished first 3 array challanges --- 04 - Array Cardio Day 1/index-START.html | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 317883a4c1..dd1c9fe0e5 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -31,13 +31,33 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + const fifteen = inventors.filter((inventor) => { + return inventor.year >= 1500 && inventor.year <= 1600; + }); + + console.log('Born in 1500:'); + console.log(fifteen); // Array.prototype.map() // 2. Give us an array of the inventors' first and last names + const fullNames = inventors.map((inventor) => { + return `${inventor.first} ${inventor.last}`; + }); + console.log('inventors full names:'); + console.log(fullNames); + // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + const birthdate = inventors.sort((a,b) => { + const a_age = a.passed - a.year; + const b_age = b.passed - b.year; + + return b_age - a_age; + }) + console.log('Birthday oldest to youngest'); + console.log(birthdate); // Array.prototype.reduce() // 4. How many years did all the inventors live? From 86a926fc2f840eefa77d99f531f9b4a189639154 Mon Sep 17 00:00:00 2001 From: mjdude Date: Fri, 23 Dec 2016 16:21:13 +0000 Subject: [PATCH 12/36] completed upto exercise 6 --- 04 - Array Cardio Day 1/index-START.html | 33 +++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index dd1c9fe0e5..e43a3ed506 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -36,7 +36,7 @@ }); console.log('Born in 1500:'); - console.log(fifteen); + console.table(fifteen); // Array.prototype.map() // 2. Give us an array of the inventors' first and last names @@ -49,23 +49,44 @@ // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + + // this sorts by age not brithdate const birthdate = inventors.sort((a,b) => { - const a_age = a.passed - a.year; - const b_age = b.passed - b.year; - return b_age - a_age; + return (a.year > b.year ? 1 : -1); }) - console.log('Birthday oldest to youngest'); - console.log(birthdate); + console.log('Ordered by birthday'); + console.table(birthdate); // 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('Total Years: '); + console.log(totalYears); + // 5. Sort the inventors by years lived + const oldest = inventors.sort((a,b) => { + const a_age = a.passed - a.year; + const b_age = b.passed - b.year; + + return b_age - a_age; + }) + + console.log('Years lived'); + 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 + // in chrome console + // const list = document.querySelector('.mw-category'); + // const streets = list.querySelectorAll('a'); + // const streetNames = Array.from(streets); + // const streetsWithDe = streetArray.filter((street) => {return street.text.includes('de')}); // 7. sort Exercise // Sort the people alphabetically by last name From a2448910c951b8c877222cc4f426caca485c46ea Mon Sep 17 00:00:00 2001 From: mjdude Date: Fri, 23 Dec 2016 16:42:36 +0000 Subject: [PATCH 13/36] completed upto exercise 7 --- 04 - Array Cardio Day 1/index-START.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index e43a3ed506..400ba5ad37 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -90,6 +90,18 @@ // 7. sort Exercise // Sort the people alphabetically by last name + const peopleByLastName = people.sort((a,b) => { + const a_names = a.split(', '); + const b_names = b.split(', '); + + console.log(`comparing ${a_names[1]} with ${b_names[1]}`); + const res = a_names[1] > b_names[1] ? a_names[1] : b_names[1]; + console.log(`alpha is ${res}`); + return a_names[1] > b_names[1] ? 1 : -1; + }); + + console.log('People by last names:'); + console.log(peopleByLastName); // 8. Reduce Exercise // Sum up the instances of each of these From 9ea75eb13f08da19cbf1dc1c779b8b6e8bbedff6 Mon Sep 17 00:00:00 2001 From: mjdude Date: Fri, 23 Dec 2016 17:51:48 +0000 Subject: [PATCH 14/36] updated with solutions --- 04 - Array Cardio Day 1/index-START.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 400ba5ad37..9b853f461b 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -107,6 +107,17 @@ // 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((object, item) => { + if (!object[item]) { + object[item] = 0; + } + object[item]++; + return object; + }, {}); + + console.log('Transportation grouped:'); + console.log(transportation); + From fd2904ee704fb94684051d8c7494e3b1dd72cc25 Mon Sep 17 00:00:00 2001 From: = <=> Date: Sun, 25 Dec 2016 22:14:53 +0000 Subject: [PATCH 15/36] completed transition --- 05 - Flex Panel Gallery/index-START.html | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index e1d643ad5c..c17531b97a 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,11 @@ font-size: 20px; background-size:cover; background-position:center; + flex: 1; + align-items: center; + justify-content: center; + display: flex; + flex-direction: column; } @@ -54,7 +60,16 @@ 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; @@ -68,6 +83,7 @@ .panel.open { font-size:40px; + flex: 5; } .cta { @@ -107,6 +123,28 @@ From 8b24d84315662decf575dcfc000f4eb778bbc555 Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 26 Dec 2016 10:06:26 +0000 Subject: [PATCH 16/36] writting matching function --- 06 - Type Ahead/index-START.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 1436886918..5b354b5f91 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -17,6 +17,29 @@ From e8ee95281d2914939b4f7456078a82021c1475b5 Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 26 Dec 2016 10:20:04 +0000 Subject: [PATCH 17/36] replaced .include to use .match and regex --- 06 - Type Ahead/index-START.html | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 5b354b5f91..0dbcf733d6 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -31,13 +31,12 @@ console.log(e); }) - function findMatches(word, cities){ - return cities.filter((city) => { - if (city.city.includes(word) || city.state.includes(word)) { - return true; - } else { - return false; - } + function findMatches(wordToMatch, cities){ + return cities.filter((place) => { + + // g means we will do a global search via the regex and i means case incensitive + const regex = new RegExp(wordToMatch, 'gi'); + return place.city.match(regex) || place.state.match(regex); }); } From 614789850fefd43427561844faa9123d2d3d4d39 Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 26 Dec 2016 10:51:16 +0000 Subject: [PATCH 18/36] updated suggestions component to show results --- 06 - Type Ahead/index-START.html | 42 +++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 0dbcf733d6..c66edc851f 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -24,21 +24,45 @@ }) .then((data) => { cities.push(...data); - - console.log(findMatches('san', cities)); }) .catch((e) => { console.log(e); }) - function findMatches(wordToMatch, cities){ - return cities.filter((place) => { +function findMatches(wordToMatch, cities){ + return cities.filter((place) => { + + // g means we will do a global search via the regex and i means case incensitive + const regex = new RegExp(wordToMatch, 'gi'); + return place.city.match(regex) || place.state.match(regex); + }); +} + + +function displayMatches(){ + const matchArray = findMatches(this.value, cities); + + // .join turns array into one big string + const html = matchArray.map((place) => { + return ` +
  • + ${place.city}, ${place.state} + ${place.population} +
  • + `; + }).join(''); + suggestions.innerHTML = html; +}; + +const searchInput = document.querySelector('.search'); +const suggestions = document.querySelector('.suggestions'); + +// evertime a word is entered +searchInput.addEventListener('change', displayMatches); +// fire evertime a key is pressed +searchInput.addEventListener('keyup', displayMatches); + - // g means we will do a global search via the regex and i means case incensitive - const regex = new RegExp(wordToMatch, 'gi'); - return place.city.match(regex) || place.state.match(regex); - }); - } From 64a67ed684cf8cd97ff1d1d1d62a7b8f751e5464 Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 26 Dec 2016 11:03:03 +0000 Subject: [PATCH 19/36] added numbers with arrays for population --- 06 - Type Ahead/index-START.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index c66edc851f..26ba06a013 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -38,16 +38,22 @@ }); } +function numberWithCommas(x) { + return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); +} function displayMatches(){ const matchArray = findMatches(this.value, cities); // .join turns array into one big string const html = matchArray.map((place) => { + const regex = new RegExp(this.value, 'gi'); + const cityName = place.city.replace(regex, `${this.value}`); + const stateName = place.state.replace(regex, `${this.value}`); return `
  • - ${place.city}, ${place.state} - ${place.population} + ${cityName}, ${stateName} + ${numberWithCommas(place.population)}
  • `; }).join(''); From 94ebcf8a1ec7de8917719ef5a26200b465318bf0 Mon Sep 17 00:00:00 2001 From: mjdude Date: Sun, 1 Jan 2017 12:46:05 +0000 Subject: [PATCH 20/36] completed 1/ array cardio --- 07 - Array Cardio Day 2/index-START.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 969566ff78..1a33be1668 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -26,12 +26,33 @@ // Some and Every Checks // Array.prototype.some() // is at least one person 19 or older? + const isAdult = people.some((person) => { + const date = new Date; + return date.getFullYear() - person.year > 19 + }) + + console.log('is at least one person 19 or older'); + console.log(isAdult); + // Array.prototype.every() // is everyone 19 or older? + const allAdults = people.every((person) => { + return (new Date).getFullYear() - person.year > 19 + }); + + console.log('is everyone 19 or older?'); + 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 correctComment = comments.find((comment) => { + return comment.id === 823423; + }); + + console.log(`find the comment with the ID of 823423`); + console.log(correctComment); // Array.prototype.findIndex() // Find the comment with this ID // delete the comment with the ID of 823423 From 28e1f388e9a3fa75d56bf05eaeb71092c9305363 Mon Sep 17 00:00:00 2001 From: mjdude Date: Sun, 1 Jan 2017 12:57:24 +0000 Subject: [PATCH 21/36] completed array cardio 2 --- 07 - Array Cardio Day 2/index-START.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 1a33be1668..d1f87c63c9 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -57,6 +57,19 @@ // Find the comment with this ID // delete the comment with the ID of 823423 + const index = comments.findIndex((comment) => { + return comment.id === 823423; + }); + + const removeComment = comments.splice(index, 1); + + console.log( + `Find the comment with this ID + delete the comment with the ID of 823423` + ); + + console.log(removeComment); + From 8de4e57791a6dc939a56ad478655082aa6b9d9db Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 2 Jan 2017 15:06:05 +0000 Subject: [PATCH 22/36] updating javascipt canvas --- 08 - Fun with HTML5 Canvas/index-START.html | 21 ++++++++++++++++++++- 1 file changed, 20 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..b3ea84bd20 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -7,8 +7,27 @@ + const canvas = document.querySelector('#draw'); + const ctx = canvas.getContext('2d'); + canvas.width = window.innerWidth; + canvas.height = window.innerHeight; + ctx.strokeStyle = '#BADA55'; + ctx.lineJoin = 'round'; + ctx.lineCap = 'round'; + let isDrawing = false; + let lastX =0; + let lastY =0; + + function draw(e){ + if (!isDrawing) { + return; + } + console.log(e); + } + canvas.addEventListener('mousemove', draw); + canvas.addEventListener('mousedown', () => isDrawing = !isDrawing); +