From bb5474e91b1d8414da28e9dfaa5c5483a41ecea0 Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Tue, 20 Dec 2016 15:07:32 -0500 Subject: [PATCH 01/29] completed drum kit --- 01 - JavaScript Drum Kit/index-START.html | 92 +++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..894d769fed 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -58,7 +58,99 @@ From f820785da6246c7a3689f76308509ae0b37d5a83 Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Wed, 21 Dec 2016 14:37:07 -0500 Subject: [PATCH 02/29] completed clock --- 02 - JS + CSS Clock/index-START.html | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..9b7ac9a3f6 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-origin: 100%; + transform: rotate(90deg); + transition: all 0.05s; + /*transition-timing-function: cubic-bezier(0, 2.68, 0.98, 1.04);*/ } From f079ab4cc8fc3f22789bd4ace03c4e88e81e9031 Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Wed, 21 Dec 2016 19:39:53 -0500 Subject: [PATCH 03/29] completed exercise --- 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 7171607a8b..b13edc6320 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -21,7 +21,21 @@

Update CSS Variables with JS

From c086ece712044e0a475037abec2f4989f07bcf7f Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Thu, 22 Dec 2016 14:54:49 -0500 Subject: [PATCH 04/29] completed exercise --- 04 - Array Cardio Day 1/index-START.html | 55 +++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 4162bce339..c95d82974e 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -33,29 +33,82 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + let filter = inventors.filter((element, index) => { + return element.year < 1600 && element.year >= 1500 + }) + console.log(filter) // Array.prototype.map() // 2. Give us an array of the inventors' first and last names + let result = inventors.map(inventor => `${inventor.first}, ${inventor.last}`) + console.log(result) // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + inventors.sort((inventor1, inventor2) => { + if (inventor1.year < inventor2.year) return -1; + if (inventor1.year > inventor2.year) return 1; + return 0; + }) + + console.log(inventors) // Array.prototype.reduce() // 4. How many years did all the inventors live? - + let yearCount = inventors.reduce((initialVal, currentVal) => { + return initialVal += (currentVal.passed - currentVal.year) + },0) + console.log(yearCount) // 5. Sort the inventors by years lived + inventors.sort((inventor, inventor2) => { + if (inventor.passed - inventor.year > inventor2.passed-inventor2.year) { + return -1; + } + if (inventor.passed - inventor.year < inventor2.passed-inventor2.year) { + return 1; + } + }) + console.log(inventors) // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name // https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris + // Boulevards.map(index => { + // if (index.indexOf('de') > -1) { + // return index; + // } + // }) // 7. sort Exercise // Sort the people alphabetically by last name + people.sort((person1, person2) => { + let lastNameIndex = person1.indexOf(',') + 2; + let lastNameIndex2 = person2.indexOf(',') + 2; + if (person1[lastNameIndex] < person2[lastNameIndex2]) { + return -1; + } + if (person1[lastNameIndex] > person2[lastNameIndex2]) { + return 1; + } + // console.log(person1[lastNameIndex]) + }) + console.log(people) + // 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' ]; + let redResult = data.reduce((obj, word) => { + if (!obj[word]) { + obj[word] = 0; + } + obj[word] ++; + return obj; + },{}) + + console.log(redResult) + From 15922d972488d1e276bd4c7d5c68f0653616e9b8 Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Fri, 23 Dec 2016 22:03:19 -0500 Subject: [PATCH 05/29] completed exercise - helpful for filtering search results in future --- 06 - Type Ahead/index-START.html | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 1436886918..86784e1f70 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -17,6 +17,48 @@ From 5d54c22d9f233263705ce4e3fb63c859cec2a199 Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Sat, 24 Dec 2016 11:09:42 -0500 Subject: [PATCH 06/29] finished exercise --- 07 - Array Cardio Day 2/index-START.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 206ec31aa0..30b7940136 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -26,15 +26,26 @@ // Some and Every Checks // Array.prototype.some() // is at least one person 19? + let someCheck = people.some(person => 2016 - person.year >= 19) + console.log(someCheck) + // Array.prototype.every() // is everyone 19? + let everyCheck = people.every(person => 2016 - person.year === 19) + console.log(everyCheck) + // 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 + let findResult = comments.find(comment => comment.id === 823423) + console.log(findResult) // Array.prototype.findIndex() // Find the comment with this ID // delete the comment with the ID of 823423 + let result = comments.findIndex(comment => comment.id === 823423) + comments.splice(result, 1) + console.log(comments) From fa147173951d33d9cb67e0588fae1db8fd864f78 Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Tue, 27 Dec 2016 17:01:58 -0500 Subject: [PATCH 07/29] finished exercise --- 08 - Fun with HTML5 Canvas/index-START.html | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html index 37c148df07..0cfc6bc2f9 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -7,6 +7,41 @@ From 4de4fa0fa3914a7027a3acbb7f7eff4171163ab3 Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Mon, 2 Jan 2017 16:55:26 -0500 Subject: [PATCH 14/29] finished exercise --- 17 - Sort Without Articles/index-START.html | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/17 - Sort Without Articles/index-START.html b/17 - Sort Without Articles/index-START.html index cfaf3e0440..a1ccffe159 100644 --- a/17 - Sort Without Articles/index-START.html +++ b/17 - Sort Without Articles/index-START.html @@ -45,6 +45,37 @@ From dc80c94ebd12a9cc6f9083891ef28af51bb82591 Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Mon, 2 Jan 2017 18:02:26 -0500 Subject: [PATCH 15/29] finished exercise --- .../index-START.html | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/18 - Adding Up Times with Reduce/index-START.html b/18 - Adding Up Times with Reduce/index-START.html index 3eaee0f3ef..c05400d7e2 100644 --- a/18 - Adding Up Times with Reduce/index-START.html +++ b/18 - Adding Up Times with Reduce/index-START.html @@ -182,6 +182,29 @@ From e3f876c519ab5f25da0cc7ab739b3630db98f63d Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Tue, 3 Jan 2017 15:14:45 -0500 Subject: [PATCH 16/29] completed exercise --- 19 - Webcam Fun/index.html | 4 +- 19 - Webcam Fun/scripts.js | 95 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 2 deletions(-) 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..5183c4b6e6 100644 --- a/19 - Webcam Fun/scripts.js +++ b/19 - Webcam Fun/scripts.js @@ -3,3 +3,98 @@ const canvas = document.querySelector('.photo'); const ctx = canvas.getContext('2d'); const strip = document.querySelector('.strip'); const snap = document.querySelector('.snap'); + +// video comes off webcame (video element) and we pipe it into the canvas. strip is where we put images + +function getVideo() { + navigator.mediaDevices.getUserMedia({video: true, audio: false}) + .then(localMediaStream => { + video.src = window.URL.createObjectURL(localMediaStream); + video.play(); + }) + .catch(err => console.error("Webcam access was denied", 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); + // retrieve the pixels + let pixels = ctx.getImageData(0,0, width, height); + // add effect to pixels + // pixels = redEffect(pixels); + // pixels = rgbSplit(pixels); + // ctx.globalAlpha = 0.1; + pixels = greenScreen(pixels); + + // put pixels back + ctx.putImageData(pixels, 0, 0); + }, 16); +} + +function takePhoto() { + // play camera snap audio + snap.currentTime = 0; + snap.play(); + + //take data out of canvas + const data = canvas.toDataURL('image/jpeg'); + const link = document.createElement('a'); + link.href = data; + link.setAttribute('download', 'handsome'); + link.innerHTML = `handsome person` + strip.insertBefore(link, strip.firstChild) +} + +function redEffect(pixels) { + for (let i = 0; i < pixels.data.length; i += 4) { + pixels.data[i] = pixels.data[i] + 100; // r + pixels.data[i + 1] = pixels.data[i + 1] - 50; // g + pixels.data[i + 2] = pixels.data[i + 2] * 0.5; // b + } + return pixels +} + +function rgbSplit(pixels) { + for (let i = 0; i < pixels.data.length; i += 4) { + pixels.data[i - 150] = pixels.data[i]; // r + pixels.data[i + 400] = pixels.data[i + 1]; // g + pixels.data[i - 550] = pixels.data[i + 2]; // b + } + 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 4cc666427914e3a3226ff8c42f6999f7394283d9 Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Fri, 6 Jan 2017 11:56:57 -0500 Subject: [PATCH 17/29] completed exercise --- 20 - Speech Detection/index-START.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/20 - Speech Detection/index-START.html b/20 - Speech Detection/index-START.html index d3395cca35..3728745ff5 100644 --- a/20 - Speech Detection/index-START.html +++ b/20 - Speech Detection/index-START.html @@ -12,6 +12,27 @@ From 24c504c103597faba331dfc7540a57cfb5c704e3 Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Fri, 6 Jan 2017 15:39:27 -0500 Subject: [PATCH 18/29] completed exercise --- 21 - Geolocation/index-START.html | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/21 - Geolocation/index-START.html b/21 - Geolocation/index-START.html index d794c144ba..2c4236ef44 100644 --- a/21 - Geolocation/index-START.html +++ b/21 - Geolocation/index-START.html @@ -57,17 +57,19 @@

/*Compass: https://thenounproject.com/search/?q=compass&i=592352*/ From 618e15724422e130c4aee13221dde6470aabd978 Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Sat, 7 Jan 2017 17:34:10 -0500 Subject: [PATCH 19/29] completed exercise --- .../index-START.html | 21 ++++++++++++++++++- 22 - Follow Along Link Highlighter/style.css | 4 ++++ 2 files changed, 24 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..1527dec258 100644 --- a/22 - Follow Along Link Highlighter/index-START.html +++ b/22 - Follow Along Link Highlighter/index-START.html @@ -26,7 +26,26 @@ diff --git a/22 - Follow Along Link Highlighter/style.css b/22 - Follow Along Link Highlighter/style.css index 222e27ae68..598671fff5 100644 --- a/22 - Follow Along Link Highlighter/style.css +++ b/22 - Follow Along Link Highlighter/style.css @@ -57,3 +57,7 @@ a { margin:0 20px; color:black; } + +.hidden { + visibility: hidden; +} From ac5f3f01c689b7f5dc258e652abe9871c73a69e5 Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Sun, 8 Jan 2017 17:44:19 -0500 Subject: [PATCH 20/29] completed exercise --- 23 - Speech Synthesis/index-START.html | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/23 - Speech Synthesis/index-START.html b/23 - Speech Synthesis/index-START.html index e890008d36..6f7fb042c5 100644 --- a/23 - Speech Synthesis/index-START.html +++ b/23 - Speech Synthesis/index-START.html @@ -35,6 +35,58 @@

The Voiceinator 5000

const options = document.querySelectorAll('[type="range"], [name="text"]'); const speakButton = document.querySelector('#speak'); const stopButton = document.querySelector('#stop'); + const synth = window.speechSynthesis; + const form = document.querySelector('textarea'); + + function speakFn() { + msg.text = form.value; + synth.speak(msg) + } + + function stopSpeaking() { + synth.cancel(); + } + + function handleChange() { + let name = this.name; + msg[`${name}`] = this.value; + synth.cancel(); + speakFn() + } + + speakButton.addEventListener('click', speakFn) + stopButton.addEventListener('click', stopSpeaking) + options.forEach(option => { + option.addEventListener('change', handleChange) + }) + + let item = document.createElement('option'); + + let timer = setInterval(function() { + voices = synth.getVoices(); + voices = voices.filter(voice => { + return voice.lang.includes('en') + }) + + if (voices.length !== 0) { + voices.map((voice, index) => { + item = document.createElement('option'); + item.value = index; + item.textContent = voice.name; + voicesDropdown.appendChild(item) + }) + clearInterval(timer); + } +}, 200); + + function selectVoice() { + msg.voice = voices[this.value]; + synth.cancel(); + speakFn(); + } + + voicesDropdown.addEventListener('change', selectVoice) + From 61fd44c194a4c1857236f2a71f0f7c5956c72dd7 Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Sun, 8 Jan 2017 20:11:07 -0500 Subject: [PATCH 21/29] completed exercise - useful navbar --- 24 - Sticky Nav/index-START.html | 18 ++++++++++++++++++ 24 - Sticky Nav/style-START.css | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/24 - Sticky Nav/index-START.html b/24 - Sticky Nav/index-START.html index e7bc67e9a5..06a7c64f54 100644 --- a/24 - Sticky Nav/index-START.html +++ b/24 - Sticky Nav/index-START.html @@ -55,6 +55,24 @@

A story about getting lost.

diff --git a/24 - Sticky Nav/style-START.css b/24 - Sticky Nav/style-START.css index c6d59a31b3..b772633214 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; +} + +.fixed-nav .site-wrap { + transform: scale(1); +} From 640acc5b23ba09580352135bd88260b607af8f4d Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Sun, 8 Jan 2017 20:31:03 -0500 Subject: [PATCH 22/29] finished exercise --- .../index-START.html | 8 ++++++++ 1 file changed, 8 insertions(+) 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..619afc5b04 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 @@ From 9dece2e709efbf2105b1cec18dd857eecbf6f62e Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Mon, 9 Jan 2017 15:43:00 -0500 Subject: [PATCH 23/29] finished awesome exercise --- 26 - Stripe Follow Along Nav/index-START.html | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/26 - Stripe Follow Along Nav/index-START.html b/26 - Stripe Follow Along Nav/index-START.html index 9780d0d1ac..75c964fee0 100644 --- a/26 - Stripe Follow Along Nav/index-START.html +++ b/26 - Stripe Follow Along Nav/index-START.html @@ -208,6 +208,34 @@

Cool

From 93c86339c8652aa1be7f3acd5225bb1b70e08fec Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Mon, 9 Jan 2017 16:15:23 -0500 Subject: [PATCH 24/29] finished exercise --- 27 - Click and Drag/index-START.html | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/27 - Click and Drag/index-START.html b/27 - Click and Drag/index-START.html index b8609315f7..c16c593455 100644 --- a/27 - Click and Drag/index-START.html +++ b/27 - Click and Drag/index-START.html @@ -35,6 +35,43 @@ From db655348712611fb991c591a94abcbe413f4e7cc Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Tue, 10 Jan 2017 18:29:26 -0500 Subject: [PATCH 25/29] completed exercise --- 28 - Video Speed Controller/index-START.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/28 - Video Speed Controller/index-START.html b/28 - Video Speed Controller/index-START.html index c4cbd4259a..d85f9d7b29 100644 --- a/28 - Video Speed Controller/index-START.html +++ b/28 - Video Speed Controller/index-START.html @@ -15,6 +15,24 @@ From 335271cac3f816b75c47c48107cd58e0e2590ec6 Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Tue, 17 Jan 2017 21:36:28 -0500 Subject: [PATCH 26/29] finished exercise --- 29 - Countdown Timer/scripts-START.js | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/29 - Countdown Timer/scripts-START.js b/29 - Countdown Timer/scripts-START.js index e69de29bb2..106362e432 100644 --- a/29 - Countdown Timer/scripts-START.js +++ b/29 - Countdown Timer/scripts-START.js @@ -0,0 +1,55 @@ +let timeLeftElement = document.querySelector('.display__time-left'); +let endTimeElement = document.querySelector('.display__end-time'); +let buttons = document.querySelectorAll('button'); +let form = document.querySelector('[name=customForm'); +let input = form.querySelector('input'); +let countdown; + +function startTimer() { + timer(this.dataset.time); +} + +function timer(seconds) { + clearInterval(countdown); + let now = Date.now(); + let then = now + seconds * 1000; + displayTimeLeft(seconds); + displayEndTime(then); + + countdown = setInterval(() => { + let secondsLeft = Math.round((then - Date.now()) / 1000); + + if (secondsLeft < 1) { + clearInterval(countdown); + } + + displayTimeLeft(secondsLeft); + }, 1000); + +} + +function displayTimeLeft(seconds) { + let minutes = Math.floor(seconds / 60); + let remainingSeconds = seconds % 60; + timeLeftElement.innerHTML = `${minutes}:${remainingSeconds < 10 ? '0' : ''}${remainingSeconds}`; + document.title = timeLeftElement.innerHTML; +} + +function displayEndTime(timestamp) { + const endTime = new Date(timestamp); + let hours = endTime.getHours(); + const minutes = endTime.getMinutes(); + endTimeElement.innerHTML = `Be back at ${hours > 12 ? hours-= 12 : hours}:${minutes < 10 ? '0' : ''}${minutes}`; +} + + +buttons.forEach(button => { + button.addEventListener('click', startTimer); +}) + +form.addEventListener('submit', (e) => { + e.preventDefault(); + let minutes = input.value; + form.reset(); + timer(minutes * 60); +}); From a20aa28bb2778e6ec583b13b7dc0446244dbaf1f Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Tue, 17 Jan 2017 23:57:25 -0500 Subject: [PATCH 27/29] finished exercise --- 05 - Flex Panel Gallery/index-START.html | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index e1d643ad5c..cca12893d9 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,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 > *:last-child { + transform: translateY(100%); } .panel p { @@ -62,12 +80,22 @@ text-shadow:0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45); font-size: 2em; } + + .panel.open-active > *:first-child { + transform: translateY(0); + } + + .panel.open-active > *:last-child { + transform: translateY(0); + } + .panel p:nth-child(2) { font-size: 4em; } .panel.open { font-size:40px; + flex: 5; } .cta { @@ -108,6 +136,22 @@ From 99628bc6df3972bf576444ea772ee6f7b8137b2e Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Wed, 18 Jan 2017 19:03:18 -0500 Subject: [PATCH 28/29] completed 30 day challenge --- 30 - Whack A Mole/index-START.html | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/30 - Whack A Mole/index-START.html b/30 - Whack A Mole/index-START.html index 2014ff458c..f813eddaa6 100644 --- a/30 - Whack A Mole/index-START.html +++ b/30 - Whack A Mole/index-START.html @@ -36,6 +36,53 @@

Whack-a-mole! 0

const holes = document.querySelectorAll('.hole'); const scoreBoard = document.querySelector('.score'); const moles = document.querySelectorAll('.mole'); + let lastHole; + let timeUp = false; + + function randomTime(min, max) { + return Math.round(Math.random() * (max-min) + min); + } + + function randomHole(holes) { + let index = Math.floor(Math.random() * holes.length); + let 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 addPoint(e) { + // will exit if detects fake click + if (!e.isTrusted) return; + scoreBoard.textContent = Number(scoreBoard.textContent) + 1; + this.classList.remove('up'); + } + + + function startGame() { + scoreBoard.textContent = 0; + timeUp = false; + + moles.forEach(mole => { + mole.addEventListener('click', addPoint); + }) + + peep(); + setTimeout(() => clearInterval(() => timeUp = true), 10000); + + } From fa90d218d8ce1a74c0d386e9f0a42a465c2b2f77 Mon Sep 17 00:00:00 2001 From: Brandon Culp Date: Wed, 18 Jan 2017 19:09:44 -0500 Subject: [PATCH 29/29] fixed game timing issue --- 30 - Whack A Mole/index-START.html | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/30 - Whack A Mole/index-START.html b/30 - Whack A Mole/index-START.html index f813eddaa6..8733e804fc 100644 --- a/30 - Whack A Mole/index-START.html +++ b/30 - Whack A Mole/index-START.html @@ -74,16 +74,14 @@

Whack-a-mole! 0

function startGame() { scoreBoard.textContent = 0; timeUp = false; + peep(); + setTimeout(() => timeUp = true, 10000); + } moles.forEach(mole => { mole.addEventListener('click', addPoint); }) - peep(); - setTimeout(() => clearInterval(() => timeUp = true), 10000); - - } -