Skip to content

Commit 8207d2b

Browse files
committed
Completed project 1
1 parent f3f7116 commit 8207d2b

File tree

6 files changed

+110
-6
lines changed

6 files changed

+110
-6
lines changed

β€Ž.devcontainer/Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#-------------------------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
4+
#-------------------------------------------------------------------------------------------------------------
5+
6+
# To fully customize the contents of this image, use the following Dockerfile instead:
7+
# https://github.com/microsoft/vscode-dev-containers/tree/v0.101.0/containers/typescript-node-12/.devcontainer/Dockerfile
8+
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-12
9+
10+
# ** [Optional] Uncomment this section to install additional packages. **
11+
#
12+
# ENV DEBIAN_FRONTEND=noninteractive
13+
# RUN apt-get update \
14+
# && apt-get -y install --no-install-recommends <your-package-list-here> \
15+
# #
16+
# # Clean up
17+
# && apt-get autoremove -y \
18+
# && apt-get clean -y \
19+
# && rm -rf /var/lib/apt/lists/*
20+
# ENV DEBIAN_FRONTEND=dialog
21+

β€Ž.devcontainer/devcontainer.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.101.0/containers/typescript-node-12
3+
{
4+
"name": "Node.js 12 & TypeScript",
5+
"dockerFile": "Dockerfile",
6+
// Set *default* container specific settings.json values on container create.
7+
"settings": {
8+
"terminal.integrated.shell.linux": "/bin/bash"
9+
},
10+
// Add the IDs of extensions you want installed when the container is created.
11+
"extensions": [
12+
"dbaeumer.vscode-eslint",
13+
"ms-vscode.vscode-typescript-tslint-plugin",
14+
"ritwickdey.liveserver"
15+
],
16+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
17+
"forwardPorts": [
18+
5500
19+
],
20+
// Use 'postCreateCommand' to run commands after the container is created.
21+
// "postCreateCommand": "yarn install",
22+
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
23+
// "remoteUser": "node"
24+
}

β€Ž01 - JavaScript Drum Kit/index-START.html

+1-5
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@
5757
<audio data-key="75" src="sounds/tom.wav"></audio>
5858
<audio data-key="76" src="sounds/tink.wav"></audio>
5959

60-
<script>
61-
62-
</script>
63-
64-
60+
<script src="typescripts.js"></script>
6561
</body>
6662
</html>
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var keys = document.querySelector('.keys');
2+
function handleKey(e) {
3+
var audio = document.querySelector("audio[data-key=\"" + e.keyCode + "\"]");
4+
if (!audio)
5+
return;
6+
var key = document.querySelector(".key[data-key=\"" + e.keyCode + "\"]");
7+
audio.currentTime = 0;
8+
audio.play();
9+
key.classList.add('playing');
10+
}
11+
function handleEnd(e) {
12+
if (e.propertyName !== 'transform')
13+
return;
14+
e.target.classList.remove('playing');
15+
}
16+
document.addEventListener('keydown', handleKey);
17+
keys.addEventListener('transitionend', handleEnd);
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* JavaScript30 by Wes Bos, https://javascript30.com/
3+
* TypeScript implementation by Will Wager https://willwager.dev
4+
* Project: TypeScript Drum Kit
5+
* Concepts:
6+
* keyCodes, Audio, transitionend events
7+
* Key takeaways:
8+
* Attribute selectors, HTMLAudioElement properties and methods, classList usage, and
9+
* using transitionend events to keep the visuals in sync.
10+
* Sidenotes:
11+
* keyCode is deprecated, but the replacement 'code' is not implemented in Edge and IE.
12+
* The sound is reset when pressed multiple times, but the visual state is not so there
13+
* is a flicker when holding the key.
14+
*/
15+
16+
const keys = document.querySelector('.keys');
17+
18+
function handleKey(e) {
19+
const audio: HTMLAudioElement = document.querySelector(`audio[data-key="${e.keyCode}"]`);
20+
if (!audio) return;
21+
const key = document.querySelector(`.key[data-key="${e.keyCode}"]`);
22+
audio.currentTime = 0;
23+
audio.play();
24+
25+
key.classList.add('playing');
26+
}
27+
28+
// Updated to use event delegation here.
29+
function handleEnd(e) {
30+
if (e.propertyName !== 'transform') return;
31+
e.target.classList.remove('playing');
32+
}
33+
34+
document.addEventListener('keydown', handleKey);
35+
keys.addEventListener('transitionend', handleEnd);

β€Žreadme.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
![](https://javascript30.com/images/JS3-social-share.png)
22

3+
Will Wager's TypeScript solutions for Wes Bos's...
34
# JavaScript30
45

6+
Run them yourself from a VS Code container!
7+
* Open in vscode and run `Remote Containers: Reopen in Container` from the command palette.
8+
* Build each TypeScript file with `tsc typescripts.ts` from each project's folder.
9+
* All html files have been adjusted to look for typescripts.js.
10+
* I use the options `--target es5 --removeComments` in my js builds.
11+
* Press ALT + L, ALT + O to start the Live Server extension and access the html files at http://localhost:5500 + the relative path.
12+
* For example, to open the first project, go to (replace spaces with '20%' if your browser complains): `http://localhost:5500/01%20-%20JavaScript%20Drum%20Kit/index-START.html`
13+
14+
----
15+
516
Starter Files + Completed solutions for the JavaScript 30 Day Challenge.
617

718
Grab the course at [https://JavaScript30.com](https://JavaScript30.com)
@@ -39,7 +50,7 @@ Feel free to submit a PR adding a link to your own recaps, guides or reviews!
3950
* [Yusong Notes](https://sky172839465.github.io/course/js30) Records Yusong JS 30 days note and demo :star2:
4051
* [Ding's Implementation](https://github.com/Ding-Fan/javascript30) code and online demo
4152
* [Herminio Torres](https://github.com/herminiotorres/JavaScript30) lessons and tricks learned, and a [gh-page](https://herminiotorres.github.io/JavaScript30/) to see working all the mini-projects.
42-
* [Dmytro Borysovskyi](https://github.com/dimabory) says many thanks to for the course to Wes 🀝 It was incredible challenge πŸ‘Œ The full repository with code available [here](https://github.com/dimabory/dimabory.github.io/tree/gh-pages/src/components/JavaScript30Days) and demos can be reached by the link to [gh-pages](https://dimabory.github.io/#/js30days) πŸ‘πŸ‘πŸ‘
53+
* [Dmytro Borysovskyi](https://github.com/dimabory) says many thanks to for the course to Wes 🀝 It was incredible challenge πŸ‘Œ The full repository with code available [here](https://github.com/dimabory/dimabory.github.io/tree/gh-pages/src/components/JavaScript30Days) and demos can be reached by the link to [gh-pages](https://dimabory.github.io/#/js30days) πŸ‘πŸ‘πŸ‘
4354
* [Kizito](https://github.com/akhilome/)'s follow along [repo](https://github.com/akhilome/js30) with [completed challenges](https://akhilome.github.io/js30) and [notes](https://akhilome.github.io/js30/notes).
4455
* [VannTile](https://github.com/vanntile)'s [repository](https://github.com/vanntile/JavaScript30) and [GitHub Pages showcase](https://vanntile.github.io/JavaScript30/). Thank you for a great ⌨️ experience.
4556
* [Alex Kim](https://github.com/Alex-K1m/js30-challenge) completed all the challenges. You can check them out at [github pages](https://alex-k1m.github.io/js30-challenge/).

0 commit comments

Comments
Β (0)