mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
Add connection status indicator for #44
This commit is contained in:
@@ -86,3 +86,7 @@ table.metrics {
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
#conn-status {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ function startMonitor() {
|
||||
var url = ((l.protocol === "https:") ? "wss://" : "ws://") + l.host + uri
|
||||
var ws = new WebSocket(url);
|
||||
|
||||
ws.addEventListener('open', function (e) {
|
||||
$('#conn-status').text('Connected.');
|
||||
});
|
||||
ws.addEventListener('message', function (e) {
|
||||
var msg = JSON.parse(e.data);
|
||||
msg['href'] = '/mailbox?name=' + msg.mailbox + '&id=' + msg.id;
|
||||
@@ -26,6 +29,9 @@ function startMonitor() {
|
||||
msg,
|
||||
{ append: true });
|
||||
});
|
||||
ws.addEventListener('close', function (e) {
|
||||
$('#conn-status').text('Disconnected!');
|
||||
});
|
||||
}
|
||||
|
||||
function messageClick(node) {
|
||||
|
||||
@@ -47,5 +47,7 @@ $(document).ready(function () {
|
||||
<tbody id="monitor-message-list"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="conn-status">Connecting...</div>
|
||||
{{end}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user