-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathriconoscimento-con-apple.html
67 lines (59 loc) · 1.42 KB
/
riconoscimento-con-apple.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
<!DOCTYPE html>
<html><head><meta charset="utf-8" /></head>
<body>
<input oninput="changeIp()" type="text" value="127.0.0.1:9092" id='ip'/>
<br/>
<textarea oninput="change()"></textarea>
<script>
var lastWord;
var timer;
function change(e){
var valore = document.querySelector("textarea").value
var newWords = valore.split(" ");
// console.log("SLICE= " + valore.split(" ")[0]);
for(var a = newWords.length - 1; a >= 0 ; a--)
{
if(a < newWords.length - 1)
{
console.log(a + " - " + newWords[a]);
connection.send(newWords[a])
}
else
{
lastWord = newWords[newWords.length - 1];
codeForLastWord();
}
}
document.querySelector("textarea").value = "";
}
function codeForLastWord()
{
clearTimeout(timer);
timer = setTimeout(function()
{
console.log("Send last = " + lastWord);
connection.send(lastWord);
}, 1000);
}
function changeIp(e){
connection = new WebSocket("ws://"+getIpFromInput())
}
// mauro 192.168.1.112
connection = new WebSocket("ws://"+getIpFromInput());
function getIpFromInput(){
return document.getElementById('ip').value
}
// Log messages from the server
connection.onmessage = function (e) {
console.log('Server: ' + e.data);
};
connection.onerror = function (e) {
console.log('Server: ' + e.data);
};
connection.onopen = function(e) {
console.log("Connection established!");
connection.send('Hello Me!');
};
</script>
</body>
</html>