-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello-world.html
107 lines (85 loc) · 2.11 KB
/
hello-world.html
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<!-- HTML5 Hello world by kirupa - http://www.kirupa.com/html5/getting_your_feet_wet_html5_pg1.htm -->
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>Hello...</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<style type="text/css">
#mainContent {
font-family: Arial, Helvetica, sans-serif;
font-size: xx-large;
font-weight: bold;
background-color: #E3F0FB;
border-radius: 4px;
padding: 10px;
text-align: center;
}
.buttonStyle {
border-radius: 4px;
border: thin solid #F0E020;
padding: 5px;
background-color: #F8F094;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
font-weight: bold;
color: #663300;
width: 75px;
}
.buttonStyle:hover {
border: thin solid #FFCC00;
background-color: #FCF9D6;
color: #996633;
cursor: pointer;
}
.buttonStyle:active {
border: thin solid #99CC00;
background-color: #F5FFD2;
color: #669900;
cursor: pointer;
}
</style>
</head>
<body>
<div id="mainContent">
<p id="helloText">?</p>
<button id="clickButton" class="buttonStyle">click me</button>
</div>
<textarea></textarea>
<script>
var myButton = document.getElementById("clickButton");
var myText = document.getElementById("helloText");
var index = 0;
myButton.addEventListener('click', doSomething, false)
function doSomething() {
myText.textContent = "hello, world!";
}
function speak(phrase) {
var voices = window.speechSynthesis.getVoices();
var msg = new SpeechSynthesisUtterance(phrase);
msg.voice = voices[1];
window.speechSynthesis.speak(msg);
console.log('voice is: ' + msg.voice)
}
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function (str){
return this.slice(0, str.length) == str;
};
}
function speakNextLine() {
var phrase = $('textarea').val().split('\n')[index];
index++;
if (phrase.startsWith('Marcy:')) {
speak(phrase.slice(6));
return true;
}
return false;
}
$(document).keypress(function(e){
console.log('in here!');
while (speakNextLine() === false) {};
});
window.speechSynthesis.getVoices();
speak('Hello friends!');
</script>
</body>
</html>