diff --git a/01 - JavaScript Drum Kit/drumBeat.js b/01 - JavaScript Drum Kit/drumBeat.js new file mode 100644 index 0000000000..204a3b99c7 --- /dev/null +++ b/01 - JavaScript Drum Kit/drumBeat.js @@ -0,0 +1,18 @@ +function playSound (e) { + const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`); + const key = document.querySelector(`.key[data-key="${e.keyCode}"]`); + if (!audio) return; + audio.currentTime = 0; + audio.play(); + key.classList.add('playing'); +} + +function removeTransition (e) { + if (e.propertyName !== 'transform') return; + this.classList.remove('playing'); +} + +const keys = document.querySelectorAll('.key'); +keys.forEach(key => key.addEventListener('transitionend', removeTransition)); + +window.addEventListener('keydown', playSound); diff --git a/01 - JavaScript Drum Kit/index-FINISHED.html b/01 - JavaScript Drum Kit/index-FINISHED.html deleted file mode 100644 index 1a16d0997c..0000000000 --- a/01 - JavaScript Drum Kit/index-FINISHED.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - - JS Drum Kit - - - - - -
-
- A - clap -
-
- S - hihat -
-
- D - kick -
-
- F - openhat -
-
- G - boom -
-
- H - ride -
-
- J - snare -
-
- K - tom -
-
- L - tink -
-
- - - - - - - - - - - - - - - - diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html deleted file mode 100644 index 4070d32767..0000000000 --- a/01 - JavaScript Drum Kit/index-START.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - JS Drum Kit - - - - - -
-
- A - clap -
-
- S - hihat -
-
- D - kick -
-
- F - openhat -
-
- G - boom -
-
- H - ride -
-
- J - snare -
-
- K - tom -
-
- L - tink -
-
- - - - - - - - - - - - - - - - diff --git a/01 - JavaScript Drum Kit/index.html b/01 - JavaScript Drum Kit/index.html index 246639f990..34b387982a 100644 --- a/01 - JavaScript Drum Kit/index.html +++ b/01 - JavaScript Drum Kit/index.html @@ -57,27 +57,7 @@ - + diff --git a/02 - JS + CSS Clock/gulpfile.js b/02 - JS + CSS Clock/gulpfile.js new file mode 100644 index 0000000000..0320a4bbe1 --- /dev/null +++ b/02 - JS + CSS Clock/gulpfile.js @@ -0,0 +1,16 @@ +const gulp = require('gulp'); +const browserSync = require('browser-sync').create(); + +gulp.task('default', ['browser-sync']); + +gulp.task('browser-sync', ['watch'], function() { + return browserSync.init({ server: { baseDir: './src' } }); +}); + +gulp.task('watch', function() { + return gulp.watch('./src/**/*', ['refresh']); +}); + +gulp.task('refresh', function() { + return browserSync.reload(); +}); diff --git a/02 - JS + CSS Clock/index-FINISHED.html b/02 - JS + CSS Clock/index-FINISHED.html deleted file mode 100644 index fb1080dc9c..0000000000 --- a/02 - JS + CSS Clock/index-FINISHED.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - - Document - - - - -
-
-
-
-
-
-
- - - - - - - diff --git a/02 - JS + CSS Clock/index.html b/02 - JS + CSS Clock/index.html deleted file mode 100644 index d5c9ec9596..0000000000 --- a/02 - JS + CSS Clock/index.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - Document - - - - -
-
-
-
-
-
-
- - - - - - - diff --git a/02 - JS + CSS Clock/package.json b/02 - JS + CSS Clock/package.json new file mode 100644 index 0000000000..71a211ed82 --- /dev/null +++ b/02 - JS + CSS Clock/package.json @@ -0,0 +1,15 @@ +{ + "name": "2", + "version": "1.0.0", + "description": "", + "main": "clock.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "browser-sync": "^2.18.2", + "gulp": "^3.9.1" + } +} diff --git a/02 - JS + CSS Clock/src/clock.js b/02 - JS + CSS Clock/src/clock.js new file mode 100644 index 0000000000..8869324bef --- /dev/null +++ b/02 - JS + CSS Clock/src/clock.js @@ -0,0 +1,21 @@ +const hourHand = document.querySelector('.hour-hand'); +const minuteHand = document.querySelector('.min-hand'); +const secondHand = document.querySelector('.second-hand'); + +function setDate () { + const now = new Date(); + const seconds = now.getSeconds(); + const secondsDegrees = (((seconds / 60) * 360) + 90); + + const minutes = now.getMinutes() + seconds / 60; + const minutesDegrees = (((minutes / 60) * 360) + 90); + + const hours = now.getHours() + minutes / 60; + const hoursDegrees = ((hours / 12) * 360 + 90); + + secondHand.style.transform = `rotate(${secondsDegrees}deg)`; + minuteHand.style.transform = `rotate(${minutesDegrees}deg)`; + hourHand.style.transform = `rotate(${hoursDegrees}deg)`; +} + +setInterval(setDate, 1000); \ No newline at end of file diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/src/index.html similarity index 83% rename from 02 - JS + CSS Clock/index-START.html rename to 02 - JS + CSS Clock/src/index.html index 240705d8fe..dfc8dc5334 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/src/index.html @@ -2,7 +2,7 @@ - Document + JS + CSS Clock @@ -24,7 +24,6 @@ text-align: center; font-size: 10px; } - body { font-size: 2rem; display:flex; @@ -32,7 +31,6 @@ min-height: 100vh; align-items: center; } - .clock { width: 30rem; height: 30rem; @@ -47,27 +45,30 @@ inset 0 0 10px black, 0 0 10px rgba(0,0,0,0.2); } - .clock-face { position: relative; width: 100%; height: 100%; transform: translateY(-3px); /* account for the height of the clock hands */ } - .hand { width:50%; height:6px; background:black; position: absolute; top:50%; + transform-origin: 100%; + transform: rotate(90deg); + transition: all 0.05s; + transition-timing-function: cubic-bezier(0.4, 0, 1, 1); + } + .hour-hand { + height: 3px; + } - + diff --git a/03 - CSS Variables/.gitignore b/03 - CSS Variables/.gitignore new file mode 100644 index 0000000000..30bc162798 --- /dev/null +++ b/03 - CSS Variables/.gitignore @@ -0,0 +1 @@ +/node_modules \ No newline at end of file diff --git a/03 - CSS Variables/gulpfile.js b/03 - CSS Variables/gulpfile.js new file mode 100644 index 0000000000..0320a4bbe1 --- /dev/null +++ b/03 - CSS Variables/gulpfile.js @@ -0,0 +1,16 @@ +const gulp = require('gulp'); +const browserSync = require('browser-sync').create(); + +gulp.task('default', ['browser-sync']); + +gulp.task('browser-sync', ['watch'], function() { + return browserSync.init({ server: { baseDir: './src' } }); +}); + +gulp.task('watch', function() { + return gulp.watch('./src/**/*', ['refresh']); +}); + +gulp.task('refresh', function() { + return browserSync.reload(); +}); diff --git a/03 - CSS Variables/index-FINISHED.html b/03 - CSS Variables/index-FINISHED.html deleted file mode 100644 index 9401d7b339..0000000000 --- a/03 - CSS Variables/index-FINISHED.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - - Scoped CSS Variables and JS - - -

Update CSS Variables with JS

- -
- - - - - - - - -
- - - - - - - - - - diff --git a/03 - CSS Variables/package.json b/03 - CSS Variables/package.json new file mode 100644 index 0000000000..9decdd0b29 --- /dev/null +++ b/03 - CSS Variables/package.json @@ -0,0 +1,15 @@ +{ + "name": "2", + "version": "1.0.0", + "description": "", + "main": "variables.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "browser-sync": "^2.18.2", + "gulp": "^3.9.1" + } +} \ No newline at end of file diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/src/index.html similarity index 78% rename from 03 - CSS Variables/index-START.html rename to 03 - CSS Variables/src/index.html index bf0f33e3ba..15bed1edbb 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/src/index.html @@ -21,10 +21,22 @@

Update CSS Variables with JS

- + diff --git a/03 - CSS Variables/src/variables.js b/03 - CSS Variables/src/variables.js new file mode 100644 index 0000000000..e1fa3efcc7 --- /dev/null +++ b/03 - CSS Variables/src/variables.js @@ -0,0 +1,11 @@ +const inputs = document.querySelectorAll('.controls input'); + +function handleUpdate () { + const suffix = this.dataset.sizing || ''; + document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix); +} + +inputs.forEach(input => input.addEventListener('change', handleUpdate)); +inputs.forEach(input => input.addEventListener('mousemove', handleUpdate)); + +//variables can be scoped just like regular css diff --git a/04 - Array Cardio Day 1/.gitignore b/04 - Array Cardio Day 1/.gitignore new file mode 100644 index 0000000000..30bc162798 --- /dev/null +++ b/04 - Array Cardio Day 1/.gitignore @@ -0,0 +1 @@ +/node_modules \ No newline at end of file diff --git a/04 - Array Cardio Day 1/gulpfile.js b/04 - Array Cardio Day 1/gulpfile.js new file mode 100644 index 0000000000..0320a4bbe1 --- /dev/null +++ b/04 - Array Cardio Day 1/gulpfile.js @@ -0,0 +1,16 @@ +const gulp = require('gulp'); +const browserSync = require('browser-sync').create(); + +gulp.task('default', ['browser-sync']); + +gulp.task('browser-sync', ['watch'], function() { + return browserSync.init({ server: { baseDir: './src' } }); +}); + +gulp.task('watch', function() { + return gulp.watch('./src/**/*', ['refresh']); +}); + +gulp.task('refresh', function() { + return browserSync.reload(); +}); diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html deleted file mode 100644 index 6e28e357d0..0000000000 --- a/04 - Array Cardio Day 1/index-START.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - Array Cardio πŸ’ͺ - - - - - diff --git a/04 - Array Cardio Day 1/package.json b/04 - Array Cardio Day 1/package.json new file mode 100644 index 0000000000..56e19cffb6 --- /dev/null +++ b/04 - Array Cardio Day 1/package.json @@ -0,0 +1,15 @@ +{ + "name": "2", + "version": "1.0.0", + "description": "", + "main": "cardio.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "browser-sync": "^2.18.2", + "gulp": "^3.9.1" + } +} \ No newline at end of file diff --git a/04 - Array Cardio Day 1/index-FINISHED.html b/04 - Array Cardio Day 1/src/cardio.js similarity index 63% rename from 04 - Array Cardio Day 1/index-FINISHED.html rename to 04 - Array Cardio Day 1/src/cardio.js index f68d8c3545..73c519eb07 100644 --- a/04 - Array Cardio Day 1/index-FINISHED.html +++ b/04 - Array Cardio Day 1/src/cardio.js @@ -1,15 +1,3 @@ - - - - - Array Cardio πŸ’ͺ - - - - - diff --git a/04 - Array Cardio Day 1/src/index.html b/04 - Array Cardio Day 1/src/index.html new file mode 100644 index 0000000000..5d8293cdd0 --- /dev/null +++ b/04 - Array Cardio Day 1/src/index.html @@ -0,0 +1,11 @@ + + + + + Array Cardio πŸ’ͺ + + + + + diff --git a/05 - Flex Panel Gallery/flex.js b/05 - Flex Panel Gallery/flex.js new file mode 100644 index 0000000000..5eb5688b9f --- /dev/null +++ b/05 - Flex Panel Gallery/flex.js @@ -0,0 +1,16 @@ +const panels = document.querySelectorAll('.panel') + +function toggleOpen () { + this.classList.toggle('open') +} + +function toggleActive (e) { + console.log(e.propertyName); + if (e.propertyName.includes('flex')) { + this.classList.toggle('open-active'); + } +} + +panels.forEach(panel => panel.addEventListener('click', toggleOpen)); +panels.forEach(panel => panel.addEventListener('transitionend', + toggleActive)); \ No newline at end of file diff --git a/05 - Flex Panel Gallery/index-FINISHED.html b/05 - Flex Panel Gallery/index-FINISHED.html deleted file mode 100644 index 243f8a221d..0000000000 --- a/05 - Flex Panel Gallery/index-FINISHED.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - - Flex Panels πŸ’ͺ - - - - - - -
-
-

Hey

-

Let's

-

Dance

-
-
-

Give

-

Take

-

Receive

-
-
-

Experience

-

It

-

Today

-
-
-

Give

-

All

-

You can

-
-
-

Life

-

In

-

Motion

-
-
- - - - - diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index.html similarity index 82% rename from 05 - Flex Panel Gallery/index-START.html rename to 05 - Flex Panel Gallery/index.html index e1d643ad5c..b152af73cb 100644 --- a/05 - Flex Panel Gallery/index-START.html +++ b/05 - Flex Panel Gallery/index.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,8 +60,18 @@ 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; font-family: 'Amatic SC', cursive; @@ -67,6 +83,7 @@ } .panel.open { + flex: 5; font-size:40px; } @@ -106,7 +123,7 @@ - diff --git a/06 - Type Ahead/index-FINISHED.html b/06 - Type Ahead/index-FINISHED.html deleted file mode 100644 index 5902b43936..0000000000 --- a/06 - Type Ahead/index-FINISHED.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - Type Ahead πŸ‘€ - - - - -
- - -
- - - diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index.html similarity index 71% rename from 06 - Type Ahead/index-START.html rename to 06 - Type Ahead/index.html index 1436886918..2a2a183be9 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index.html @@ -14,9 +14,7 @@
  • or a state
  • - diff --git a/06 - Type Ahead/type.js b/06 - Type Ahead/type.js new file mode 100644 index 0000000000..e9a1b7d459 --- /dev/null +++ b/06 - Type Ahead/type.js @@ -0,0 +1,43 @@ +const endpoint = 'https://gist.githubusercontent.com/Miserlou/c5cd8364bf9b2420bb29/raw/2bf258763cdddd704f8ffd3ea9a3e81d25e2c6f6/cities.json'; + +const cities = []; + +fetch(endpoint) + .then(blob => blob.json()) + .then(data => cities.push(...data)); + +function findMatches(wordToMatch, cities) { + return cities.filter(place => { + const regex = new RegExp(wordToMatch, 'gi'); + return place.city.match(regex) || place.state.match(RegExp); + }) +} + +function numberWithCommas(number) { + return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); +} + +function displayMatches () { + const matchArray = findMatches(this.value, cities); + 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}`) + const population = numberWithCommas(place.population) + + return ` +
  • + ${cityName}, ${stateName} + ${population} +
  • + `; + }).join(''); + suggestions.innerHTML = html; +} + +const searchInput = document.querySelector('.search'); +const suggestions = document.querySelector('.suggestions'); + +searchInput.addEventListener('change', displayMatches); +searchInput.addEventListener('keyup', displayMatches); diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/cardio.js similarity index 57% rename from 07 - Array Cardio Day 2/index-START.html rename to 07 - Array Cardio Day 2/cardio.js index bdf6c44415..ea69e79f11 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/cardio.js @@ -1,67 +1,83 @@ - - - - - Document - - - - - + console.table(newComments) + + + + + + + diff --git a/07 - Array Cardio Day 2/index-FINISHED.html b/07 - Array Cardio Day 2/index-FINISHED.html deleted file mode 100644 index e39d35f79a..0000000000 --- a/07 - Array Cardio Day 2/index-FINISHED.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - Document - - - - - diff --git a/07 - Array Cardio Day 2/index.html b/07 - Array Cardio Day 2/index.html new file mode 100644 index 0000000000..5b2b107a20 --- /dev/null +++ b/07 - Array Cardio Day 2/index.html @@ -0,0 +1,12 @@ + + + + + Document + + + + + diff --git a/08 - Fun with HTML5 Canvas/index-FINISHED.html b/08 - Fun with HTML5 Canvas/canvas.js similarity index 57% rename from 08 - Fun with HTML5 Canvas/index-FINISHED.html rename to 08 - Fun with HTML5 Canvas/canvas.js index 0791e17d0d..7510ea7a4e 100644 --- a/08 - Fun with HTML5 Canvas/index-FINISHED.html +++ b/08 - Fun with HTML5 Canvas/canvas.js @@ -1,21 +1,13 @@ - - - - - HTML5 Canvas - - - - - - - - - diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index.html similarity index 90% rename from 08 - Fun with HTML5 Canvas/index-START.html rename to 08 - Fun with HTML5 Canvas/index.html index 37c148df07..372be250cc 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index.html @@ -6,7 +6,7 @@ - - -
    -
    - -

    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/10 - Hold Shift and Check Checkboxes/index-START.html b/10 - Hold Shift and Check Checkboxes/index.html similarity index 98% rename from 10 - Hold Shift and Check Checkboxes/index-START.html rename to 10 - Hold Shift and Check Checkboxes/index.html index eb7ed310bb..7e2bb2591b 100644 --- a/10 - Hold Shift and Check Checkboxes/index-START.html +++ b/10 - Hold Shift and Check Checkboxes/index.html @@ -103,7 +103,7 @@ - diff --git a/11 - Custom Video Player/index.html b/11 - Custom Video Player/index.html index fe2b55b394..48b948c65f 100644 --- a/11 - Custom Video Player/index.html +++ b/11 - Custom Video Player/index.html @@ -19,6 +19,7 @@ + diff --git a/11 - Custom Video Player/scripts.js b/11 - Custom Video Player/scripts.js index e69de29bb2..4827cb310d 100644 --- a/11 - Custom Video Player/scripts.js +++ b/11 - Custom Video Player/scripts.js @@ -0,0 +1,76 @@ +//Get our elements +const player = document.querySelector('.player'); +const video = player.querySelector('.viewer'); +const progress = player.querySelector('.progress'); +const progressBar = player.querySelector('.progress__filled'); +const toggle = player.querySelector('.toggle'); +const skipButtons = player.querySelectorAll('[data-skip]'); +const ranges = player.querySelectorAll('.player__slider'); +const fullScreenButton = player.querySelector('.fullscreen') +console.log(fullScreenButton) + +//Build our functions +function togglePlay () { + const method = video.paused ? 'play' : 'pause'; + video[method](); +} + +function updateButton () { + const icon = this.paused ? 'β–Ί' : '❚ ❚'; + toggle.textContent = icon; +} + +function skip () { + video.currentTime += parseFloat(this.dataset.skip); +} + +function handleRangeUpdate () { + video[this.name] = this.value; +} + +function handleProgress () { + const percent = (video.currentTime / video.duration) * 100; + progressBar.style.flexBasis = `${percent}%`; +} + +function scrub (e) { + const scrubTime = (e.offsetX / progress.offsetWidth) * video.duration; + video.currentTime = scrubTime; +} + +function changeScreenSize() { + if(document.webkitFullscreenElement) { + document.webkitCancelFullScreen() + } else { + video.webkitRequestFullscreen(); + video.style.width = window.screen.width; + video.style.height = window.screen.height; + } +} + +//Hook up eventListeners +video.addEventListener('click', togglePlay); +video.addEventListener('play', updateButton); +video.addEventListener('pause', updateButton); +video.addEventListener('timeupdate', handleProgress); + +toggle.addEventListener('click', togglePlay); + +skipButtons.forEach(button => button.addEventListener('click', skip)); +fullScreenButton.addEventListener('click', changeScreenSize); + +ranges.forEach(range => range.addEventListener('change', + handleRangeUpdate)); +ranges.forEach(range => range.addEventListener('mousemove', + handleRangeUpdate)); + +let mousedown = false; + +progress.addEventListener('click', scrub); + +progress.addEventListener('mousemove', (e) => mousedown && scrub(e)); +progress.addEventListener('mousedown', () => mousedown = true); +progress.addEventListener('mouseup', () => mousedown = false); + + +//Next Up - Make the fullscreen button work! 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-FINISHED.html b/12 - Key Sequence Detection/index-FINISHED.html deleted file mode 100644 index 562127a0d2..0000000000 --- a/12 - Key Sequence Detection/index-FINISHED.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - Key Detection - - - - - - diff --git a/12 - Key Sequence Detection/index-START.html b/12 - Key Sequence Detection/index.html similarity index 91% rename from 12 - Key Sequence Detection/index-START.html rename to 12 - Key Sequence Detection/index.html index 8cab786140..d193e6b825 100644 --- a/12 - Key Sequence Detection/index-START.html +++ b/12 - Key Sequence Detection/index.html @@ -6,7 +6,7 @@ - diff --git a/12 - Key Sequence Detection/seq.js b/12 - Key Sequence Detection/seq.js new file mode 100644 index 0000000000..ae59b7ee9f --- /dev/null +++ b/12 - Key Sequence Detection/seq.js @@ -0,0 +1,20 @@ +const pressed = []; +const secretCode = 'wesbos'; + +window.addEventListener('keyup', (e) => { + pressed.push(e.key); + pressed.splice(-secretCode.length - 1, pressed.length - secretCode.length); + + if (pressed.join('').includes(secretCode)) { + console.log('DING DING!') + } +}) + + +//Starts at the end - goes -7 + +//Pressed +//["w", "e", "s", "b", "o", "s", "i"] + +//Spliced Press +//["e", "s", "b", "o", "s", "i"] \ No newline at end of file diff --git a/13 - Slide in on Scroll/index-FINISHED.html b/13 - Slide in on Scroll/index-FINISHED.html deleted file mode 100644 index bbaf0b6f22..0000000000 --- a/13 - Slide in on Scroll/index-FINISHED.html +++ /dev/null @@ -1,140 +0,0 @@ - - - - - Document - - - -
    - -

    Slide in on Scroll

    - -

    Consectetur adipisicing elit. Tempore tempora rerum, est autem cupiditate, corporis a qui libero ipsum delectus quidem dolor at nulla, adipisci veniam in reiciendis aut asperiores omnis blanditiis quod quas laborum nam! Fuga ad tempora in aspernatur pariaturlores sunt esse magni, ut, dignissimos.

    -

    Lorem ipsum cupiditate, corporis a qui libero ipsum delectus quidem dolor at nulla, adipisci veniam in reiciendis aut asperiores omnis blanditiis quod quas laborum nam! Fuga ad tempora in aspernatur pariatur fugit quibusdam dolores sunt esse magni, ut, dignissimos.

    -

    Adipisicing elit. Tempore tempora rerum..

    -

    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore tempora rerum, est autem cupiditate, corporis a qui libero ipsum delectus quidem dolor at nulla, adipisci veniam in reiciendis aut asperiores omnis blanditiis quod quas laborum nam! Fuga ad tempora in aspernatur pariatur fugit quibusdam dolores sunt esse magni, ut, dignissimos.

    -

    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore tempora rerum, est autem cupiditate, corporis a qui libero ipsum delectus quidem dolor at nulla, adipisci veniam in reiciendis aut asperiores omnis blanditiis quod quas laborum nam! Fuga ad tempora in aspernatur pariatur fugit quibusdam dolores sunt esse magni, ut, dignissimos.

    -

    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore tempora rerum, est autem cupiditate, corporis a qui libero ipsum delectus quidem dolor at nulla, adipisci veniam in reiciendis aut asperiores omnis blanditiis quod quas laborum nam! Fuga ad tempora in aspernatur pariatur fugit quibusdam dolores sunt esse magni, ut, dignissimos.

    - - - -

    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptates, deserunt facilis et iste corrupti omnis tenetur est. Iste ut est dicta dolor itaque adipisci, dolorum minima, veritatis earum provident error molestias. Ratione magni illo sint vel velit ut excepturi consectetur suscipit, earum modi accusamus voluptatem nostrum, praesentium numquam, reiciendis voluptas sit id quisquam. Consequatur in quis reprehenderit modi perspiciatis necessitatibus saepe, quidem, suscipit iure natus dignissimos ipsam, eligendi deleniti accusantium, rerum quibusdam fugit perferendis et optio recusandae sed ratione. Culpa, dolorum reprehenderit harum ab voluptas fuga, nisi eligendi natus maiores illum quas quos et aperiam aut doloremque optio maxime fugiat doloribus. Eum dolorum expedita quam, nesciunt

    - - - -

    at provident praesentium atque quas rerum optio dignissimos repudiandae ullam illum quibusdam. Vel ad error quibusdam, illo ex totam placeat. Quos excepturi fuga, molestiae ea quisquam minus, ratione dicta consectetur officia omnis, doloribus voluptatibus? Veniam ipsum veritatis architecto, provident quas consequatur doloremque quam quidem earum expedita, ad delectus voluptatum, omnis praesentium nostrum qui aspernatur ea eaque adipisci et cumque ab? Ea voluptatum dolore itaque odio. Eius minima distinctio harum, officia ab nihil exercitationem. Tempora rem nemo nam temporibus molestias facilis minus ipsam quam doloribus consequatur debitis nesciunt tempore officiis aperiam quisquam, molestiae voluptates cum, fuga culpa. Distinctio accusamus quibusdam, tempore perspiciatis dolorum optio facere consequatur quidem ullam beatae architecto, ipsam sequi officiis dignissimos amet impedit natus necessitatibus tenetur repellendus dolor rem! Dicta dolorem, iure, facilis illo ex nihil ipsa amet officia, optio temporibus eum autem odit repellendus nisi. Possimus modi, corrupti error debitis doloribus dicta libero earum, sequi porro ut excepturi nostrum ea voluptatem nihil culpa? Ullam expedita eligendi obcaecati reiciendis velit provident omnis quas qui in corrupti est dolore facere ad hic, animi soluta assumenda consequuntur reprehenderit! Voluptate dolor nihil veniam laborum voluptas nisi pariatur sed optio accusantium quam consectetur, corrupti, sequi et consequuntur, excepturi doloremque. Tempore quis velit corporis neque fugit non sequi eaque rem hic. Facere, inventore, aspernatur. Accusantium modi atque, asperiores qui nobis soluta cumque suscipit excepturi possimus doloremque odit saepe perferendis temporibus molestiae nostrum voluptatum quis id sint quidem nesciunt culpa. Rerum labore dolor beatae blanditiis praesentium explicabo velit optio esse aperiam similique, voluptatem cum, maiores ipsa tempore. Reiciendis sed culpa atque inventore, nam ullam enim expedita consectetur id velit iusto alias vitae explicabo nemo neque odio reprehenderit soluta sint eaque. Aperiam, qui ut tenetur, voluptate doloremque officiis dicta quaerat voluptatem rerum natus magni. Eum amet autem dolor ullam.

    - - - -

    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio maiores adipisci quibusdam repudiandae dolor vero placeat esse sit! Quibusdam saepe aperiam explicabo placeat optio, consequuntur nihil voluptatibus expedita quia vero perferendis, deserunt et incidunt eveniet temporibus doloremque possimus facilis. Possimus labore, officia dolore! Eaque ratione saepe, alias harum laboriosam deserunt laudantium blanditiis eum explicabo placeat reiciendis labore iste sint. Consectetur expedita dignissimos, non quos distinctio, eos rerum facilis eligendi. Asperiores laudantium, rerum ratione consequatur, culpa consectetur possimus atque ab tempore illum non dolor nesciunt. Neque, rerum. A vel non incidunt, quod doloremque dignissimos necessitatibus aliquid laboriosam architecto at cupiditate commodi expedita in, quae blanditiis. Deserunt labore sequi, repellat laboriosam est, doloremque culpa reiciendis tempore excepturi. Enim nostrum fugit itaque vel corporis ullam sed tenetur ipsa qui rem quam error sint, libero. Laboriosam rem, ratione. Autem blanditiis

    - - -

    laborum neque repudiandae quam, cumque, voluptate veritatis itaque, placeat veniam ad nisi. Expedita, laborum reprehenderit ratione soluta velit natus, odit mollitia. Corporis rerum minima fugiat in nostrum. Assumenda natus cupiditate hic quidem ex, quas, amet ipsum esse dolore facilis beatae maxime qui inventore, iste? Maiores dignissimos dolore culpa debitis voluptatem harum, excepturi enim reiciendis, tempora ab ipsam illum aspernatur quasi qui porro saepe iure sunt eligendi tenetur quaerat ducimus quas sequi omnis aperiam suscipit! Molestiae obcaecati officiis quo, ratione eveniet, provident pariatur. Veniam quasi expedita distinctio, itaque molestiae sequi, dolorum nisi repellendus quia facilis iusto dignissimos nam? Tenetur fugit quos autem nihil, perspiciatis expedita enim tempore, alias ab maiores quis necessitatibus distinctio molestias eum, quidem. Delectus impedit quidem laborum, fugit vel neque quo, ipsam, quasi aspernatur quas odio nihil? Veniam amet reiciendis blanditiis quis reprehenderit repudiandae neque, ab ducimus, odit excepturi voluptate saepe ipsam. Voluptatem eum error voluptas porro officiis, amet! Molestias, fugit, ut! Tempore non magnam, amet, facere ducimus accusantium eos veritatis neque.

    - - - -

    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio maiores adipisci quibusdam repudiandae dolor vero placeat esse sit! Quibusdam saepe aperiam explicabo placeat optio, consequuntur nihil voluptatibus expedita quia vero perferendis, deserunt et incidunt eveniet temporibus doloremque possimus facilis. Possimus labore, officia dolore! Eaque ratione saepe, alias harum laboriosam deserunt laudantium blanditiis eum explicabo placeat reiciendis labore iste sint. Consectetur expedita dignissimos, non quos distinctio, eos rerum facilis eligendi. Asperiores laudantium, rerum ratione consequatur, culpa consectetur possimus atque ab tempore illum non dolor nesciunt. Neque, rerum. A vel non incidunt, quod doloremque dignissimos necessitatibus aliquid laboriosam architecto at cupiditate commodi expedita in, quae blanditiis. Deserunt labore sequi, repellat laboriosam est, doloremque culpa reiciendis tempore excepturi. Enim nostrum fugit itaque vel corporis ullam sed tenetur ipsa qui rem quam error sint, libero. Laboriosam rem, ratione. Autem blanditiis laborum neque repudiandae quam, cumque, voluptate veritatis itaque, placeat veniam ad nisi. Expedita, laborum reprehenderit ratione soluta velit natus, odit mollitia. Corporis rerum minima fugiat in nostrum. Assumenda natus cupiditate hic quidem ex, quas, amet ipsum esse dolore facilis beatae maxime qui inventore, iste? Maiores dignissimos dolore culpa debitis voluptatem harum, excepturi enim reiciendis, tempora ab ipsam illum aspernatur quasi qui porro saepe iure sunt eligendi tenetur quaerat ducimus quas sequi omnis aperiam suscipit! Molestiae obcaecati officiis quo, ratione eveniet, provident pariatur. Veniam quasi expedita distinctio, itaque molestiae sequi, dolorum nisi repellendus quia facilis iusto dignissimos nam? Tenetur fugit quos autem nihil, perspiciatis expedita enim tempore, alias ab maiores quis necessitatibus distinctio molestias eum, quidem. Delectus impedit quidem laborum, fugit vel neque quo, ipsam, quasi aspernatur quas odio nihil? Veniam amet reiciendis blanditiis quis reprehenderit repudiandae neque, ab ducimus, odit excepturi voluptate saepe ipsam. Voluptatem eum error voluptas porro officiis, amet! Molestias, fugit, ut! Tempore non magnam, amet, facere ducimus accusantium eos veritatis neque.

    -

    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio maiores adipisci quibusdam repudiandae dolor vero placeat esse sit! Quibusdam saepe aperiam explicabo placeat optio, consequuntur nihil voluptatibus expedita quia vero perferendis, deserunt et incidunt eveniet temporibus doloremque possimus facilis. Possimus labore, officia dolore! Eaque ratione saepe, alias harum laboriosam deserunt laudantium blanditiis eum explicabo placeat reiciendis labore iste sint. Consectetur expedita dignissimos, non quos distinctio, eos rerum facilis eligendi. Asperiores laudantium, rerum ratione consequatur, culpa consectetur possimus atque ab tempore illum non dolor nesciunt. Neque, rerum. A vel non incidunt, quod doloremque dignissimos necessitatibus aliquid laboriosam architecto at cupiditate commodi expedita in, quae blanditiis. Deserunt labore sequi, repellat laboriosam est, doloremque culpa reiciendis tempore excepturi. Enim nostrum fugit itaque vel corporis ullam sed tenetur ipsa qui rem quam error sint, libero. Laboriosam rem, ratione. Autem blanditiis laborum neque repudiandae quam, cumque, voluptate veritatis itaque, placeat veniam ad nisi. Expedita, laborum reprehenderit ratione soluta velit natus, odit mollitia. Corporis rerum minima fugiat in nostrum. Assumenda natus cupiditate hic quidem ex, quas, amet ipsum esse dolore facilis beatae maxime qui inventore, iste? Maiores dignissimos dolore culpa debitis voluptatem harum, excepturi enim reiciendis, tempora ab ipsam illum aspernatur quasi qui porro saepe iure sunt eligendi tenetur quaerat ducimus quas sequi omnis aperiam suscipit! Molestiae obcaecati officiis quo, ratione eveniet, provident pariatur. Veniam quasi expedita distinctio, itaque molestiae sequi, dolorum nisi repellendus quia facilis iusto dignissimos nam? Tenetur fugit quos autem nihil, perspiciatis expedita enim tempore, alias ab maiores quis necessitatibus distinctio molestias eum, quidem. Delectus impedit quidem laborum, fugit vel neque quo, ipsam, quasi aspernatur quas odio nihil? Veniam amet reiciendis blanditiis quis reprehenderit repudiandae neque, ab ducimus, odit excepturi voluptate saepe ipsam. Voluptatem eum error voluptas porro officiis, amet! Molestias, fugit, ut! Tempore non magnam, amet, facere ducimus accusantium eos veritatis neque.

    - - - - -
    - - - - - - - diff --git a/13 - Slide in on Scroll/index-START.html b/13 - Slide in on Scroll/index.html similarity index 91% rename from 13 - Slide in on Scroll/index-START.html rename to 13 - Slide in on Scroll/index.html index 12591bad30..8bbcdb0778 100644 --- a/13 - Slide in on Scroll/index-START.html +++ b/13 - Slide in on Scroll/index.html @@ -42,42 +42,7 @@

    Slide in on Scroll

    - - - - - diff --git a/16 - Mouse Move Shadow/index.html b/16 - Mouse Move Shadow/index.html new file mode 100644 index 0000000000..bc20a47c21 --- /dev/null +++ b/16 - Mouse Move Shadow/index.html @@ -0,0 +1,37 @@ + + + + + Mouse Shadow + + + +
    +

    πŸ”₯WOAH!

    +
    + + + + + + diff --git a/16 - Mouse Move Shadow/mouse.js b/16 - Mouse Move Shadow/mouse.js new file mode 100644 index 0000000000..004c6339e7 --- /dev/null +++ b/16 - Mouse Move Shadow/mouse.js @@ -0,0 +1,69 @@ +const hero = document.querySelector('.hero'); +const text = hero.querySelector('h1'); +const walk = 100; //px + +function shadow (e) { + const { offsetWidth: width, offsetHeight: height } = hero; + let { offsetX: x, offsetY: y } = e; + + if (this !== e.target) { + x = x + e.target.offsetLeft; + y = y + e.target.offsetTop; + } + + const xWalk = Math.round(( x / width * walk ) - ( walk / 2 )); + const yWalk = Math.round(( y / height * walk ) - ( walk / 2 )); + + text.style.textShadow = ` + ${xWalk}px ${yWalk}px 0 rgba(255,0,255,0.7), + ${xWalk * -1}px ${yWalk}px 0 rgba(0,255,255,0.7), + ${yWalk}px ${xWalk * -1}px 0 rgba(0,255,0,0.7), + ${yWalk * -1}px ${xWalk}px 0 rgba(0,0,255,0.7) + `; + +} + +hero.addEventListener('mousemove', shadow); + + + + + + + + + + + + + + + + + + // const hero = document.querySelector('.hero'); + // const text = hero.querySelector('h1'); + // const walk = 500; // 100px + + // function shadow(e) { + // const { offsetWidth: width, offsetHeight: height } = hero; + // let { offsetX: x, offsetY: y } = e; + + // if (this !== e.target) { + // x = x + e.target.offsetLeft; + // y = y + e.target.offsetTop; + // } + + // const xWalk = Math.round((x / width * walk) - (walk / 2)); + // const yWalk = Math.round((y / height * walk) - (walk / 2)); + + // text.style.textShadow = ` + // ${xWalk}px ${yWalk}px 0 rgba(255,0,255,0.7), + // ${xWalk * -1}px ${yWalk}px 0 rgba(0,255,255,0.7), + // ${yWalk}px ${xWalk * -1}px 0 rgba(0,255,0,0.7), + // ${yWalk * -1}px ${xWalk}px 0 rgba(0,0,255,0.7) + // `; + + // } + + // hero.addEventListener('mousemove', shadow); \ No newline at end of file diff --git a/17 - Sort Without Articles/index-FINISHED.html b/17 - Sort Without Articles/index-FINISHED.html deleted file mode 100644 index 5de851cbbd..0000000000 --- a/17 - Sort Without Articles/index-FINISHED.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - Sort Without Articles - - - - - - - - - - - diff --git a/17 - Sort Without Articles/index-START.html b/17 - Sort Without Articles/index.html similarity index 76% rename from 17 - Sort Without Articles/index-START.html rename to 17 - Sort Without Articles/index.html index cfaf3e0440..139f973d6a 100644 --- a/17 - Sort Without Articles/index-START.html +++ b/17 - Sort Without Articles/index.html @@ -42,10 +42,7 @@ - diff --git a/17 - Sort Without Articles/sorting.js b/17 - Sort Without Articles/sorting.js new file mode 100644 index 0000000000..ed59e9288b --- /dev/null +++ b/17 - Sort Without Articles/sorting.js @@ -0,0 +1,14 @@ +const bands = ['The Plot in You', 'The Devil Wears Prada', 'Pierce the Veil', 'Norma Jean', 'The Bled', 'Say Anything', 'The Midway State', 'We Came as Romans', 'Counterparts', 'Oh, Sleeper', 'A Skylit Drive', 'Anywhere But Here', 'An Old Dog']; + +function strip(bandName) { + return bandName.replace(/^(a |the |an )/i, '').trim(); +} + +const sortedBands = bands.sort((firstBand, secondBand) => strip(firstBand) > strip(secondBand) ? 1 : -1); + +document.querySelector('#bands').innerHTML = sortedBands +.map(band => `
  • ${band}
  • `) +.join(''); + + +console.log(sortedBands) diff --git a/18 - Adding Up Times with Reduce/adding.js b/18 - Adding Up Times with Reduce/adding.js new file mode 100644 index 0000000000..8e85f868cb --- /dev/null +++ b/18 - Adding Up Times with Reduce/adding.js @@ -0,0 +1,22 @@ +const timeNodes = Array.from(document.querySelectorAll('[data-time]')); + + +//try putting this all in one reduce; + + +const seconds = timeNodes + .map(node => node.dataset.time) + .map(timeCode => { + const [mins, secs] = timeCode.split(':').map(parseFloat); + return (mins * 60) + secs; + }) + .reduce((total, vidSeconds) => total + vidSeconds) + +let secondsLeft = seconds; +const hours = Math.floor(secondsLeft / 3600); +secondsLeft = secondsLeft % 3600; + +const mins = Math.floor(secondsLeft/ 60); +secondsLeft = secondsLeft % 60; + +console.log(hours, mins, secondsLeft); diff --git a/18 - Adding Up Times with Reduce/index-FINISHED.html b/18 - Adding Up Times with Reduce/index-FINISHED.html deleted file mode 100644 index 9dcbb3d396..0000000000 --- a/18 - Adding Up Times with Reduce/index-FINISHED.html +++ /dev/null @@ -1,207 +0,0 @@ - - - - - Videos - - -