-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyjs.js
More file actions
58 lines (53 loc) · 1.02 KB
/
myjs.js
File metadata and controls
58 lines (53 loc) · 1.02 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
var ip="192.168.1.3";
var size=0;
var codes="";
function setIP(opt){
if (opt==0){
if (event.keyCode==13){
ip=document.getElementById("ip").value;
document.getElementById("ipH").innerHTML="The Arduino Server IP:"+ip;
}
}
else{
ip=document.getElementById("ip").value;
document.getElementById("ipH").innerHTML="The Arduino Server IP:"+ip;
}
}
function sub(opt){
val="";
if(opt==0){
val=document.getElementById("txt").value;
}
else{
val=size.toString()+codes;
}
errTextbox=document.getElementById("di");
try{
request=new XMLHttpRequest();
request.open('get','http://'+ip+'?'+val,true);
request.send();
}
catch(error){
errTextbox.value=error;
}
}
function subK(opt){
if (event.keyCode==13){
sub(opt);
}
}
function addIns(code){
if (size+1>9){
alert("You can only send 9 instructions to Arduino.");
}
else{
codes=codes+code;
size=size+1;
document.getElementById("txt").value=size.toString()+codes;
}
}
function cl(){
size=0;
codes="";
document.getElementById("txt").value=""
}