-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.html
70 lines (64 loc) · 2.21 KB
/
page.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
68
69
70
<!DOCTYPE html>
<html>
<head>
<title>Message Transfer</title>
<style>
body {
text-align: center;
background-color: aqua;
}
h1 {
color: #017;
font-family: sans-serif;
}
p {
color: #017;
font-family: sans-serif;
}
.warning {
color: red;
font-family: sans-serif;
}
textarea {
color: blue;
font-family: Georgia, 'Times New Roman', Times, serif;
background-color: #eef5;
border-style: dashed;
border-width: 2px;
border-color: #017;
border-radius: 5px;
width: 97%;
height: 400px;
}
</style>
<script>
let socket = new WebSocket("ws://" + location.host + "/connect");
function sendData() {
socket.send(document.getElementById("DOC").value);
}
socket.onmessage = function(event) {
document.getElementById("DOC").value = event.data;
};
socket.onclose = function(event) {
if (event.wasClean) {
document.getElementById("error console").style.display = '';
document.getElementById("error console").value = "Server connection is now closed. Come back later and it may be open."
} else {
document.getElementById("error console").style.display = '';
document.getElementById("error console").value = "Uh oh! There was an error in the server connection."
}
};
socket.onerror = function(error) {
document.getElementById("error console").style.display = '';
document.getElementById("error console").value = "There was a strange error in the server connection: " + error.message;
};
</script>
</head>
<body>
<noscript class="warning"><b><u>ERROR:</u></b> Javascript is not supported by your web browser. This may be the result of an outdated web browser or Javascript being disabled in your settings.</noscript>
<h1>Local Network Message Transfer</h1>
<p>Editing the content below will automatically update it for everyone on this site.</p>
<p id="error console" class="warning" style="display: none"></p>
<textarea id="DOC" oninput="sendData()"></textarea>
</body>
</html>