Skip to content

Commit 917c26d

Browse files
committed
Reorganize file structure to avoid git rebasing issues
1 parent 6caea9e commit 917c26d

File tree

8 files changed

+752
-0
lines changed

8 files changed

+752
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>JS Drum Kit</title>
6+
<link rel="stylesheet" href="style.css">
7+
</head>
8+
<body>
9+
10+
11+
<div class="keys">
12+
<div data-key="65" class="key">
13+
<kbd>A</kbd>
14+
<span class="sound">clap</span>
15+
</div>
16+
<div data-key="83" class="key">
17+
<kbd>S</kbd>
18+
<span class="sound">hihat</span>
19+
</div>
20+
<div data-key="68" class="key">
21+
<kbd>D</kbd>
22+
<span class="sound">kick</span>
23+
</div>
24+
<div data-key="70" class="key">
25+
<kbd>F</kbd>
26+
<span class="sound">openhat</span>
27+
</div>
28+
<div data-key="71" class="key">
29+
<kbd>G</kbd>
30+
<span class="sound">boom</span>
31+
</div>
32+
<div data-key="72" class="key">
33+
<kbd>H</kbd>
34+
<span class="sound">ride</span>
35+
</div>
36+
<div data-key="74" class="key">
37+
<kbd>J</kbd>
38+
<span class="sound">snare</span>
39+
</div>
40+
<div data-key="75" class="key">
41+
<kbd>K</kbd>
42+
<span class="sound">tom</span>
43+
</div>
44+
<div data-key="76" class="key">
45+
<kbd>L</kbd>
46+
<span class="sound">tink</span>
47+
</div>
48+
</div>
49+
50+
<audio data-key="65" src="sounds/clap.wav"></audio>
51+
<audio data-key="83" src="sounds/hihat.wav"></audio>
52+
<audio data-key="68" src="sounds/kick.wav"></audio>
53+
<audio data-key="70" src="sounds/openhat.wav"></audio>
54+
<audio data-key="71" src="sounds/boom.wav"></audio>
55+
<audio data-key="72" src="sounds/ride.wav"></audio>
56+
<audio data-key="74" src="sounds/snare.wav"></audio>
57+
<audio data-key="75" src="sounds/tom.wav"></audio>
58+
<audio data-key="76" src="sounds/tink.wav"></audio>
59+
60+
<script>
61+
62+
63+
function playSound(e) {
64+
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
65+
const key = document.querySelector(`.key[data-key="${e.keyCode}"]`);
66+
if(!audio) return;
67+
audio.currentTime = 0;
68+
audio.play();
69+
key.classList.add('playing');
70+
}
71+
72+
function playSoundOnClick(e){
73+
keyCode = e.target.closest(".key").dataset.key;
74+
const audio = document.querySelector(`audio[data-key="${keyCode}"]`);
75+
const key = document.querySelector(`.key[data-key="${keyCode}"]`);
76+
if(!audio) return;
77+
audio.currentTime = 0;
78+
audio.play();
79+
key.classList.add('playing');
80+
console.log(keyCode);
81+
}
82+
83+
function removeTransition(e) {
84+
if(e.propertyName !== 'transform') return;
85+
this.classList.remove('playing');
86+
}
87+
88+
const keys = document.querySelectorAll('.key');
89+
keys.forEach(key => key.addEventListener('transitionend', removeTransition));
90+
keys.forEach(key => key.addEventListener('mousedown', playSoundOnClick));
91+
window.addEventListener('keydown', playSound);
92+
93+
</script>
94+
95+
96+
</body>
97+
</html>

02 - JS and CSS Clock/index.html

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>JS + CSS Clock</title>
6+
</head>
7+
<body>
8+
9+
10+
<div class="clock">
11+
<div class="clock-face">
12+
<div class="hand hour-hand"></div>
13+
<div class="hand min-hand"></div>
14+
<div class="hand second-hand"></div>
15+
</div>
16+
</div>
17+
18+
19+
<style>
20+
html {
21+
background:#018DED url(http://unsplash.it/1500/1000?image=881&blur=50);
22+
background-size:cover;
23+
font-family:'helvetica neue';
24+
text-align: center;
25+
font-size: 10px;
26+
}
27+
28+
body {
29+
font-size: 2rem;
30+
display:flex;
31+
flex:1;
32+
min-height: 100vh;
33+
align-items: center;
34+
}
35+
36+
.clock {
37+
width: 30rem;
38+
height: 30rem;
39+
border:20px solid white;
40+
border-radius:50%;
41+
margin:50px auto;
42+
position: relative;
43+
padding:2rem;
44+
box-shadow:
45+
0 0 0 4px rgba(0,0,0,0.1),
46+
inset 0 0 0 3px #EFEFEF,
47+
inset 0 0 10px black,
48+
0 0 10px rgba(0,0,0,0.2);
49+
}
50+
51+
.clock-face {
52+
position: relative;
53+
width: 100%;
54+
height: 100%;
55+
transform: translateY(-3px); /* account for the height of the clock hands */
56+
}
57+
58+
.hand {
59+
width:50%;
60+
height:6px;
61+
background:black;
62+
position: absolute;
63+
top:50%;
64+
transform-origin: 100%;
65+
transform: rotate(90deg);
66+
transition: all 0.5s;
67+
transition-timing-function: cubic-bezier(0.88, -0.46, 0.29, 1.93)
68+
}
69+
70+
</style>
71+
72+
<script>
73+
74+
const secondHand = document.querySelector('.second-hand');
75+
const minuteHand = document.querySelector('.min-hand');
76+
const hourHand = document.querySelector('.hour-hand');
77+
78+
var now = new Date();
79+
var seconds = now.getSeconds();
80+
var minutes = now.getMinutes();
81+
var hours = now.getHours() % 12;
82+
var secondDegrees = ((seconds / 60) * 360) + 90;
83+
var minuteDegrees = (minutes + seconds / 60) * 6 + 90;
84+
var hourDegrees = (hours + minutes / 60) * 30 + 90;
85+
86+
function updateClock(){
87+
console.log(new Date().getSeconds());
88+
secondHand.style.transform = `rotate(${secondDegrees}deg)`;
89+
minuteHand.style.transform = `rotate(${minuteDegrees}deg)`;
90+
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
91+
secondDegrees += 6;
92+
minuteDegrees += 6 / 60;
93+
hourDegrees += 30 / 60 / 60;
94+
}
95+
96+
setInterval(updateClock, 1000);
97+
98+
</script>
99+
</body>
100+
</html>

03 - CSS Variables/index.html

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Scoped CSS Variables and JS</title>
6+
</head>
7+
<body>
8+
<h2>Update CSS Variables with <span class='hl'>JS</span></h2>
9+
10+
<div class="controls">
11+
<label for="spacing">Spacing:</label>
12+
<input id="spacing" type="range" name="spacing" min="10" max="200" value="10" data-sizing="px">
13+
14+
<label for="blur">Blur:</label>
15+
<input id="blur" type="range" name="blur" min="0" max="25" value="10" data-sizing="px">
16+
17+
<label for="base">Base Color</label>
18+
<input id="base" type="color" name="base" value="#ffc600">
19+
</div>
20+
21+
<img src="https://source.unsplash.com/7bwQXzbF6KE/800x500">
22+
23+
<style>
24+
25+
:root {
26+
--base: #36c445;
27+
--spacing: 10px;
28+
--blur: 10px;
29+
}
30+
31+
img {
32+
padding: var(--spacing);
33+
background: var(--base);
34+
filter: blur(var(--blur));
35+
}
36+
37+
.hl {
38+
color: var(--base);
39+
}
40+
41+
/*
42+
misc styles, nothing to do with CSS variables
43+
*/
44+
45+
body {
46+
text-align: center;
47+
}
48+
49+
body {
50+
background: #193549;
51+
color: white;
52+
font-family: 'helvetica neue', sans-serif;
53+
font-weight: 100;
54+
font-size: 50px;
55+
}
56+
57+
.controls {
58+
margin-bottom: 50px;
59+
}
60+
61+
input {
62+
width:100px;
63+
}
64+
</style>
65+
66+
<script>
67+
68+
69+
const inputs = document.querySelectorAll('.controls input');
70+
71+
function handleUpdate() {
72+
const suffix = this.dataset.sizing || '';
73+
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix);
74+
}
75+
76+
inputs.forEach(input => input.addEventListener('change', handleUpdate));
77+
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate));
78+
79+
</script>
80+
81+
</body>
82+
</html>
83+
84+
85+
86+
87+
88+
89+
90+
91+
92+
93+
94+
95+
96+

04 - Array Cardio Day 1/index.html

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Array Cardio 💪</title>
6+
</head>
7+
<body>
8+
<p><em>Psst: have a look at the JavaScript Console</em> 💁</p>
9+
<script>
10+
// Get your shorts on - this is an array workout!
11+
// ## Array Cardio Day 1
12+
13+
// Some data we can work with
14+
15+
const inventors = [
16+
{ first: 'Albert', last: 'Einstein', year: 1879, passed: 1955 },
17+
{ first: 'Isaac', last: 'Newton', year: 1643, passed: 1727 },
18+
{ first: 'Galileo', last: 'Galilei', year: 1564, passed: 1642 },
19+
{ first: 'Marie', last: 'Curie', year: 1867, passed: 1934 },
20+
{ first: 'Johannes', last: 'Kepler', year: 1571, passed: 1630 },
21+
{ first: 'Nicolaus', last: 'Copernicus', year: 1473, passed: 1543 },
22+
{ first: 'Max', last: 'Planck', year: 1858, passed: 1947 },
23+
{ first: 'Katherine', last: 'Blodgett', year: 1898, passed: 1979 },
24+
{ first: 'Ada', last: 'Lovelace', year: 1815, passed: 1852 },
25+
{ first: 'Sarah E.', last: 'Goode', year: 1855, passed: 1905 },
26+
{ first: 'Lise', last: 'Meitner', year: 1878, passed: 1968 },
27+
{ first: 'Hanna', last: 'Hammarström', year: 1829, passed: 1909 }
28+
];
29+
30+
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'];
31+
32+
// Array.prototype.filter()
33+
// 1. Filter the list of inventors for those who were born in the 1500's
34+
const fifteen = inventors.filter(inventor => inventor.year >= 1500 && inventor.year < 1600);
35+
console.table(fifteen);
36+
37+
// Array.prototype.map()
38+
// 2. Give us an array of the inventors' first and last names
39+
const fullNames = inventors.map(inventor => `${inventor.first} ${inventor.last}` );
40+
41+
console.log(fullNames);
42+
43+
// Array.prototype.sort()
44+
// 3. Sort the inventors by birthdate, oldest to youngest
45+
const orderered = inventors.sort((a, b) => a.year > b.year ? 1 : -1);
46+
47+
console.table(orderered);
48+
49+
// Array.prototype.reduce()
50+
// 4. How many years did all the inventors live?
51+
const totalYears = inventors.reduce((total, inventor) => {
52+
return total + (inventor.passed - inventor.year);
53+
}, 0);
54+
// const yearsLived = inventors.reduce(function(sum, inventor){
55+
// return sum + (inventor.passed - inventor.year);
56+
// });
57+
58+
console.log(totalYears);
59+
60+
// 5. Sort the inventors by years lived
61+
62+
const yearsLived = inventors.sort((a, b) => (a.passed - a.year) > (b.passed - b.year) ? 1 : -1);
63+
64+
console.table(yearsLived);
65+
66+
// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name
67+
// https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris
68+
const links = Array.from(document.querySelectorAll('.mw-category-group a'));
69+
const names = links
70+
.filter(link => link.textContent.includes("de"))
71+
.map(link => link.textContent);
72+
73+
console.log(names);
74+
75+
// 7. sort Exercise
76+
// Sort the people alphabetically by last name
77+
const lastNames = people.sort((a, b) => (a > b) ? 1 : -1);
78+
79+
console.table(lastNames);
80+
81+
82+
// 8. Reduce Exercise
83+
// Sum up the instances of each of these
84+
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck', 'horse' ];
85+
86+
const transportation = data.reduce(function(obj, item){
87+
if ( !obj[item] ){
88+
obj[item] = 0;
89+
}
90+
obj[item]++;
91+
return obj;
92+
}, {});
93+
94+
console.log(transportation);
95+
96+
</script>
97+
</body>
98+
</html>

0 commit comments

Comments
 (0)