Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion 01 - JavaScript Drum Kit/index-START.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<body>


<div class="keys">
<div class="keys" id="keys">
<div data-key="65" class="key">
<kbd>A</kbd>
<span class="sound">clap</span>
Expand Down Expand Up @@ -58,7 +58,28 @@
<audio data-key="76" src="sounds/tink.wav"></audio>

<script>
var currentDiv;

function initKey(e) {
var key = e.keyCode || e.charCode;
var audio = document.querySelector('audio[data-key="'+ key +'"]');
currentDiv = document.querySelector('div[data-key="'+ key +'"]');

if(currentDiv) {
audio.currentTime = 0;
audio.play()
currentDiv.classList.add("playing")
}
}

function deleteKey() {
if(currentDiv) {
currentDiv.classList.remove("playing")
}

}
window.addEventListener("keydown", initKey);
window.addEventListener("keyup", deleteKey);
</script>


Expand Down
35 changes: 34 additions & 1 deletion 02 - JS and CSS Clock/index-START.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@


<style>
* {
margin: 0;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, do not use * selector dut to performance requierements

}
html {
background:#018DED url(http://unsplash.it/1500/1000?image=881&blur=50);
background-size:cover;
Expand Down Expand Up @@ -53,7 +56,7 @@
position: relative;
width: 100%;
height: 100%;
transform: translateY(-3px); /* account for the height of the clock hands */
transform: translateY(-3px) rotate(90deg);
}

.hand {
Expand All @@ -62,11 +65,41 @@
background:black;
position: absolute;
top:50%;
transform-origin: 100% 0;
}

.hour-hand {
transform: rotate(10deg);
}
</style>

<script>
var handHour = document.querySelector(".hour-hand");
var handMin = document.querySelector(".min-hand");
var handSec = document.querySelector(".second-hand");

var now = new Date();
var hours = null;
var minutes = null;
var seconds = null;

function setTime() {
handHour.style.transform = 'rotate(' + hours * 30 + 'deg)';
handMin.style.transform = 'rotate(' + minutes * 6 + 'deg)';
handSec.style.transform = 'rotate(' + seconds * 6 + 'deg)';
}
function result() {
now = new Date();
hours = now.getHours();
hours = hours > 12 ? hours - 12 : hours;
minutes = now.getMinutes();
seconds = now.getSeconds();

setTime();
return seconds;
}

setInterval(result, 1000);


</script>
Expand Down
32 changes: 28 additions & 4 deletions 03 - CSS Variables/index-START.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
<img src="https://source.unsplash.com/7bwQXzbF6KE/800x500">

<style>

/*
misc styles, nothing to do with CSS variables
*/
html {
--blur: 10px;
--spacing: 10px;
--base: #fff;
}

body {
text-align: center;
Expand All @@ -42,9 +43,32 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
input {
width:100px;
}

img {
filter: blur(var(--blur));
padding: var(--spacing);
background-color: var(--base);
}

</style>

<script>
const root = document.documentElement;
const blur = document.getElementById('blur');
const spacing = document.getElementById('spacing');
const base = document.getElementById('base');

blur.addEventListener('input', function () {
root.style.setProperty('--blur', blur.value + 'px');
})

spacing.addEventListener('input', function () {
root.style.setProperty('--spacing', spacing.value + 'px');
})

base.addEventListener('input', function () {
root.style.setProperty('--base', base.value);
})
</script>

</body>
Expand Down