diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..f8425f35ee 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -58,7 +58,18 @@ diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..92e33a8f57 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -61,12 +61,40 @@ background:black; position: absolute; top:50%; + transform: rotate(90deg); + transform-origin: 100%; + transition: all 0.06s; + transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1) } diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index 7171607a8b..956bf53539 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -21,10 +21,21 @@

Update CSS Variables with JS

diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 4162bce339..6e36253cad 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -33,28 +33,61 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + console.log('Filter the list of inventors for those who were born in the 1500s') + console.table(inventors.filter(x => x.year >= 1500 && x.year <= 1599)) // Array.prototype.map() - // 2. Give us an array of the inventors' first and last names + // 2. Give us an array of the inventory first and last names + console.log('Give us an array of the inventory first and last names') + console.table(inventors.map(x => { + return {first: x.first, last: x.last} + })) // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + console.log('Sort the inventors by birthdate, oldest to youngest') + console.table(inventors.sort((x, y) => x.year > y.year ? 1 : -1)) // Array.prototype.reduce() // 4. How many years did all the inventors live? + console.log('How many years did all the inventors live?') + console.log(inventors.reduce((acc, current) => { + return acc + (current.passed - current.year) + }, 0)) // 5. Sort the inventors by years lived + console.log('Sort the inventors by years lived') + console.table(inventors.sort((x, y) => (x.passed - x.year) < (y.passed -y.year) ? 1 : -1)) // 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 boulevards = ["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 de Strasbourg","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 du Temple","Boulevard Voltaire","Boulevard de la Zone"] + console.log('create a list of Boulevards in Paris that contain de anywhere in the name') + console.table(boulevards.filter(x => x.includes('de'))) + // 7. sort Exercise // Sort the people alphabetically by last name + console.log('Sort the people alphabetically by last name') + console.table(people.sort((x, y) => { + return x.split(', ')[0] > y.split(', ')[0] ? 1 : -1 + })) // 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' ]; + console.log('Sum up the instances of each of these') + console.table( + data.reduce((acc, current, index, all) => { + if (acc[current]) { + acc[current] = acc[current] + 1 + } else { + acc[current] = 1 + } + return acc + }, {}) + ) diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index e1d643ad5c..4364be33b5 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; + display: flex; + flex: 1; + justify-content: center; + align-items: center; + flex-direction: column; } @@ -54,8 +60,17 @@ margin:0; width: 100%; transition:transform 0.5s; + 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 +83,7 @@ .panel.open { font-size:40px; + flex: 5; } .cta { @@ -107,7 +123,20 @@ diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 1436886918..fa8e9a6b28 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -14,9 +14,53 @@
  • or a state
  • - + diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 206ec31aa0..73b6b00960 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -24,17 +24,35 @@ { text: 'Nice Nice Nice!', id: 542328 } ]; + const year = (new Date()).getFullYear() + const age = (personYear) => year - personYear + const nineteen = (person) => person.year >= 19 + // Some and Every Checks // Array.prototype.some() // is at least one person 19? + const isAdult = people.some(nineteen) + console.log({isAdult}) + // Array.prototype.every() // is everyone 19? + const allAdults = people.every(nineteen) + 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(comment => comment.id === 823423) + console.log(comment); // 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); + + const newComments = [ + ...comments.slice(0, index), + ...comments.slice(index + 1) + ] + console.table(newComments) diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html index 37c148df07..46c7fcabc6 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -7,6 +7,48 @@ diff --git a/17 - Sort Without Articles/index-START.html b/17 - Sort Without Articles/index-START.html index cfaf3e0440..430efc8ee9 100644 --- a/17 - Sort Without Articles/index-START.html +++ b/17 - Sort Without Articles/index-START.html @@ -43,9 +43,11 @@ diff --git a/18 - Adding Up Times with Reduce/index-START.html b/18 - Adding Up Times with Reduce/index-START.html index 3eaee0f3ef..7a930673a9 100644 --- a/18 - Adding Up Times with Reduce/index-START.html +++ b/18 - Adding Up Times with Reduce/index-START.html @@ -1,4 +1,4 @@ - + @@ -182,6 +182,26 @@ diff --git a/19 - Webcam Fun/index.html b/19 - Webcam Fun/index.html index d4ffc4dc2a..a2c66ca55a 100755 --- a/19 - Webcam Fun/index.html +++ b/19 - Webcam Fun/index.html @@ -10,7 +10,7 @@
    - +
    diff --git a/19 - Webcam Fun/scripts.js b/19 - Webcam Fun/scripts.js index 00355f5a9c..120225b98f 100644 --- a/19 - Webcam Fun/scripts.js +++ b/19 - Webcam Fun/scripts.js @@ -1,5 +1,84 @@ -const video = document.querySelector('.player'); -const canvas = document.querySelector('.photo'); -const ctx = canvas.getContext('2d'); -const strip = document.querySelector('.strip'); -const snap = document.querySelector('.snap'); +const video = document.querySelector('.player') +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(stream => { + video.src = window.URL.createObjectURL(stream) + video.play() + }) + .catch(error => { + console.error(error) + }) +} + +function paintCanvas () { + canvas.width = video.videoWidth + canvas.height = video.videoHeight + + return setInterval(() => { + ctx.drawImage(video, 0, 0) + + let pixels = ctx.getImageData(0, 0, canvas.width, canvas.height) + // pixels = rgbSplit(pixels) + // pixels = redEffect(pixels) + // pixels = greenScreen(pixels) + ctx.putImageData(pixels, 0, 0) + }, 16) +} + +function takePhoto () { + snap.currentTime = 0 + snap.play() + const photo = canvas.toDataURL('image/jpeg') + const link = document.createElement('a') + link.href = photo + link.setAttribute('download', 'heygoodlooking') + link.innerHTML = `` + strip.insertBefore(link, strip.firstChild) +} + +function redEffect (pixels) { + for (let i = 0; i < pixels.data.length; i = i + 4) { + pixels.data[i + 0] = pixels.data[i + 0] + 100 + pixels.data[i + 1] = pixels.data[i + 1] - 50 + pixels.data[i + 2] = pixels.data[i + 2] * 0.5 + } + return pixels +} + +function rgbSplit (pixels) { + for (let i = 0; i < pixels.data.length; i = i + 4) { + pixels.data[i - 150] = pixels.data[i + 0] + pixels.data[i + 100] = pixels.data[i + 1] + pixels.data[i + 150] = pixels.data[i + 2] + } + return pixels +} + +function greenScreen (pixels) { + const levels = {} + + document.querySelectorAll('.rgb input').forEach((input) => { + levels[input.name] = input.value + }) + + for (let i = 0; i < pixels.data.length; i = i + 4) { + let red = pixels.data[i + 0] + let green = pixels.data[i + 1] + let blue = pixels.data[i + 2] + + 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', paintCanvas) diff --git a/20 - Speech Detection/index-START.html b/20 - Speech Detection/index-START.html index d3395cca35..7bd478af06 100644 --- a/20 - Speech Detection/index-START.html +++ b/20 - Speech Detection/index-START.html @@ -10,9 +10,30 @@ diff --git a/21 - Geolocation/index-START.html b/21 - Geolocation/index-START.html index d794c144ba..6906d368bb 100644 --- a/21 - Geolocation/index-START.html +++ b/21 - Geolocation/index-START.html @@ -57,18 +57,14 @@

    /*Compass: https://thenounproject.com/search/?q=compass&i=592352*/ diff --git a/22 - Follow Along Link Highlighter/index-START.html b/22 - Follow Along Link Highlighter/index-START.html index 8476112b5e..bcfbe90b8f 100644 --- a/22 - Follow Along Link Highlighter/index-START.html +++ b/22 - Follow Along Link Highlighter/index-START.html @@ -26,7 +26,19 @@ diff --git a/23 - Speech Synthesis/index-START.html b/23 - Speech Synthesis/index-START.html index e890008d36..c7baf5ddd7 100644 --- a/23 - Speech Synthesis/index-START.html +++ b/23 - Speech Synthesis/index-START.html @@ -29,12 +29,44 @@

    The Voiceinator 5000

    diff --git a/24 - Sticky Nav/index-START.html b/24 - Sticky Nav/index-START.html index e7bc67e9a5..1dee90169b 100644 --- a/24 - Sticky Nav/index-START.html +++ b/24 - Sticky Nav/index-START.html @@ -54,7 +54,20 @@

    A story about getting lost.

    diff --git a/24 - Sticky Nav/style-START.css b/24 - Sticky Nav/style-START.css index c6d59a31b3..7556c7e26e 100644 --- a/24 - Sticky Nav/style-START.css +++ b/24 - Sticky Nav/style-START.css @@ -84,3 +84,16 @@ nav a { transition:all 0.2s; text-transform: uppercase; } + +.fixed-nav nav { + position: fixed; + box-shadow: 0 5px rgba(0,0,0,0.1) +} + +.fixed-nav li.logo { + max-width: 500px +} + +body.fixed-nav .site-wrap { + transform: scale(1); +} 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..62d62c7d73 100644 --- a/25 - Event Capture, Propagation, Bubbling and Once/index-START.html +++ b/25 - Event Capture, Propagation, Bubbling and Once/index-START.html @@ -39,6 +39,14 @@ diff --git a/26 - Stripe Follow Along Nav/index-START.html b/26 - Stripe Follow Along Nav/index-START.html index 9780d0d1ac..6e1acbf090 100644 --- a/26 - Stripe Follow Along Nav/index-START.html +++ b/26 - Stripe Follow Along Nav/index-START.html @@ -208,6 +208,37 @@

    Cool

    diff --git a/27 - Click and Drag/index-START.html b/27 - Click and Drag/index-START.html index b8609315f7..e5b71be6ec 100644 --- a/27 - Click and Drag/index-START.html +++ b/27 - Click and Drag/index-START.html @@ -35,6 +35,33 @@