Skip to content

Commit 837ab16

Browse files
authored
Merge pull request #12 from cindyliu923/cindy/update-clock
Update cindy clock for add audio
2 parents 81dd892 + 516d0bf commit 837ab16

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

cindy/Day2-clock/index.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@
88
</head>
99
<body>
1010
<div class="chick">
11+
<audio class="time-audio" controls="controls">
12+
<source src="" type="audio/mpeg">
13+
</audio>
1114
<div class="chick-head">
12-
<div class="triangle"></div>
15+
<div class="triangle">
16+
<br/>
17+
<p>點我報時</p><br/>
18+
</div>
1319
</div>
1420
<div class="clock">
1521
<div class="clock-face">

cindy/Day2-clock/main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const minsHand = document.querySelector('.min-hand');
33
const hourHand = document.querySelector('.hour-hand');
44
const time = document.querySelector('.time')
55
const dot = document.querySelector('.dot')
6+
const audio = document.querySelector('.time-audio')
7+
const chickHead = document.querySelector('.chick-head')
68

79
const caculateSeconds = (seconds) => {
810
const secondsDegrees = ((seconds / 60) * 360) + 90;
@@ -30,4 +32,9 @@ const setDate = () => {
3032
caculateHours(hour);
3133
}
3234

35+
chickHead.addEventListener('click', () => {
36+
audio.src = `https://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=${time.innerText}&tl=en-gb`
37+
audio.autoplay = 'autoplay'
38+
});
39+
3340
setInterval(setDate, 10);

cindy/Day2-clock/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,7 @@ body {
8080
position: relative;
8181
width: 1rem;
8282
}
83+
84+
.time-audio {
85+
display: none;
86+
}

0 commit comments

Comments
 (0)