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