1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 10:07:02 +00:00

Add connection status indicator for #44

This commit is contained in:
James Hillyerd
2017-01-21 20:47:10 -08:00
parent 9ae428ca44
commit e14e97919f
3 changed files with 12 additions and 0 deletions

View File

@@ -86,3 +86,7 @@ table.metrics {
cursor: pointer;
font-size: 12px;
}
#conn-status {
font-style: italic;
}

View File

@@ -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) {

View File

@@ -47,5 +47,7 @@ $(document).ready(function () {
<tbody id="monitor-message-list"></tbody>
</table>
</div>
<div id="conn-status">Connecting...</div>
{{end}}