From c830e5f30f2088144d01b0e5fc103ef755b15d3d Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Wed, 15 Feb 2017 20:37:35 -0800 Subject: [PATCH 01/33] Finished Exercise 1 --- 01 - JavaScript Drum Kit/index-START.html | 24 ++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..6e77081ad3 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -58,7 +58,29 @@ From 585339555462f5b46d6e9108788cad487415177c Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Sat, 18 Feb 2017 16:19:53 -0800 Subject: [PATCH 02/33] Finished Clock! --- 01 - JavaScript Drum Kit/index-START.html | 2 +- 02 - JS and CSS Clock/index-START.html | 25 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 6e77081ad3..c84e7109a3 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -66,13 +66,13 @@ } audio.currentTime = 0; audio.play(); - // console.log(key); key.classList.add('playing'); } function removeTransition(e) { if (e.propertyName !== 'transform') { return; } + console.log(e.propertyName); this.classList.remove('playing'); } diff --git a/02 - JS and CSS Clock/index-START.html b/02 - JS and CSS Clock/index-START.html index 2712384201..4da1b5b954 100644 --- a/02 - JS and CSS Clock/index-START.html +++ b/02 - JS and CSS Clock/index-START.html @@ -61,12 +61,35 @@ background:black; position: absolute; top:50%; + transform-origin: 100%; + transform: rotate(90deg); + transition: all 0.05s; + transition-timing-function: cubic-bezier(0.15, 2.59, 0.46, -2.15) } - From 3a56b938e75a48c27a0ed6084fd71ceeb8881a87 Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Sun, 19 Feb 2017 10:37:17 -0800 Subject: [PATCH 03/33] Finished CSS Variables --- 03 - CSS Variables/index-START.html | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index ca2b59d077..ab72daf780 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -22,6 +22,21 @@

Update CSS Variables with JS

From 1643691dfec8e1bbe0729efe73a2be8c456c9593 Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Thu, 23 Feb 2017 21:40:06 -0800 Subject: [PATCH 04/33] Working on Array Cardio 1 --- 04 - Array Cardio Day 1/index-START.html | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index eec0ffc31d..425c384992 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -31,16 +31,32 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's - + var results1500 = inventors.filter( (person) => { + return person.year >= 1500 && person.year < 1600; + }); + // console.log(results1500); // Array.prototype.map() // 2. Give us an array of the inventors' first and last names - + var firstLast = inventors.map( (inventor) => { + return { + first: inventor.first, + last: inventor.last + }; + }) + // console.log(firstLast); // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest - + var sorted = inventors.sort( (a, b) => { + return a.year - b.year; + }); + // console.log(sorted); // Array.prototype.reduce() // 4. How many years did all the inventors live? - + var total = inventors.reduce((acc, val) => { + acc = acc + val.passed - val.year; + return acc; + }, 0); + console.log(total); // 5. Sort the inventors by years lived // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name From a0e36b91b0f4f2bcec120bbdf34d2cff863bab0c Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Thu, 23 Feb 2017 22:10:52 -0800 Subject: [PATCH 05/33] Working on sorting people function --- 04 - Array Cardio Day 1/index-START.html | 72 +++++++++++++++++++----- boulevards.txt | 33 +++++++++++ formatBoule.js | 8 +++ output.txt | 1 + 4 files changed, 101 insertions(+), 13 deletions(-) create mode 100644 boulevards.txt create mode 100644 formatBoule.js create mode 100644 output.txt diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 425c384992..63ac37294b 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -1,9 +1,11 @@ + Array Cardio 💪 +

Psst: have a look at the JavaScript Console 💁

- + + \ No newline at end of file diff --git a/boulevards.txt b/boulevards.txt new file mode 100644 index 0000000000..d325eaf4ed --- /dev/null +++ b/boulevards.txt @@ -0,0 +1,33 @@ +Boulevards of Paris +City walls of Paris +Thiers wall +Wall of Charles V +Wall of Philip II Augustus +City gates of Paris +Haussmann's renovation of Paris +Boulevards of the Marshals +Boulevard Auguste-Blanqui +Boulevard Barbès +Boulevard Beaumarchais +Boulevard de l'Amiral-Bruix +Boulevard des Capucines +Boulevard de la Chapelle +Boulevard de Clichy +Boulevard du Crime +Boulevard Haussmann +Boulevard de l'Hôpital +Boulevard des Italiens +Boulevard de la Madeleine +Boulevard de Magenta +Boulevard Montmartre +Boulevard du Montparnasse +Boulevard Raspail +Boulevard Richard-Lenoir +Boulevard de Rochechouart +Boulevard Saint-Germain +Boulevard Saint-Michel +Boulevard de Sébastopol +Boulevard de Strasbourg +Boulevard du Temple +Boulevard Voltaire +Boulevard de la Zone \ No newline at end of file diff --git a/formatBoule.js b/formatBoule.js new file mode 100644 index 0000000000..8f55a0ea98 --- /dev/null +++ b/formatBoule.js @@ -0,0 +1,8 @@ +var fs = require('fs'); + +fs.readFile('boulevards.txt', 'utf-8', (err, data) => { + var formatted = data.split('\n').map( boul => { + return '\'' + boul + '\'' + '\r'; + }); + fs.writeFile('output.txt', formatted); +}); \ No newline at end of file diff --git a/output.txt b/output.txt new file mode 100644 index 0000000000..f83635b74c --- /dev/null +++ b/output.txt @@ -0,0 +1 @@ +'Boulevards of Paris' ,'City walls of Paris' ,'Thiers wall' ,'Wall of Charles V' ,'Wall of Philip II Augustus' ,'City gates of Paris' ,'Haussmann's renovation of Paris' ,'Boulevards of the Marshals' ,'Boulevard Auguste-Blanqui' ,'Boulevard Barbès' ,'Boulevard Beaumarchais' ,'Boulevard de l'Amiral-Bruix' ,'Boulevard des Capucines' ,'Boulevard de la Chapelle' ,'Boulevard de Clichy' ,'Boulevard du Crime' ,'Boulevard Haussmann' ,'Boulevard de l'Hôpital' ,'Boulevard des Italiens' ,'Boulevard de la Madeleine' ,'Boulevard de Magenta' ,'Boulevard Montmartre' ,'Boulevard du Montparnasse' ,'Boulevard Raspail' ,'Boulevard Richard-Lenoir' ,'Boulevard de Rochechouart' ,'Boulevard Saint-Germain' ,'Boulevard Saint-Michel' ,'Boulevard de Sébastopol' ,'Boulevard de Strasbourg' ,'Boulevard du Temple' ,'Boulevard Voltaire' ,'Boulevard de la Zone' \ No newline at end of file From 1b2e8005476e60aaaaebea7c33ff97780a110242 Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Thu, 23 Feb 2017 22:18:26 -0800 Subject: [PATCH 06/33] Finished Array Cardio 1 --- 04 - Array Cardio Day 1/index-START.html | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 63ac37294b..284a604acf 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -108,13 +108,30 @@ // console.log(filterDE); // 7. sort Exercise // Sort the people alphabetically by last name - var sortedPeople = people.sort( (a, b) => { - return b.toLowerCase() < a.toLowerCase(); + var peopleFirstLast = people.map( person => { + var temp = person.split(','); + return { + first: temp[1], + last: temp[0] + } }); - console.log(sortedPeople); + + var sortedPeopleFirstLast = peopleFirstLast.sort( (a, b) => { + return a.last > b.last; + }) + // console.log(sortedPeopleFirstLast); // 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']; + var instance = data.reduce( (acc, next) => { + if (acc[next] === undefined) { + acc[next] = 1; + } else { + acc[next]++; + } + return acc; + }, {}); + console.log(instance); From d79924e2f3bf1a55d7bda75a625e5813b9f5321c Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Tue, 7 Mar 2017 23:20:49 -0800 Subject: [PATCH 07/33] Finished 5 --- 05 - Flex Panel Gallery/index-START.html | 46 ++++++++++++++++++++++++ output.txt | 34 +++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index e1d643ad5c..31e099b84f 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; + justify-content: center; + align-items: center; + display: flex; + flex-direction: column; } @@ -50,12 +56,33 @@ .panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); } .panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); } + /*Flex Children*/ .panel > * { margin:0; width: 100%; transition:transform 0.5s; + border: 1px solid red; + display: flex; + flex: 1 0 auto; + 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; @@ -68,6 +95,7 @@ .panel.open { font-size:40px; + flex: 5; } .cta { @@ -107,6 +135,24 @@ diff --git a/output.txt b/output.txt index f83635b74c..5212373e19 100644 --- a/output.txt +++ b/output.txt @@ -1 +1,33 @@ -'Boulevards of Paris' ,'City walls of Paris' ,'Thiers wall' ,'Wall of Charles V' ,'Wall of Philip II Augustus' ,'City gates of Paris' ,'Haussmann's renovation of Paris' ,'Boulevards of the Marshals' ,'Boulevard Auguste-Blanqui' ,'Boulevard Barbès' ,'Boulevard Beaumarchais' ,'Boulevard de l'Amiral-Bruix' ,'Boulevard des Capucines' ,'Boulevard de la Chapelle' ,'Boulevard de Clichy' ,'Boulevard du Crime' ,'Boulevard Haussmann' ,'Boulevard de l'Hôpital' ,'Boulevard des Italiens' ,'Boulevard de la Madeleine' ,'Boulevard de Magenta' ,'Boulevard Montmartre' ,'Boulevard du Montparnasse' ,'Boulevard Raspail' ,'Boulevard Richard-Lenoir' ,'Boulevard de Rochechouart' ,'Boulevard Saint-Germain' ,'Boulevard Saint-Michel' ,'Boulevard de Sébastopol' ,'Boulevard de Strasbourg' ,'Boulevard du Temple' ,'Boulevard Voltaire' ,'Boulevard de la Zone' \ No newline at end of file +'Boulevards of Paris' +'City walls of Paris', +'Thiers wall', +'Wall of Charles V', +'Wall of Philip II Augustus', +'City gates of Paris', +'Haussmann's renovation of Paris', +'Boulevards of the Marshals', +'Boulevard Auguste-Blanqui', +'Boulevard Barbès', +'Boulevard Beaumarchais', +'Boulevard de l'Amiral-Bruix', +'Boulevard des Capucines', +'Boulevard de la Chapelle', +'Boulevard de Clichy', +'Boulevard du Crime', +'Boulevard Haussmann', +'Boulevard de l'Hôpital', +'Boulevard des Italiens', +'Boulevard de la Madeleine', +'Boulevard de Magenta', +'Boulevard Montmartre', +'Boulevard du Montparnasse', +'Boulevard Raspail', +'Boulevard Richard-Lenoir', +'Boulevard de Rochechouart', +'Boulevard Saint-Germain', +'Boulevard Saint-Michel', +'Boulevard de Sébastopol', +'Boulevard de Strasbourg', +'Boulevard du Temple', +'Boulevard Voltaire', +'Boulevard de la Zone' From 85b86b122fbda5ecad2c27dd727c557c4385af22 Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Wed, 8 Mar 2017 10:02:59 -0800 Subject: [PATCH 08/33] 6 in progress --- 06 - Type Ahead/index-START.html | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 1436886918..5f6eb1ec7f 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -1,10 +1,12 @@ + Type Ahead 👀 +
@@ -14,9 +16,21 @@
  • or a state
  • - + - - - + \ No newline at end of file From 5c1ecb4e9fe5393be29cae695ab7e447f1516c8f Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Fri, 17 Mar 2017 22:55:19 -0700 Subject: [PATCH 09/33] In progress --- 06 - Type Ahead/index-START.html | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 5f6eb1ec7f..345a9cda9f 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -22,14 +22,12 @@ const cities = []; fetch(endpoint) - .then(blob => { - blob.json(); - }) - .then(data => { - cities = data; - console.log(cities ); - }); - + .then(blob => blob.json()) + .then(data => cities.push(...data)); + + function findMatches(wordToMatch, cities) { + return cities. + } From d39fa339038dd7bc5dc01385a3bd51b80961256a Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Sun, 19 Mar 2017 14:34:35 -0700 Subject: [PATCH 10/33] Finished Num 06 --- 06 - Type Ahead/index-START.html | 36 ++++++++++++++++++++++++++++++-- 06 - Type Ahead/style.css | 2 +- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 345a9cda9f..96f66c5f55 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -24,10 +24,42 @@ fetch(endpoint) .then(blob => blob.json()) .then(data => cities.push(...data)); - + function findMatches(wordToMatch, cities) { - return cities. + return cities.filter(place => { + + const regex = new RegExp(wordToMatch, 'gi'); + return place.city.match(regex) || place.state.match(regex); + }); + } + + function numberWithCommas(x) { + return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); } + + function displayMatches() { + const matchArray = findMatches(this.value, cities); + const html = matchArray.map(place => { + console.log('city', place.city, 'population', place.population); + const regex = new RegExp(this.value, 'gi'); + const cityName = place.city.replace(regex, `${this.value}`); + const stateName = place.state.replace(regex, `${this.value}`); + const formattedPop = numberWithCommas(place.population); + return ` +
  • + ${cityName}, ${stateName} + ${formattedPop} +
  • + ` + }).join(''); + suggestions.innerHTML = html; + console.log('value', matchArray); + } + const searchInput = document.querySelector('.search'); + const suggestions = document.querySelector('.suggestions'); + + searchInput.addEventListener('change', displayMatches); + searchInput.addEventListener('keyup', displayMatches); diff --git a/06 - Type Ahead/style.css b/06 - Type Ahead/style.css index 36dc55f30e..cf69a28b87 100644 --- a/06 - Type Ahead/style.css +++ b/06 - Type Ahead/style.css @@ -72,7 +72,7 @@ font-size: 15px; } - .hl { + .hl, .highlight { background:#ffc600; } From 9479e8d89f5d915299628e8e2d2b8d0a9cf66155 Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Mon, 15 May 2017 14:46:49 -0700 Subject: [PATCH 11/33] Finished 07 --- 07 - Array Cardio Day 2/index-START.html | 23 ++++++++++++++++++++++- 1 file changed, 22 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..81a023560e 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -1,9 +1,11 @@ + Array Cardio 💪💪 +

    Psst: have a look at the JavaScript Console 💁

    - + + \ No newline at end of file From 7c8496be74b51a93d3c6c15cf1b86bdf454dcb0e Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Mon, 15 May 2017 14:59:57 -0700 Subject: [PATCH 12/33] 08 in progress --- 08 - Fun with HTML5 Canvas/index-START.html | 39 ++++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html index 37c148df07..728087ae1b 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -1,19 +1,40 @@ + HTML5 Canvas + - - + + + + - + + \ No newline at end of file From debdd36041987cca65520ad26fe00b7da630cc6f Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Mon, 29 May 2017 21:25:03 -0700 Subject: [PATCH 13/33] Finished 08 --- 08 - Fun with HTML5 Canvas/index-START.html | 38 ++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html index 728087ae1b..a8e3a62e9c 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -15,17 +15,53 @@ canvas.width = window.innerWidth; canvas.height = window.innerHeight; ctx.strokeStyle = '#BADA55'; + ctx.lineJoin = 'round'; ctx.lineCap = 'round'; + ctx.lineWidth = 100; + ctx.globalCompositeOperation = 'screen'; let isDrawing = false; + let direction = true; let lastX = 0; let lastY = 0; + let hue = 0; function draw(e) { - console.log('e', e); + if (!isDrawing) { + return; + } + ctx.strokeStyle = `hsl(${hue}, 100%, 50%)`; + ctx.beginPath(); + // start from: + ctx.moveTo(lastX, lastY); + // go to: + ctx.lineTo(e.offsetX, e.offsetY); + ctx.stroke(); + [lastX, lastY] = [e.offsetX, e.offsetY]; + if (hue > 360) hue = 0; + hue += 7; + + if (ctx.lineWidth >= 100 || ctx.lineWidth <= 1) { + direction = !direction; + } + + if (direction) { + ctx.lineWidth+= 3; + } else { + ctx.lineWidth-= 3; + } + } + canvas.addEventListener('mousedown', (e) => { + isDrawing = true + console.log('*', e); + [lastX, lastY] = [e.offsetX, e.offsetY]; + console.log('x, y', lastX, lastY); + }); canvas.addEventListener('mousemove', draw); + canvas.addEventListener('mouseup', () => isDrawing = false); + canvas.addEventListener('mouseout', () => isDrawing = false); - + diff --git a/19 - Webcam Fun/scripts.js b/19 - Webcam Fun/scripts.js index 00355f5a9c..d54c80a3bd 100644 --- a/19 - Webcam Fun/scripts.js +++ b/19 - Webcam Fun/scripts.js @@ -3,3 +3,100 @@ const canvas = document.querySelector('.photo'); const ctx = canvas.getContext('2d'); const strip = document.querySelector('.strip'); const snap = document.querySelector('.snap'); + +function getVideo() { + navigator.mediaDevices.getUserMedia({ video: true, audio: false }) + .then(localMediaStream => { + console.log(localMediaStream); + video.src = window.URL.createObjectURL(localMediaStream); + video.play(); + }) + .catch(err => { + console.error('error message', err); + }); +} + +function paintToCanvas() { + const width = video.videoWidth; + const height = video.videoHeight; + canvas.width = width; + canvas.height = height; + + return setInterval(() => { + ctx.drawImage(video, 0, 0, width, height); + // Take the pixels out + let pixels = ctx.getImageData(0, 0, width, height); + // Alter pixels + // pixels = redEffect(pixels); + pixels = rgbSplit(pixels); + // pixels = greenScreen(pixels); + ctx.globalAlpha = 0.2; + // Put pixels back + ctx.putImageData(pixels, 0, 0); + + }, 16); +} + +function takePhoto() { + setTimeout(() => { + + snap.currentTime = 0; + snap.play(); + + const data = canvas.toDataURL('/image/jpeg'); + const link = document.createElement('a'); + link.href = data; + link.setAttribute('download', 'handsome'); + link.innerHTML = `Handsome Smooth!`; + strip.insertBefore(link, strip.firstChild); + + }, 1000); +} + +function redEffect(pixels) { + for (let i = 0; i < pixels.data.length; i += 4) { + pixels.data[i] *= 1.2; // Red + pixels.data[i + 1] += 50; // Green + pixels.data[i + 2] *= 1.4; // Blue + } + return pixels; +} + +function rgbSplit(pixels) { + for (let i = 0; i < pixels.data.length; i += 4) { + pixels.data[i - 200] = pixels.data[i]; // Red + pixels.data[i + 80] = pixels.data[i + 1]; // Green + pixels.data[i - 50] = pixels.data[i + 2]; // Blue + } + return pixels; +} + +function greenScreen(pixels) { + const levels = {}; + + document.querySelectorAll('.rgb input').forEach((input) => { + levels[input.name] = input.value; + }); + + for (i = 0; i < pixels.data.length; i = i + 4) { + red = pixels.data[i + 0]; + green = pixels.data[i + 1]; + blue = pixels.data[i + 2]; + alpha = pixels.data[i + 3]; + + if (red >= levels.rmin + && green >= levels.gmin + && blue >= levels.bmin + && red <= levels.rmax + && green <= levels.gmax + && blue <= levels.bmax) { + // take it out! + pixels.data[i + 3] = 0; + } + } + + return pixels; +} +getVideo(); + +video.addEventListener('canplay', paintToCanvas); \ No newline at end of file From f8167dc259c752c22b248070f29051cc327293d3 Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Sun, 13 Aug 2017 21:31:08 -0700 Subject: [PATCH 27/33] Probably the most fun exercise yet...#20 speech recognition complete! --- 20 - Speech Detection/index-START.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/20 - Speech Detection/index-START.html b/20 - Speech Detection/index-START.html index fa472df74e..c5529e4b4b 100644 --- a/20 - Speech Detection/index-START.html +++ b/20 - Speech Detection/index-START.html @@ -12,7 +12,30 @@ From b422f7c5d743ac68c6ecacf58596d8b18e88eaf5 Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Mon, 14 Aug 2017 15:18:55 -0700 Subject: [PATCH 28/33] #22 finished --- .../index-START.html | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/22 - Follow Along Link Highlighter/index-START.html b/22 - Follow Along Link Highlighter/index-START.html index 8476112b5e..db2b25b1a6 100644 --- a/22 - Follow Along Link Highlighter/index-START.html +++ b/22 - Follow Along Link Highlighter/index-START.html @@ -26,7 +26,28 @@ From 6a360be6a81d6e9ed3ee00ef0730b48e43c5f614 Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Sat, 26 Aug 2017 11:08:47 -0700 Subject: [PATCH 29/33] Finished 23 and 25 --- 23 - Speech Synthesis/index-START.html | 73 ++++++++++++++----- .../index-START.html | 9 +++ 2 files changed, 62 insertions(+), 20 deletions(-) diff --git a/23 - Speech Synthesis/index-START.html b/23 - Speech Synthesis/index-START.html index e890008d36..818c8c3016 100644 --- a/23 - Speech Synthesis/index-START.html +++ b/23 - Speech Synthesis/index-START.html @@ -1,41 +1,74 @@ + Speech Synthesis + -
    +
    -

    The Voiceinator 5000

    +

    The Voiceinator 5000

    - - - + + + + + + + + + - +
    - - - - + + function setVoice() { + msg.voice = voices.find(voice => voice.name === this.value); + toggle(); + } + + function toggle(startOver = true) { + speechSynthesis.cancel(); + if (startOver) { + speechSynthesis.speak(msg); + } + } + + function setOption() { + console.log(this.name, this.value); + msg[this.name] = this.value; + toggle(); + } + + speechSynthesis.addEventListener('voiceschanged', populateVoices); + voicesDropdown.addEventListener('change', setVoice); + options.forEach(option => option.addEventListener('change', setOption)); + speakButton.addEventListener('click', toggle); + stopButton.addEventListener('click', () => toggle(false)); + - + + \ No newline at end of file diff --git a/25 - Event Capture, Propagation, Bubbling and Once/index-START.html b/25 - Event Capture, Propagation, Bubbling and Once/index-START.html index 98f5e070c4..e8b44891eb 100644 --- a/25 - Event Capture, Propagation, Bubbling and Once/index-START.html +++ b/25 - Event Capture, Propagation, Bubbling and Once/index-START.html @@ -39,7 +39,16 @@ From 0c88a2d8bd7bdaed02eff5bac1730b47b732a478 Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Sun, 27 Aug 2017 14:24:11 -0700 Subject: [PATCH 30/33] 24 finished --- 24 - Sticky Nav/index-START.html | 16 +++++++++++++++- 24 - Sticky Nav/style-START.css | 12 ++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/24 - Sticky Nav/index-START.html b/24 - Sticky Nav/index-START.html index e7bc67e9a5..5e37f799e1 100644 --- a/24 - Sticky Nav/index-START.html +++ b/24 - Sticky Nav/index-START.html @@ -54,7 +54,21 @@

    A story about getting lost.

    diff --git a/24 - Sticky Nav/style-START.css b/24 - Sticky Nav/style-START.css index c6d59a31b3..0b17ea59da 100644 --- a/24 - Sticky Nav/style-START.css +++ b/24 - Sticky Nav/style-START.css @@ -23,6 +23,9 @@ body { transition: transform 0.5s; } +.fixed-nav .site-wrap { + transform: scale(1); +} header { text-align: center; height:50vh; @@ -48,6 +51,11 @@ nav { z-index: 1; } +.fixed-nav nav { + position: fixed; + box-shadow: 0 5px rgba(0, 0, 0, 0.1); +} + nav ul { margin: 0; padding:0; @@ -72,6 +80,10 @@ li.logo { font-size: 30px; } +.fixed-nav li.logo { + max-width: 500px; +} + li.logo a { color:black; } From 103a59a46e00021d58abe8791415ac801d21a9ea Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Sun, 27 Aug 2017 17:57:33 -0700 Subject: [PATCH 31/33] finished 26 --- 26 - Stripe Follow Along Nav/index-START.html | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/26 - Stripe Follow Along Nav/index-START.html b/26 - Stripe Follow Along Nav/index-START.html index 23808e118a..cb9801f8d8 100644 --- a/26 - Stripe Follow Along Nav/index-START.html +++ b/26 - Stripe Follow Along Nav/index-START.html @@ -134,8 +134,6 @@

    Cool

    opacity: 1; } - - .dropdownBackground { width:100px; height:100px; @@ -208,6 +206,36 @@

    Cool

    From 0967462e2ecbf5bf30db61f8883910ca41ebb19c Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Sun, 27 Aug 2017 18:22:01 -0700 Subject: [PATCH 32/33] 27 finished --- 27 - Click and Drag/index-START.html | 41 +++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/27 - Click and Drag/index-START.html b/27 - Click and Drag/index-START.html index b8609315f7..2678828243 100644 --- a/27 - Click and Drag/index-START.html +++ b/27 - Click and Drag/index-START.html @@ -1,10 +1,12 @@ + Click and Drag +
    01
    @@ -34,8 +36,39 @@
    25
    - + + + - - + \ No newline at end of file From a7baacc7e96f3b45a9b65359eaf0825bdb47b33d Mon Sep 17 00:00:00 2001 From: jdlawrence Date: Tue, 29 Aug 2017 13:56:23 -0700 Subject: [PATCH 33/33] All finished!! --- 28 - Video Speed Controller/index-START.html | 18 ++++++- 29 - Countdown Timer/index.html | 3 +- 29 - Countdown Timer/scripts-START.js | 56 ++++++++++++++++++++ 30 - Whack A Mole/index-FINISHED.html | 2 +- 30 - Whack A Mole/index-START.html | 5 +- 30 - Whack A Mole/script.js | 54 +++++++++++++++++++ 6 files changed, 131 insertions(+), 7 deletions(-) create mode 100644 30 - Whack A Mole/script.js diff --git a/28 - Video Speed Controller/index-START.html b/28 - Video Speed Controller/index-START.html index c4cbd4259a..c1bbf0ea18 100644 --- a/28 - Video Speed Controller/index-START.html +++ b/28 - Video Speed Controller/index-START.html @@ -8,13 +8,29 @@
    - +
    diff --git a/29 - Countdown Timer/index.html b/29 - Countdown Timer/index.html index d54f447dd9..29d2e699a4 100644 --- a/29 - Countdown Timer/index.html +++ b/29 - Countdown Timer/index.html @@ -3,7 +3,7 @@ Countdown Timer - + @@ -25,5 +25,6 @@

    + diff --git a/29 - Countdown Timer/scripts-START.js b/29 - Countdown Timer/scripts-START.js index e69de29bb2..4b2a0d4966 100644 --- a/29 - Countdown Timer/scripts-START.js +++ b/29 - Countdown Timer/scripts-START.js @@ -0,0 +1,56 @@ +const buttons = document.querySelectorAll('.timer__button'); +const customTime = document.querySelector('[name="customForm"]'); + +function buttonClick() { + startCount(this.dataset.time); +} + +function handleCustomTime(e) { + e.preventDefault(); + const mins = document.querySelector('[name="minutes"]').value; + startCount(mins * 60); +} + +buttons.forEach(button => { + button.addEventListener('click', buttonClick); +}); +customTime.addEventListener('submit', handleCustomTime); + +let timeLeft = document.querySelector('.display__time-left'); +let timeEnd = document.querySelector('.display__end-time'); + + +let countDown; +function startCount(timeInSeconds) { + // Remove old timers + clearInterval(countDown); + timeLeft.textContent = formatTime(timeInSeconds); + + // Format the future time for the end of the timer + let endTime = new Date(Date.now() + timeInSeconds * 1000); + let endHours = padZeros(endTime.getHours()); + let endMinutes = padZeros(endTime.getMinutes()); + timeEnd.textContent = `Be back at ${endHours}:${endMinutes}`; + + countDown = setInterval(() => { + timeInSeconds--; + timeLeft.textContent = formatTime(timeInSeconds); + if (timeInSeconds <= 0) { + clearInterval(countDown); + } + }, 1000); +} + +function formatTime(timeInSeconds) { + let mins = padZeros(Math.floor(timeInSeconds / 60)); + let seconds = padZeros(timeInSeconds % 60); + return `${mins}:${seconds}`; +} + +function padZeros(num) { + num = num.toString(); + while (num.length < 2) { + num = '0' + num; + } + return num; +} \ No newline at end of file diff --git a/30 - Whack A Mole/index-FINISHED.html b/30 - Whack A Mole/index-FINISHED.html index 8d741d5bf0..dd2a47a12c 100644 --- a/30 - Whack A Mole/index-FINISHED.html +++ b/30 - Whack A Mole/index-FINISHED.html @@ -3,7 +3,7 @@ Whack A Mole! - + diff --git a/30 - Whack A Mole/index-START.html b/30 - Whack A Mole/index-START.html index 2014ff458c..7654c564a9 100644 --- a/30 - Whack A Mole/index-START.html +++ b/30 - Whack A Mole/index-START.html @@ -32,10 +32,7 @@

    Whack-a-mole! 0

    - diff --git a/30 - Whack A Mole/script.js b/30 - Whack A Mole/script.js new file mode 100644 index 0000000000..cf129d0a19 --- /dev/null +++ b/30 - Whack A Mole/script.js @@ -0,0 +1,54 @@ +const holes = document.querySelectorAll('.hole'); +const scoreBoard = document.querySelector('.score'); +const moles = document.querySelectorAll('.mole'); +let lastHole; +let timeUp; +let score = 0; + +function randomTime(min, max) { + return Math.round(Math.random() * (max - min) + min); +} + +function randomHole(holes) { + const index = Math.floor(Math.random() * holes.length); + const hole = holes[index]; + if (hole === lastHole) { + return randomHole(holes); + } + lastHole = hole; + return hole; +} + +function peep() { + const time = randomTime(200, 1000); + const hole = randomHole(holes); + hole.classList.add('up'); + setTimeout(() => { + hole.classList.remove('up'); + if (!timeUp) { + peep(); + } + }, time); +} + +function startGame() { + score = 0; + scoreBoard.textContent = score; + timeUp = false; + peep(); + setTimeout(function () { + timeUp = true; + }, 10000); +} + +function bonk(e) { + console.log(e); + if (!e.isTrusted) return; // cheater! + score++; + scoreBoard.textContent = score; + this.classList.remove('up'); +} + +moles.forEach(mole => { + mole.addEventListener('click', bonk); +}); \ No newline at end of file