-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
82 lines (78 loc) · 2.78 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html lang="en" class="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Language" content="en">
<link rel="stylesheet" type="text/css" href="/node_modules/github-markdown-css/github-markdown.css">
<link rel="stylesheet" type="text/css" href="/github-pandoc.css">
<style>
.markdown-body {
min-width: 200px;
max-width: 980px;
margin: 0 auto;
padding: 45px;
}
#con-error {
position: fixed;
top: 50vh;
right: 50vh;
padding: 5px;
background: white;
color: red;
font-size: 2em;
}
</style>
<script src="/node_modules/socket.io-client/socket.io.js"></script>
<script>
var socket = io.connect('http://'+ window.location.host +'/');
socket.on('connect', function () {
setDisconnected(false);
socket.on('newContent', function(newHTML) {
document.querySelector(".markdown-body").innerHTML = newHTML;
});
socket.on('die', function(newHTML) {
window.open('', '_self', '');
window.close();
var firefoxWarning =
"<h1>Oops!</h1>" +
"<h3>Firefox doesn't allow windows to self-close.</h3>" +
"<h3>If you want the preview window to close automatically like in other browsers, go to about:config and set dom.allow_scripts_to_close_windows to true.</h3>"
document.body.innerHTML = firefoxWarning;
});
});
socket.on('disconnect', function() {
setDisconnected(true);
});
try {
eval('// If CSP is active, then this is blocked');
} catch (e) {
// Detected that the CSP was active (by the user's preference).
// Drop capabilities to prevent rendered markdown from executing scripts.
var meta = document.createElement('meta');
meta.setAttribute('http-equiv', 'Content-Security-Policy');
meta.setAttribute('content', "script-src 'none';");
document.head.appendChild(meta);
}
function setDisconnected(isDisconnected) {
document.getElementById('wrapper').style.display = isDisconnected ? 'none' : 'block';
document.getElementById('con-error').style.display =
isDisconnected ? 'block' : 'none';
}
</script>
</head>
<body>
<div id="wrapper" class="wrapper">
<div class="container">
<div class="repository-with-sidebar repo-container new-discussion-timeline with-full-navigation">
<div id="js-repo-pjax-container" class="repository-content context-loader-container">
<div id="readme" class="boxed-group flush clearfix announce instapaper_body md">
<article class="markdown-body"></article>
</div>
</div>
</div>
</div>
</div>
<div id="con-error" style="display:none">Live preview is unavailable</div>
</body>
</html>