-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (33 loc) · 937 Bytes
/
index.js
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
let mic_btn = document.getElementById('speechtotext');
search_bar = document.getElementById('search_bar');
mic_btn.addEventListener('click', () => {
// Use API
var recognition = new webkitSpeechRecognition || window.SpeechRecognition;
recognition.lang = "en-GB"
recognition.onresult = function (event) {
search_bar.value = event.results[0][0].transcript;
}
// start record
recognition.start();
// Search your query in google
setTimeout(() => {
if (search_bar.value == "") {
} else {
window.location = "http://www.google.com/search?q=" + search_bar.value;
return false;
}
}, 5000);
});
// Type text automatically in input placeholder
var i = 0;
var txt = "Search Google ot type a URL";
if (location.reload) {
types();
}
function types() {
if (i < txt.length) {
document.getElementById('search_bar').placeholder += txt.charAt(i);
i++;
}
setTimeout(types, 100);
}