-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
49 lines (49 loc) · 1.73 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
<!DOCTYPE html>
<html>
<head>
<title>{%TITLE%}</title>
<link rel="stylesheet" type="text/css" href="http://{%HOST%}:{%PORT%}/gfm/app.css">
<link rel="stylesheet" type="text/css" href="http://{%HOST%}:{%PORT%}/gfm/hl.css">
<link rel="icon" type="image/png" sizes="32x32" href="http://{%HOST%}:{%PORT%}/gfm/favicon.png">
<link rel="icon" type="image/x-icon" href="http://{%HOST%}:{%PORT%}/gfm/favicon.ico" />
</head>
<body>
<div id="app" class="markdown-body"></div>
<script src="http://{%HOST%}:{%PORT%}/gfm/hl.js"></script>
<script src="http://{%HOST%}:{%PORT%}/gfm/socket.io.js"></script>
<script type="text/javascript">
window.addEventListener('DOMContentLoaded', function() {
var socket = io('http://{%HOST%}:{%PORT%}');
socket.on('connect', function() {
var clicking;
socket.emit('request content');
socket.emit('clicked');
socket.on('response content', function (data) {
document.getElementById('app').innerHTML = data;
hljs.initHighlightingOnLoad();
var links = document.getElementsByTagName('a');
for (var i = links.length - 1; i >= 0; i--) {
links[i].addEventListener('click', function(e) {
e.preventDefault();
socket.emit('clicking');
clicking = e.target.href;
});
}
});
socket.on('clickable', () => {
if (clicking) {
window.location.href = clicking;
clicking = null;
}
});
history.pushState(null, null, location.href);
window.onpopstate = function () {
clicking = document.referrer;
history.go(1);
socket.emit('clicking');
};
});
});
</script>
</body>
</html>