diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..38b576a21c 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -59,6 +59,27 @@ diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..40809514fb 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -61,12 +61,36 @@ background:black; position: absolute; top:50%; + transform-origin: 100%; + transform: rotate(90deg); + transition: all .05s; } diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index bf0f33e3ba..0d1570215b 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -21,6 +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 6e28e357d0..7f4ddf4008 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -27,28 +27,62 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + const fifteen = inventors.filter(inventor => (inventor.year >= 1500 && inventor.year <= 1599)) // if return true + console.table(fifteen) - // Array.prototype.map() + // Array.prototype.map() -> return a new array // 2. Give us an array of the inventory first and last names + const fullNames = inventors.map(inventor => `${inventor.first} ${inventor.last}`) + console.log(fullNames) // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + const ordered = inventors.sort((a, b) => a.year > b.year ? 1 : -1) + console.table(ordered) // 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(totalYears) // 5. Sort the inventors by years lived + const oldest = inventors.sort((a, b) => { + const lastGuy = a.passed - a.year + const nextGuy = b.passed - b.year + return lastGuy > nextGuy ? -1 : 1 + }) + 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 - + // 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 const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ]; + const transportation = data.reduce((obj, item) => { + if (!obj[item]) { + obj[item] = 0 + } + + obj[item]++ + return obj + }, {}) // initiate with a blank object + + console.log(transportation) diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index e1d643ad5c..3ed8572b56 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 { @@ -31,7 +32,7 @@ box-shadow:inset 0 0 0 5px rgba(255,255,255,0.1); color:white; text-align: center; - align-items:center; + align-items: center; /* Safari transitionend event.propertyName === flex */ /* Chrome + FF transitionend event.propertyName === flex-grow */ transition: @@ -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,6 +60,23 @@ 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 { @@ -67,6 +90,7 @@ } .panel.open { + flex: 5; font-size:40px; } @@ -108,6 +132,20 @@ diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 1436886918..67395e9c25 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -15,7 +15,47 @@ diff --git a/06 - Type Ahead/style.css b/06 - Type Ahead/style.css index 36dc55f30e..87b07f085e 100644 --- a/06 - Type Ahead/style.css +++ b/06 - Type Ahead/style.css @@ -5,6 +5,9 @@ font-size: 20px; font-weight: 200; } + * { + -webkit-font-smoothing: antialiased; + } *, *:before, *:after { box-sizing: inherit; } diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index bdf6c44415..e45e3f959d 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -25,42 +25,36 @@ // Some and Every Checks // Array.prototype.some() // is at least one person 19? - // const isAdult = people.some(function(person) { - // const currentYear = (new Date()).getFullYear(); - // if(currentYear - person.year >= 19) { - // return true; - // } - // }); + const isAdult = people.some(person => { + const currentYear = (new Date()).getFullYear() + return currentYear - person.year >= 19 + }) + console.log({isAdult}) - const isAdult = people.some(person => ((new Date()).getFullYear()) - person.year >= 19); - - console.log({isAdult}); // Array.prototype.every() // is everyone 19? - - const allAdults = people.every(person => ((new Date()).getFullYear()) - person.year >= 19); - console.log({allAdults}); + const allAdults = people.every(person => { + const currentYear = (new Date()).getFullYear() + return currentYear - 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(comment => comment.id === 823423); - - console.log(comment); + 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); - - // comments.splice(index, 1); + const index = comments.findIndex(comment => comment.id === 823423) + console.log(index) + // comments.splice(index, 1) const newComments = [ ...comments.slice(0, index), ...comments.slice(index + 1) - ]; + ] diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html index 37c148df07..5511cd54eb 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -6,7 +6,56 @@ + - + diff --git a/17 - Sort Without Articles/index-START.html b/17 - Sort Without Articles/index-START.html index cfaf3e0440..e7ecfb672f 100644 --- a/17 - Sort Without Articles/index-START.html +++ b/17 - Sort Without Articles/index-START.html @@ -18,7 +18,7 @@ #bands { list-style: inside square; - font-size: 20px; + font-size: 12px; background: white; width: 500px; margin: auto; @@ -43,8 +43,15 @@ diff --git a/18 - Adding Up Times with Reduce/index-START.html b/18 - Adding Up Times with Reduce/index-START.html index 3eaee0f3ef..0348e9978c 100644 --- a/18 - Adding Up Times with Reduce/index-START.html +++ b/18 - Adding Up Times with Reduce/index-START.html @@ -181,7 +181,26 @@ Video 58 - + diff --git a/19 - Webcam Fun/index.html b/19 - Webcam Fun/index.html index d4ffc4dc2a..cb2d1b18a4 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..d84e3d3514 100644 --- a/19 - Webcam Fun/scripts.js +++ b/19 - Webcam Fun/scripts.js @@ -1,5 +1,56 @@ -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(localMediaStream => { + video.src = window.URL.createObjectURL(localMediaStream) + video.play() + }).catch(err => { + console.erro(`OH NOO!!`, 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) + let pixels = ctx.getImageData(0, 0, width, height) + pixels = redEffect(pixels) + ctx.putImageData(pixels, 0, 0) + }, 16) +} + +function takePhoto() { + // played the sound + snap.currentTime = 0 + snap.play() + + // take the data out of the canvas + const data = canvas.toDataURL('image/jpeg') + const link = document.createElement('a') + link.href = data + link.setAttribute('download', 'handsome') + link.innerHTML = `Handsome man!` + strip.insertBefore(link, strip.firstChild) +} + +function redEffect(pixels) { + for (let i = 0; i < pixels.data.length; i += 4) { + pixels.data[i + 0] = pixels.data[i + 0] + 100 // red + pixels.data[i + 1] = pixels.data[i + 1] - 50 // green + pixels.data[i + 2] = pixels.data[i + 2] * .5 // blue + } + return pixels +} + +getVideo() + +video.addEventListener('canplay', paintToCanvas) diff --git a/20 - Speech Detection/index-START.html b/20 - Speech Detection/index-START.html index d3395cca35..413c3eeaaf 100644 --- a/20 - Speech Detection/index-START.html +++ b/20 - Speech Detection/index-START.html @@ -12,6 +12,31 @@ diff --git a/22 - Follow Along Link Highlighter/index-START.html b/22 - Follow Along Link Highlighter/index-START.html index 8476112b5e..3a4488edcb 100644 --- a/22 - Follow Along Link Highlighter/index-START.html +++ b/22 - Follow Along Link Highlighter/index-START.html @@ -26,8 +26,27 @@ - diff --git a/22 - Follow Along Link Highlighter/style.css b/22 - Follow Along Link Highlighter/style.css index 222e27ae68..8caaa38e73 100644 --- a/22 - Follow Along Link Highlighter/style.css +++ b/22 - Follow Along Link Highlighter/style.css @@ -1,6 +1,9 @@ html { box-sizing: border-box; } +* { + -webkit-font-smoothing: antialiased; +} *, *:before, *:after { box-sizing: inherit; } diff --git a/23 - Speech Synthesis/index-START.html b/23 - Speech Synthesis/index-START.html index e890008d36..95094cabfa 100644 --- a/23 - Speech Synthesis/index-START.html +++ b/23 - Speech Synthesis/index-START.html @@ -29,12 +29,46 @@

The Voiceinator 5000

diff --git a/24 - Sticky Nav/index-START.html b/24 - Sticky Nav/index-START.html index 4982537eea..82f37941ee 100644 --- a/24 - Sticky Nav/index-START.html +++ b/24 - Sticky Nav/index-START.html @@ -54,20 +54,22 @@

A story about getting lost.

diff --git a/24 - Sticky Nav/style-START.css b/24 - Sticky Nav/style-START.css index 19961112b4..c037958ac1 100644 --- a/24 - Sticky Nav/style-START.css +++ b/24 - Sticky Nav/style-START.css @@ -1,9 +1,13 @@ +* { + -webkit-font-smoothing: antialiased; +} html { box-sizing: border-box; background:#eeeeee; font-family:'helvetica neue'; font-size: 20px; font-weight: 200; + line-height: 150%; } body { margin: 0; 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..78e89376c2 100644 --- a/25 - Event Capture, Propagation, Bubbling and Once/index-START.html +++ b/25 - Event Capture, Propagation, Bubbling and Once/index-START.html @@ -1,45 +1,58 @@ - - - Understanding JavaScript's Capture - - - -
-
-
+ + + Understanding JavaScript's Capture + + + + +
+
+
+
-
- - .one { - background: thistle; - } + - .two { - background:mistyrose; - } + - - + diff --git a/26 - Stripe Follow Along Nav/index-START.html b/26 - Stripe Follow Along Nav/index-START.html index 9780d0d1ac..e732e1c58d 100644 --- a/26 - Stripe Follow Along Nav/index-START.html +++ b/26 - Stripe Follow Along Nav/index-START.html @@ -208,6 +208,44 @@

Cool

diff --git a/27 - Click and Drag/index-START.html b/27 - Click and Drag/index-START.html index b8609315f7..d132020b4e 100644 --- a/27 - Click and Drag/index-START.html +++ b/27 - Click and Drag/index-START.html @@ -34,8 +34,40 @@
25
- + diff --git a/28 - Video Speed Controller/index-START.html b/28 - Video Speed Controller/index-START.html index c4cbd4259a..82154b56ee 100644 --- a/28 - Video Speed Controller/index-START.html +++ b/28 - Video Speed Controller/index-START.html @@ -14,7 +14,25 @@
- + + diff --git a/29 - Countown Timer/scripts-START.js b/29 - Countown Timer/scripts-START.js index e69de29bb2..9c7c56b535 100644 --- a/29 - Countown Timer/scripts-START.js +++ b/29 - Countown Timer/scripts-START.js @@ -0,0 +1,54 @@ +let countdown + +const timerDisplay = document.querySelector('.display__time-left') +const endTime = document.querySelector('.display__end-time') +const buttons = document.querySelectorAll('[data-time]') + +function timer(seconds) { + // clear any timer + clearInterval(countdown) + + const now = Date.now() + const then = now + (seconds * 1000) + displayTimeLeft(seconds) + displayEndTime(then) + + countdown = setInterval(() => { + const secondsLeft = Math.round((then - Date.now()) / 1000) + if (secondsLeft < 0) { + clearInterval(countdown) + return + } + + displayTimeLeft(secondsLeft) + }, 1000) +} + +function displayTimeLeft(seconds) { + const minutes = Math.floor(seconds / 60) + const remainderSeconds = seconds % 60 + const display = `${minutes}:${remainderSeconds < 10 ? '0' : ''}${remainderSeconds}` + timerDisplay.textContent = display + document.title = display +} + +function displayEndTime(timestamp) { + const end = new Date(timestamp) + const hour = end.getHours() + const adjustedHour = hour > 12 ? hour - 12 : hour + const minutes = end.getMinutes() + endTime.textContent = `Be back at ${adjustedHour}:${minutes < 10 ? 0 : ''}${minutes}` +} + +function startTimer() { + const seconds = parseInt(this.dataset.time) + timer(seconds) +} + +buttons.forEach(button => button.addEventListener('click', startTimer)) +document.customForm.addEventListener('submit', function(e) { + e.preventDefault() + const mins = this.minutes.value + timer(mins * 60) + this.reset() +}) diff --git a/29 - Countown Timer/style.css b/29 - Countown Timer/style.css index f240799477..c61b4880c8 100644 --- a/29 - Countown Timer/style.css +++ b/29 - Countown Timer/style.css @@ -1,3 +1,7 @@ +* { + -webkit-font-smoothing: antialiased; +} + html { box-sizing: border-box; font-size: 10px;