forked from TalAter/chrome-is-listening
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.html
71 lines (66 loc) · 1.73 KB
/
popup.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
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
* {
padding: 0 0;
margin: 0 0;
}
em {
color: red;
font-weight: bold;
font-size: 2em;
}
div#transcript {
padding: 5px 20px;
}
img#sneakyPopup {
position: absolute;
right: 20px;
top: 20px;
width: 72px;
height: 30px;
transition: all 200ms linear;
}
img#sneakyPopup:hover {
top: 0;
right: 0;
width: 720px;
height: 300px;
}
</style>
<script type="text/javascript">
var startListening = function() {
var recognition = new webkitSpeechRecognition();
recognition.maxAlternatives = 1;
recognition.continuous = true;
recognition.lang = 'en-US';
recognition.onresult = function(event) {
var transcript = findKeywords(event.results[event.resultIndex][0].transcript);
var textNode = document.createElement('div');
textNode.innerHTML = transcript;
document.getElementById('transcript').appendChild(textNode);
};
recognition.start();
}
var findKeywords = function(text) {
return text.replace(/(NSA|Syria|Miley|Cyrus)/ig, '<em>$1</em>')
}
</script>
</head>
<body>
<img src="images/banner.jpg" id="sneakyPopup">
<div id="transcript"></div>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-24775009-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>