Skip to content

Commit d02a5d6

Browse files
committed
finished JS Day wesbos#9, wesbos#10, wesbos#11
1 parent 5da1d5f commit d02a5d6

File tree

6 files changed

+82
-3
lines changed

6 files changed

+82
-3
lines changed

08 - Fun with HTML5 Canvas/index-START.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@
2525
function draw(e){
2626
if(!isDrawing) return;
2727
ctx.strokeStyle = `hsl(${hue}, 100%, 50%)`
28-
ctx.lineWidth = hue;
28+
2929
ctx.beginPath();
3030
ctx.moveTo(lastX, lastY);
3131
ctx.lineTo(e.offsetX, e.offsetY)
3232
ctx.stroke();
3333
hue++
34+
ctx.lineWidth++
3435

3536
}
3637

09 - Dev Tools Domination/index-START.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// Regular
2121

2222
// Interpolated
23+
console.log("%c Hello this is a console", 'color: green; background-color: #cef7ce; border-left: 5px solid green;')
2324

2425
// Styled
2526

10 - Hold Shift and Check Checkboxes/index-START.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,31 @@
9999
</div>
100100

101101
<script>
102+
const checkboxes = document.querySelectorAll('.inbox input');
103+
checkboxes.forEach(item => {
104+
item.addEventListener('click', handleCheck)
105+
})
106+
107+
let lastChecked;
108+
109+
function handleCheck(e){
110+
let inBetween = false;
111+
if(e.shiftKey && this.checked){
112+
checkboxes.forEach(checkbox => {
113+
if(checkbox === this || checkbox === lastChecked){
114+
inBetween = !inBetween;
115+
console.log('starting to check them inbetween')
116+
}
117+
if(inBetween){
118+
checkbox.checked = true;
119+
}
120+
})
121+
}
122+
lastChecked = this;
123+
124+
}
125+
126+
102127
</script>
103128
</body>
104129
</html>

11 - Custom Video Player/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
</div>
2424

2525
<script src="scripts.js"></script>
26+
2627
</body>
2728
</html>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const video = document.querySelector('.player__video');
2+
const range = document.querySelectorAll('input[type="range"]');
3+
const player = document.querySelector('.viewer');
4+
const toggle = document.querySelector('.toggle');
5+
const progressBar = document.querySelector('.progress');
6+
const progress = document.querySelector('.progress__filled');
7+
const playerButton = document.querySelector('.toggle');
8+
const skipButtons = document.querySelectorAll('button[data-skip]');
9+
10+
function scrub(e){
11+
const percentage = e.offsetX / video.videoWidth
12+
video.currentTime = video.duration * percentage
13+
}
14+
15+
function playVideo(){
16+
video.paused ? video.play() : video.pause();
17+
}
18+
19+
function skip(){
20+
video.currentTime = video.currentTime + Number(this.dataset.skip);
21+
}
22+
23+
function configChange(){
24+
if(this.name == 'volume'){
25+
video.volume = this.value;
26+
}else{
27+
video.playbackRate = this.value
28+
}
29+
}
30+
31+
function videoPlaying(){
32+
progress.style.flexBasis = (video.currentTime / video.duration) * 100 + "%";
33+
}
34+
35+
function updateButton(){
36+
toggle.innerHTML = video.paused ? '►' : '||';
37+
}
38+
39+
player.addEventListener('click', playVideo)
40+
video.addEventListener('timeupdate', videoPlaying)
41+
video.addEventListener('pause', updateButton)
42+
video.addEventListener('play', updateButton)
43+
playerButton.addEventListener('click', playVideo)
44+
progressBar.addEventListener('mousedown', scrub)
45+
skipButtons.forEach(button => {
46+
button.addEventListener('click', skip)
47+
})
48+
range.forEach(item => {
49+
item.addEventListener('mousedown', configChange)
50+
item.addEventListener('mousemove', configChange)
51+
})

11 - Custom Video Player/style.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ body {
9898
}
9999

100100
.progress__filled {
101-
width:50%;
101+
width:0%;
102102
background:#ffc600;
103103
flex:0;
104-
flex-basis:50%;
104+
flex-basis:0%;
105105
}
106106

107107
/* unholy css to style input type="range" */

0 commit comments

Comments
 (0)