-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
28 lines (28 loc) · 764 Bytes
/
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Database</title>
</head>
<body>
<label for="query">Query</label>
<input id="query" onkeydown="send(this);">
<script>
let websocketProtocol = "ws:";
if (document.location.protocol === "https:") {
websocketProtocol = "wss:";
}
let websocket = new WebSocket(websocketProtocol + "//" + document.location.host + document.location.pathname + "database");
websocket.onmessage = function (message) {
console.log(message.data);
};
let send = function (element) {
if (event.key === 'Enter') {
let message = element.value;
websocket.send(message);
element.value = '';
}
}
</script>
</body>
</html>