forked from devcon2017/devcon2017.github.io
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex-old.html
More file actions
220 lines (199 loc) · 6.69 KB
/
index-old.html
File metadata and controls
220 lines (199 loc) · 6.69 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<style>
* {
font-family: Verdana, Arial, sans-serif;
}
#start_button {
border: 0;
background-color:transparent;
padding: 0;
}
.center {
padding: 10px;
text-align: center;
}
.right {
float: right;
}
.left {
float: left;
}
textarea#textarea {
width: 659px; height: 90px;
font-family: Tahoma, sans-serif;
font-size: 50px;
min-height: 90px;
text-align: center;
}
#start_button {
border: 0;
background-color:transparent;
padding: 0;
}
#parent {
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 100%;
overflow: hidden !important;
z-index: -1;
}
.message,.message-1 {
height: 120px;
width: 120px;
background-color: orange;
color: white;
z-index: -9999;
line-height: 115px;
text-align: center;
font-family: Arial, sans-serif;
font-weight: bold;
-webkit-border-radius: 60px;
-moz-border-radius: 60px;
border-radius: 60px;
}
</style>
<meta charset=utf-8 />
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-store" />
<meta http-equiv="pragma" content="no-cache" />
<head>
<title>Ekstep Word Complexity Compute Demonstration</title>
</head>
<div class="center" id="div_language">
<p>Select Language:
<select id="select_language">
<!--<option value="en-IN">English</option> -->
<option value="hi-IN">Hindi</option>
<option value="kn-IN">Kannada</option>
<option value="te-IN">Telugu</option>
<!--<option value="ta-IN">Tamil</option> -->
</select>
</p>
</div>
<div class="center">
<button id="start_button" onclick="toggleStartStop()"">
<img id="start_img" src="record.jpg" alt="Start" height="90" width="130"></button>
<textarea id="textarea" cols=80 onkeydown="if(event.keyCode == 13){ compute(); return false;}"></textarea>
</div>
<div class="center" id="result"></div>
<div id="parent">
<div class="message">अ</div>
<div class="message">आ</div>
<div class="message">ई</div>
<div class="message">ऋ</div>
<div class="message">ಅ</div>
<div class="message">ಐ</div>
<div class="message">ಈ</div>
<div class="message">ಋ</div>
<div class="message">అ</div>
<div class="message">ఐ</div>
<div class="message">ఈ</div>
<div class="message">ఓ</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
var recognizing;
var recognition = new webkitSpeechRecognition();
recognition.continuous = true;
reset();
recognition.onend = reset();
recognition.onresult = function (event) {
for (var i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
// poulate voice to text output
textarea.value = event.results[i][0].transcript;
//call complexity api with text output
compute();
}
}
}
function reset() {
recognizing = false;
start_img.src = 'record.jpg';
}
function toggleStartStop() {
if (recognizing) {
recognition.stop();
reset();
} else {
recognition.lang = select_language.value;
recognition.start();
recognizing = true;
start_img.src = 'recordAnime.gif';
}
}
//function to call complexity measure api to compute ortho/phono complexity along with grade suggestion
function compute() {
var language = select_language.value;
var language_id = language.substring(0, 2);
if(language_id=='kn') language_id='ka';
console.log(language_id);
var ItemJSON = '{"request": {"language_id": "'+language_id+'","text": "'+textarea.value+'"}}';
URL = "https://dev.ekstep.in/api/language/v1/language/tools/complexityMeasures/text"; //Your URL
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", URL, true);
xmlhttp.setRequestHeader("Content-Type", "application/json");
xmlhttp.setRequestHeader("user-id","system");
xmlhttp.send(ItemJSON);
//display result when async call is success
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//parse json object and put ortho/phono complexity inside result DIV section along with grade suggestion
var data = JSON.parse(xmlhttp.responseText);
//log result text complexity response
console.log(data.result.text_complexity);
document.getElementById("result").innerHTML = "";
document.getElementById("result").innerHTML += "Orthographic Complexity : <b>" +data.result.text_complexity.totalOrthoComplexity+"<b>";
document.getElementById("result").innerHTML += "<BR>Phonologic Complexity : <b>" +data.result.text_complexity.totalPhonicComplexity+"<b>";
var meanComplexity = data.result.text_complexity.meanComplexity;
//mean complpexity is nothing but sum of orth0 and phono complexity
if(20>meanComplexity&& meanComplexity>0)
document.getElementById("result").innerHTML += "<BR>Grade Level : First" ;
else if(30>meanComplexity&& meanComplexity>=20)
document.getElementById("result").innerHTML += "<BR>Grade Level : Second" ;
else if(40>meanComplexity&& meanComplexity>=30)
document.getElementById("result").innerHTML += "<BR>Grade Level : Third" ;
else if(50>meanComplexity&& meanComplexity>=40)
document.getElementById("result").innerHTML += "<BR>Grade Level : Four" ;
else if(70>meanComplexity&& meanComplexity>=50)
document.getElementById("result").innerHTML += "<BR>Grade Level : Five" ;
else
document.getElementById("result").innerHTML += "<BR>Grade Level : Higher than Five" ;
}
};
}
jQuery.fn.verticalMarquee = function(vertSpeed, horiSpeed, index) {
this.css('float', 'left');
vertSpeed = vertSpeed || 1;
horiSpeed = 1/horiSpeed || 1;
var windowH = this.parent().height(),
thisH = this.height(),
parentW = (this.parent().width() - this.width()) / 2,
rand = Math.random() * (index * 1000),
current = this;
this.css('margin-top', windowH + thisH);
this.parent().css('overflow', 'hidden');
setInterval(function() {
current.css({
marginTop: function(n, v) {
return parseFloat(v) - vertSpeed;
},
marginLeft: function(n, v) {
return (Math.sin(new Date().getTime() / (horiSpeed * 5000) + rand) + 1) * parentW;
}
});
}, 15);
setInterval(function() {
if (parseFloat(current.css('margin-top')) < -thisH) {
current.css('margin-top', windowH + thisH);
}
}, 100);
};
var message = 1;
$('.message').each(function(message) {
$(this).verticalMarquee(1, 1, message);
message++
});
</script>