mirror of https://github.com/interlegis/sapl.git
6 changed files with 139 additions and 7 deletions
@ -0,0 +1,34 @@ |
|||
<!-- chat/templates/chat/room.html --> |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="utf-8"/> |
|||
<title>Chat Room</title> |
|||
</head> |
|||
<body> |
|||
<textarea id="chat-log" cols="100" rows="20"></textarea><br/> |
|||
<input id="chat-message-submit" type="button" value="Pull"/> |
|||
</body> |
|||
<script> |
|||
|
|||
var chatSocket = new WebSocket( |
|||
'ws://' + window.location.host + |
|||
'/ws/time-refresh/'); |
|||
|
|||
chatSocket.onmessage = function(e) { |
|||
var data = JSON.parse(e.data); |
|||
var message = data['message']; |
|||
document.querySelector('#chat-log').value += (e.data + '\n'); |
|||
}; |
|||
|
|||
chatSocket.onclose = function(e) { |
|||
console.error('Chat socket closed unexpectedly'); |
|||
}; |
|||
|
|||
document.querySelector('#chat-message-submit').onclick = function(e) { |
|||
chatSocket.send(JSON.stringify({ |
|||
'message': 'Olá' |
|||
})); |
|||
}; |
|||
</script> |
|||
</html> |
|||
Loading…
Reference in new issue