Skip to content

Commit 36cbf0c

Browse files
committed
Show when the server is down.
1 parent b3d3905 commit 36cbf0c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,20 @@
1313
margin: 0 auto;
1414
padding: 30px;
1515
}
16+
#con-error {
17+
position: fixed;
18+
top: 0px;
19+
right: 0px;
20+
padding: 5px;
21+
background: white;
22+
color: red;
23+
}
1624
</style>
1725
<script src="/socket.io/socket.io.js"></script>
1826
<script>
1927
var socket = io.connect('http://'+ window.location.host +'/');
2028
socket.on('connect', function () {
29+
setDisconnected(false);
2130
socket.on('newContent', function(newHTML) {
2231
document.querySelector(".markdown-body").innerHTML = newHTML;
2332
});
@@ -32,6 +41,9 @@
3241
document.body.innerHTML = firefoxWarning;
3342
});
3443
});
44+
socket.on('disconnect', function() {
45+
setDisconnected(true);
46+
});
3547

3648
try {
3749
eval('// If CSP is active, then this is blocked');
@@ -43,6 +55,11 @@
4355
meta.setAttribute('content', "script-src 'none';");
4456
document.head.appendChild(meta);
4557
}
58+
59+
function setDisconnected(isDisconnected) {
60+
document.getElementById('con-error').style.display =
61+
isDisconnected ? 'block' : 'none';
62+
}
4663
</script>
4764
</head>
4865
<body>
@@ -57,5 +74,6 @@
5774
</div>
5875
</div>
5976
</div>
77+
<div id="con-error" style="display:none">Live preview is unavailable</div>
6078
</body>
6179
</html>

0 commit comments

Comments
 (0)