diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..5d6734590a 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -58,6 +58,26 @@ diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..98198c4e3c 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -60,13 +60,48 @@ height:6px; background:black; position: absolute; - top:50%; + top: 50%; + transform-origin: 100%; + transform:rotate(90deg); + transition: all 0.05s; + transition-timing-function: cubic-bezier(0.9, 0.43, 0, 0.96); + } + + .hour-hand { + width: 25%; + top: 50%; + left: 25%; + } + + .min-hand { + width: 40%; + left: 10%; } diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index ca2b59d077..028db6cd90 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -22,6 +22,22 @@

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 eec0ffc31d..5bc393e67a 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -27,33 +27,83 @@ { first: 'Hanna', last: 'Hammarström', year: 1829, passed: 1909 } ]; - const people = ['Beck, Glenn', 'Becker, Carl', 'Beckett, Samuel', 'Beddoes, Mick', 'Beecher, Henry', 'Beethoven, Ludwig', 'Begin, Menachem', 'Belloc, Hilaire', 'Bellow, Saul', 'Benchley, Robert', 'Benenson, Peter', 'Ben-Gurion, David', 'Benjamin, Walter', 'Benn, Tony', 'Bennington, Chester', 'Benson, Leana', 'Bent, Silas', 'Bentsen, Lloyd', 'Berger, Ric', 'Bergman, Ingmar', 'Berio, Luciano', 'Berle, Milton', 'Berlin, Irving', 'Berne, Eric', 'Bernhard, Sandra', 'Berra, Yogi', 'Berry, Halle', 'Berry, Wendell', 'Bethea, Erin', 'Bevan, Aneurin', 'Bevel, Ken', 'Biden, Joseph', 'Bierce, Ambrose', 'Biko, Steve', 'Billings, Josh', 'Biondo, Frank', 'Birrell, Augustine', 'Black, Elk', 'Blair, Robert', 'Blair, Tony', 'Blake, William']; + const people = ['Beck, Glenn', 'Becker, Carl', 'Beckett, Samuel', 'Beddoes, Mick', 'Beecher, Henry', 'Beethoven, Ludwig', 'Begin, Menachem', 'Belloc, Hilaire', 'Bellow, Saul', 'Benchley, Robert', 'Benenson, Peter', 'Ben-Gurion, David', 'Benjamin, Walter', 'Benn, Tony', 'Bennington, Chester', 'Benson, Leana', 'Bent, Silas', 'Bentsen, Lloyd', 'Berger, Ric', 'Bergman, Ingmar', 'Berio, Luciano', 'Berle, Milton', 'Berlin, Irving', 'Berne, Eric', 'Bernhard, Sandra', 'Berra, Yogi', 'Berry, Halle', 'Berry, Wendell', 'Bethea, Erin', 'Bevan, Aneurin', 'Bevel, Ken', 'Biden, Joseph', 'Bierce, Ambrose', 'Biko, Steve', 'Billings, Josh', 'Biondo, Frank', 'Birrell, Augustine', 'Black Elk', 'Blair, Robert', 'Blair, Tony', 'Blake, William']; // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + function isBorn(inventor) { + return (inventor.year >= 1500 && inventor.year < 1600); + } + var born = inventors.filter(isBorn); + console.table(born); // Array.prototype.map() // 2. Give us an array of the inventors' first and last names + var names = inventors.map(inventor => { + return (inventor.first + ' ' + inventor.last); + }) + console.log('names: ' + names); // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + inventors.sort(function (a, b) { + return a.year - b.year; + }); + console.log(inventors); // Array.prototype.reduce() // 4. How many years did all the inventors live? + var yearsLived = inventors.reduce(function (total, inventor) { + return total + (inventor.passed - inventor.year); + }, 0); + + console.log(yearsLived); // 5. Sort the inventors by years lived + var sortedYears = inventors.sort(function (a, b) { + var aYears = (a.passed - a.year); + var bYears = (b.passed - b.year); + return aYears - bYears; + }); // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name // https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris + var blvds = ['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 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' + ]; + var de = blvds.filter(function(blvd) { + return blvd.match(/de/); + }) + console.log('de: ' + de); // 7. sort Exercise // Sort the people alphabetically by last name + var sorted = people.sort(function(a, b) { + var [aLast, aFirst] = a.split(', '); + var [bLast, bFirst] = b.split(', '); + return aLast > bLast ? 1 : -1; + }); + console.log(sorted); // 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 enumData = {}; + data.forEach(function(item) { + if (enumData[item]) { + enumData[item] += 1; + } else { + enumData[item] = 1; + }; + }); diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index e1d643ad5c..ba1b444385 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; } @@ -54,6 +60,10 @@ margin:0; width: 100%; transition:transform 0.5s; + flex: 1 0 auto; + display: flex; + justify-content: center; + align-items: center; } .panel p { @@ -62,12 +72,30 @@ text-shadow:0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45); font-size: 2em; } + + .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:nth-child(2) { font-size: 4em; } .panel.open { font-size:40px; + flex: 5; } .cta { @@ -107,9 +135,21 @@ + function toggleOpen() { + this.classList.toggle('open'); + } + function toggleActive(event) { + if (event.propertyName.includes('flex')) { + this.classList.toggle('open-active'); + } + } + + panels.forEach(panel => panel.addEventListener('click', toggleOpen)); + panels.forEach(panel => panel.addEventListener('transitionend', toggleActive)); + diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 1436886918..99bcb7ce36 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -15,7 +15,43 @@ diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 969566ff78..0f580655b8 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -25,16 +25,26 @@ ]; // Some and Every Checks - // Array.prototype.some() // is at least one person 19 or older? - // Array.prototype.every() // is everyone 19 or older? + // Array.prototype.some() // is at least one person 19? + const year = new Date().getFullYear(); + const year19 = year - 19; + console.log('At least one person 19: ' + people.some(person => person.year < year19)); // 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 + var commentText = comments.filter(comment => comment.id === 823423); + console.table(commentText); // Array.prototype.findIndex() // Find the comment with this ID + var commentTextIndex = comments.findIndex(comment => comment.id === 823423); // delete the comment with the ID of 823423 + var newComments = [ + ...comments.slice(0, commentTextIndex), + ...comments.slice(commentTextIndex + 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..436245aef0 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -5,14 +5,64 @@ HTML5 Canvas - + diff --git a/09 - Dev Tools Domination/index-START.html b/09 - Dev Tools Domination/index-START.html index 196fffd719..c28c7e3311 100644 --- a/09 - Dev Tools Domination/index-START.html +++ b/09 - Dev Tools Domination/index-START.html @@ -18,28 +18,56 @@ } // Regular + console.log('Hello world'); // Interpolated + console.log('Hello %s', '🌐'); // Styled + console.log('%c Code is stylish', 'color: red, background: blue'); // warning! + console.warn('you shouldn\'t be doing this'); // Error :| + console.error('Oh noes'); // Info + console.info('This is informative'); // Testing + console.assert('1' === 1, 'not equal!'); // clearing + //console.clear(); // Viewing DOM Elements + const p = document.querySelector('p'); + console.dir(p); // Grouping together + dogs.forEach(dog => { + console.group(`${dog.name}`); + console.log(`This is ${dog.name}`); + console.log(`${dog.name} is ${dog.age} years old`); + console.groupEnd(); + }) // counting + console.count('Loki'); + console.count('Loki'); + console.count('Keebler'); + console.count('Loki'); + console.count('Loki'); // timing + console.time('Fetching Data'); + fetch('https://api.github.com/users/zivi') + .then(data => data.json) + .then(data => { + console.timeEnd('fetching data'); + console.log(data); + }) diff --git a/10 - Hold Shift and Check Checkboxes/index-START-zivis-solution.html b/10 - Hold Shift and Check Checkboxes/index-START-zivis-solution.html new file mode 100644 index 0000000000..d17b25310e --- /dev/null +++ b/10 - Hold Shift and Check Checkboxes/index-START-zivis-solution.html @@ -0,0 +1,139 @@ + + + + + Document + + + + +
+
+ +

This is an inbox layout.

+
+
+ +

Check one item

+
+
+ +

Hold down your Shift key

+
+
+ +

Check a lower item

+
+
+ +

Everything inbetween should also be set to checked

+
+
+ +

Try do it with out any libraries

+
+
+ +

Just regular JavaScript

+
+
+ +

Good Luck!

+
+
+ +

Don't forget to tweet your result!

+
+
+ + + + diff --git a/11 - Custom Video Player/index.html b/11 - Custom Video Player/index.html index 281a15eaa8..4977b53c6b 100644 --- a/11 - Custom Video Player/index.html +++ b/11 - Custom Video Player/index.html @@ -15,7 +15,7 @@
- + diff --git a/11 - Custom Video Player/scripts.js b/11 - Custom Video Player/scripts.js index e69de29bb2..0bb38d2a49 100644 --- a/11 - Custom Video Player/scripts.js +++ b/11 - Custom Video Player/scripts.js @@ -0,0 +1,53 @@ +const videoPlayer = document.getElementsByTagName('video')[0]; +const progress = document.querySelector('.progress'); +const progressFilled = document.querySelector('.progress__filled'); +const play = document.querySelector('.toggle'); +const skipButtons = document.querySelectorAll('[data-skip]'); +const volume = document.getElementsByName('volume')[0]; +const playbackRate = document.getElementsByName('playbackRate')[0]; +var playProgressRate = null; +var unPlayed = true; +var progressStatus = 0; + +videoPlayer.addEventListener('timeupdate', updateStatusBar); +progress.addEventListener('click', scrub); + +videoPlayer.volume = 0.5 +volume.onmousemove = () => { + videoPlayer.volume = volume.value; +} + +playbackRate.onmousemove = () => { + videoPlayer.playbackRate = playbackRate.value; +} + +play.onclick = () => { + if (videoPlayer.paused) { + videoPlayer.play(); + videoPlayer.paused = false; + play.textContent = '❚❚'; + unPlayed = false; + } else { + videoPlayer.pause(); + videoPlayer.paused = true; + play.textContent = '►'; + } +} + +function updateStatusBar() { + const percent = (videoPlayer.currentTime / videoPlayer.duration) * 100; + progressFilled.style.flexBasis = `${percent}%`; +} + +function scrub(event) { + var scrubTime = (event.offsetX / progress.offsetWidth) * videoPlayer.duration; + videoPlayer.currentTime = scrubTime; +} + +skipButtons.forEach(button => button.addEventListener('click', skip)); +var skip = () => { + let skiptime = parseFloat(this.dataset.skip); + videoPlayer.currentTime += skiptime; + progressStatus += (playProgressRate * skiptime); + progressFilled.style.flexBasis = `${progressStatus}%`; +} diff --git a/11 - Custom Video Player/style.css b/11 - Custom Video Player/style.css index c07581c1c0..b6253af905 100644 --- a/11 - Custom Video Player/style.css +++ b/11 - Custom Video Player/style.css @@ -89,7 +89,7 @@ body { width:50%; background:#ffc600; flex:0; - flex-basis:50%; + flex-basis:0%; } /* unholy css to style input type="range" */ diff --git a/12 - Key Sequence Detection/index-START.html b/12 - Key Sequence Detection/index-START.html index 8cab786140..ce964e48c9 100644 --- a/12 - Key Sequence Detection/index-START.html +++ b/12 - Key Sequence Detection/index-START.html @@ -7,6 +7,16 @@ diff --git a/13 - Slide in on Scroll/index-START.html b/13 - Slide in on Scroll/index-START.html index 0b9fb8fccb..1db2ac8ad0 100644 --- a/13 - Slide in on Scroll/index-START.html +++ b/13 - Slide in on Scroll/index-START.html @@ -58,6 +58,24 @@

Slide in on Scroll

}; } + const sliderImages = document.querySelectorAll('.slide-in'); + + function checkSlide(event) { + sliderImages.forEach(function(sliderImage) { + const slideInAt = (window.scrollY + window.innerHeight) - (sliderImage.height / 2); + const imageBottom = sliderImage.offsetTop + sliderImage.height; + const isHalfShown = slideInAt > sliderImage.offsetTop; + const isNotScrolledPast = window.scrollY < imageBottom; + if (isHalfShown && isNotScrolledPast) { + sliderImage.classList.add('active'); + } else { + sliderImage.classList.remove('active'); + } + }) + } + + window.addEventListener('scroll', debounce(checkSlide)); +