Repository navigation
Expand file tree
/
Copy pathindex0.html
More file actions
177 lines (144 loc) · 4.88 KB
/
Copy pathindex0.html
File metadata and controls
177 lines (144 loc) · 4.88 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>a title</title>
<!-- Bootstrap core CSS -->
<link href="bootstrap.css" rel="stylesheet">
<script src="jquery.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<script>
var ct_data_ws;
var ir_sender_ws;
var roundScan;
var originalTimingList, lastTimingList;
var cpp_ir_decode_ws;
$(document).ready(function() {
//alert("Ready!");
//output = document.getElementById("output");
//ct_data_ws = new WebSocket("ws://thaiftcbk.ddns.net:9000/socket.io");
ct_data_ws = new WebSocket("ws://127.0.0.1:9111");
//ct_data_ws = new WebSocket("ws://thaiftcbk.ddns.net:9000");
ct_data_ws.onopen = function(evt) {
onCt_data_ws_Open(evt)
};
ct_data_ws.onclose = function(evt) {
onCt_data_ws_Close(evt)
};
ct_data_ws.onmessage = function(evt) {
onCt_data_ws_Message(evt)
};
ct_data_ws.onerror = function(evt) {
onCt_data_ws_Error(evt)
};
//cpp_ir_decode_ws = new WebSocket("ws://127.0.0.1:8080/IR_decode");
cpp_ir_decode_ws = new WebSocket("ws://thaiftcbk.ddns.net:8080/IR_decode");
//cpp_ir_decode_ws = new WebSocket("ws://thaiftcbk.ddns.net:9000");
cpp_ir_decode_ws.onopen = function(evt) {
onCpp_ir_decode_ws_Open(evt)
};
cpp_ir_decode_ws.onclose = function(evt) {
onCpp_ir_decode_ws_Close(evt)
};
cpp_ir_decode_ws.onmessage = function(evt) {
onCpp_ir_decode_ws_Message(evt)
};
cpp_ir_decode_ws.onerror = function(evt) {
onCpp_ir_decode_ws_Error(evt)
};
$( "#b1" ).click(function() {
//alert( "you click be" );
var aJson;
aJson = "{ \"command\" : \"get_ir\", \"name\" : \"" + $("#firstname").val() + "\" }";
//ct_data_ws.send($("#firstname").val());
ct_data_ws.send(aJson);
});
$( "#b2" ).click(function() {
//alert( "you click be" );
ct_data_ws.send("abcdef");
});
$( "#b3" ).click(function() {
//alert( "you click b3" );
//cpp_ir_decode_ws.send($("#firstname").val());
var bytearray = new Uint8Array(3);
bytearray[0] = 0x01; // 0x01 = loop scan IR
bytearray[1] = 0x02; // 0x01 = loop scan IR
bytearray[2] = 0x03; // 0x01 = loop scan IR
cpp_ir_decode_ws.send(bytearray);
});
});
function onCt_data_ws_Open(evt) {
alert("socket open");
}
function onCt_data_ws_Close(evt) {
alert("socket is closed");
}
function onCt_data_ws_Message(evt) {
//var aJSON = JSON.parse(evt.data);
//var headerLength,delayFactor,loopFactor;
//alert( aJSON.state );
//switch (aJSON.state) {
//}
//alert(evt.data);
var resultObj = JSON.parse(evt.data);
if ( resultObj.status == "found" ){
alert("Yes, found the remote");
}
else{
alert("No, not found the remote");
}
}
function onCt_data_ws_Error(evt)
{
alert("error");
}
function onCpp_ir_decode_ws_Open(evt) {
alert("socket open");
}
function onCpp_ir_decode_ws_Close(evt) {
alert("socket is closed");
}
function onCpp_ir_decode_ws_Message(evt) {
//var aJSON = JSON.parse(evt.data);
//var headerLength,delayFactor,loopFactor;
//alert( aJSON.state );
//switch (aJSON.state) {
//}
alert(evt.data);
/*
var resultObj = JSON.parse(evt.data);
if ( resultObj.status == "found" ){
alert("Yes, found the remote");
}
else{
alert("No, not found the remote");
}*/
}
function onCpp_ir_decode_ws_Error(evt)
{
alert("error");
}
</script>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
<form>
First name:<br>
<input type="text" name="firstname" id="firstname"><br>
Last name:<br>
<input type="text" name="lastname" id="lastname"><br>
<button type="button" id="b1">Sombat</button>
<button type="button" id="b2">not Sombat</button>
<button type="button" id="b3">C++Websocket Test</button>
</form>
</body>
</html>