-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpromises-song.html
More file actions
92 lines (70 loc) · 2.5 KB
/
Copy pathpromises-song.html
File metadata and controls
92 lines (70 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Promises Song</title>
</head>
<body>
<h1>A Song of Promises</h1>
<h3 id="song"></h3>
<button id="sing-btn">Sing</button>
<script>
"use strict";
const song = document.getElementById('song');
// A Song from Callback Hell...
// function singLyrics(lyrics, pitch, callback) {
// var lyric = new SpeechSynthesisUtterance(lyrics);
// lyric.pitch = pitch;
// lyric.rate = .7;
// speechSynthesis.speak(lyric);
// song.append(lyrics);
// setTimeout(callback, 1500);
// }
// const sing = () => {
// song.innerHTML = '';
// singLyrics('All a-', .5, function() {
// singLyrics('round the', 1, function() {
// singLyrics(' mulberry', 1.5, function() {
// singLyrics(' bush', 1, function() {
// singLyrics(' the monkey', .5, function() {
// singLyrics(' chased', 1, function() {
// singLyrics(' the wea-', 1.5, function() {
// singLyrics(' sel', 1, function() {
// return false;
// });
// });
// });
// });
// });
// });
// });
// });
// };
// A Simpler Song to Read (I promise)... but still sung terribly...
// function singLyrics(lyrics, pitch) {
// return new Promise((res) => {
// var lyric = new SpeechSynthesisUtterance(lyrics);
// lyric.pitch = pitch;
// lyric.rate = .7;
// speechSynthesis.speak(lyric);
// song.append(lyrics);
// setTimeout(res, 1500);
// });
// }
//
// const singPromises = () => {
// song.innerHTML = '';
// return singLyrics('All a-', .5)
// .then(() => singLyrics('round the', 1))
// .then(() => singLyrics(' mulberry', 1.5))
// .then(() => singLyrics(' bush', 1))
// .then(() => singLyrics(' the monkey', .5))
// .then(() => singLyrics(' chased', 1))
// .then(() => singLyrics(' the wea-', 1.5))
// .then(() => singLyrics(' sel', 1));
// };
//
// document.getElementById('sing-btn').addEventListener('click', singPromises);
</script>
</body>
</html>