Skip to content
Merged
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
8 changes: 7 additions & 1 deletion cindy/Day2-clock/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
</head>
<body>
<div class="chick">
<audio class="time-audio" controls="controls">
<source src="" type="audio/mpeg">
</audio>
<div class="chick-head">
<div class="triangle"></div>
<div class="triangle">
<br/>
<p>點我報時</p><br/>
</div>
</div>
<div class="clock">
<div class="clock-face">
Expand Down
7 changes: 7 additions & 0 deletions cindy/Day2-clock/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const minsHand = document.querySelector('.min-hand');
const hourHand = document.querySelector('.hour-hand');
const time = document.querySelector('.time')
const dot = document.querySelector('.dot')
const audio = document.querySelector('.time-audio')
const chickHead = document.querySelector('.chick-head')

const caculateSeconds = (seconds) => {
const secondsDegrees = ((seconds / 60) * 360) + 90;
Expand Down Expand Up @@ -30,4 +32,9 @@ const setDate = () => {
caculateHours(hour);
}

chickHead.addEventListener('click', () => {
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`
audio.autoplay = 'autoplay'
});

setInterval(setDate, 10);
4 changes: 4 additions & 0 deletions cindy/Day2-clock/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ body {
position: relative;
width: 1rem;
}

.time-audio {
display: none;
}