Skip to content

Commit 44c69a8

Browse files
committed
Rearranged icons
1 parent 1bea473 commit 44c69a8

File tree

3 files changed

+50
-20
lines changed

3 files changed

+50
-20
lines changed

bulb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"status": 1,
3+
"text": "Testing",
4+
"red_state" : 1,
5+
"blue_state" : 1
6+
}

index.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,7 @@
1212
<script src="index.js"></script>
1313
</head>
1414
<body>
15-
<div class="container">
16-
<div class="row justify-content-center">
17-
<span class="fa-stack fa-lg fa-5x grow" id="voice-btn" onclick="startDictation()">
18-
<i class="fa fa-circle fa-stack-2x"></i>
19-
<i class="fa fa-microphone fa-stack-1x fa-inverse" id="mic-ico"></i>
20-
</span>
21-
</div>
22-
<div class="row justify-content-center">
23-
<label id="detect-text">.</label>
24-
</div>
25-
<div class="row justify-content-center">
26-
<i id="loading" class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
27-
</div>
15+
<div class="container align-items-center">
2816
<div class="row justify-content-center">
2917
<div class="justify-content-center">
3018
<span class="fa-stack fa-lg fa-5x text-danger" onclick="toggle('red-bulb');">
@@ -37,7 +25,19 @@
3725
<i class="fa fa-circle fa-stack-2x"></i>
3826
<i class="fa fa-lightbulb-o fa-stack-1x fa-inverse" id="blue-bulb"></i>
3927
</span>
40-
</div>
28+
</div>
29+
</div>
30+
<div class="row justify-content-center">
31+
<label id="detect-text">.</label>
32+
</div>
33+
<div class="row justify-content-center">
34+
<i id="loading" class=""></i>
35+
</div>
36+
<div class="row justify-content-center">
37+
<span class="fa-stack fa-lg fa-5x grow" id="voice-btn" onclick="startDictation()">
38+
<i class="fa fa-circle fa-stack-2x"></i>
39+
<i class="fa fa-microphone fa-stack-1x fa-inverse" id="mic-ico"></i>
40+
</span>
4141
</div>
4242
</div>
4343
</body>

index.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,44 @@ function startDictation() {
1919
recognition.stop();
2020
document.getElementById("voice-btn").classList.remove("animated");
2121
document.getElementById("mic-ico").classList.remove("text-danger");
22-
/* Set URL
23-
axios.get('/console', {
22+
23+
axios.get('/bulb', {
2424
params: {
2525
text: e.results[0][0].transcript
2626
}
2727
})
2828
.then(function (response) {
29-
console.log(response.data);
30-
Actions here
29+
console.log(response.data);
30+
var data = response.data;
31+
console.log(data.status);
32+
33+
if(data.status > 0) {
34+
switch(data.blue_state) {
35+
case 1:switchOn('red-bulb');break;
36+
case 2:switchOff('red-bulb');break;
37+
}
38+
switch(data.red_state) {
39+
case 1:switchOn('blue-bulb');break;
40+
case 2:switchOff('blue-bulb');break;
41+
}
42+
document.getElementById('detect-text').innerHTML = data.text;
43+
}
44+
else {
45+
document.getElementById('detect-text').innerHTML =
46+
"Sorry, some error has occured while analyzing the text";
47+
}
48+
document.getElementById("loading").className = "";
49+
50+
51+
3152
})
3253
.catch(function (error) {
33-
console.log(error);
54+
document.getElementById('detect-text').innerHTML =
55+
"Sorry, some error has occured while contacting the server";
56+
console.log(error);
57+
document.getElementById("loading").className = "";
3458
});
35-
*/
59+
3660
};
3761

3862
recognition.onerror = function(e) {

0 commit comments

Comments
 (0)