-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
47 lines (35 loc) · 1.26 KB
/
index.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
<html>
<body style="margin: 35px">
<form>
<textarea id="messageField" rows="4" cols="50"></textarea>
<input onclick="sendMsg();" value="send" type="button">
</form>
<div id="msg-box" style="width:500px; height: 400px; background: #eee; overflow:auto;"></div>
<script>
var webSocket = new WebSocket("ws://localhost:8080/");
var msgField = document.getElementById("messageField");
var divMsg = document.getElementById("msg-box");
messageField.value='>1\nAACCGGTTTAAA\n>2\nAACCGGTTCAAA';
function sendMsg() {
var msgToSend = msgField.value;
webSocket.send(msgToSend);
// divMsg.innerHTML += "<div style='color:red'>Client> " + msgToSend +
// "</div>"
msgField.value = "";
}
webSocket.onmessage = function(message) {
// divMsg.innerHTML += "Server> : " + message.data;
divMsg.innerHTML += message.data + "\n";
}
webSocket.onopen = function() {
console.log("connection opened");
};
webSocket.onclose = function() {
console.log("connection closed");
};
webSocket.onerror = function wserror(message) {
console.log("error: " + message);
}
</script>
</body>
</html>