mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
Base: Format the WebSocket demo page with prettier
This commit is contained in:
parent
63b4c35ec7
commit
8339415939
1 changed files with 9 additions and 9 deletions
|
@ -8,35 +8,35 @@
|
|||
<h2>WebSocket Test</h2>
|
||||
<div id="output"></div>
|
||||
<script type="text/javascript">
|
||||
var output = document.getElementById('output');
|
||||
var output = document.getElementById("output");
|
||||
|
||||
function println(message) {
|
||||
const p = document.createElement('p');
|
||||
const p = document.createElement("p");
|
||||
p.innerHTML = message;
|
||||
output.appendChild(p);
|
||||
}
|
||||
|
||||
// Websocket echo server, provided from https://www.websocket.org/echo.html
|
||||
var targetUrl = 'wss://echo.websocket.org';
|
||||
var messageContent = 'Hello friends :^)';
|
||||
var targetUrl = "wss://echo.websocket.org";
|
||||
var messageContent = "Hello friends :^)";
|
||||
println('<span style="color: blue;">Connecting to:</span> ' + targetUrl);
|
||||
websocket = new WebSocket(targetUrl);
|
||||
websocket.onopen = function() {
|
||||
websocket.onopen = function () {
|
||||
println('<span style="color: green;">Connected to:</span> ' + targetUrl);
|
||||
println('<span style="color: blue;">Sending Message:</span> ' + messageContent);
|
||||
websocket.send(messageContent);
|
||||
};
|
||||
websocket.onmessage = function(event) {
|
||||
websocket.onmessage = function (event) {
|
||||
println('<span style="color: green;">Received Response:</span> ' + event.data);
|
||||
println('<span style="color: blue;">Closing connection...</span> ');
|
||||
websocket.close();
|
||||
};
|
||||
websocket.onerror = function(evt) {
|
||||
websocket.onerror = function (evt) {
|
||||
println('<span style="color: red;">ERROR:</span> ' + evt.data);
|
||||
};
|
||||
websocket.onclose = function() {
|
||||
websocket.onclose = function () {
|
||||
println('<span style="color: green;">Connection closed!</span>');
|
||||
};
|
||||
</script>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue