|
24 | 24 | }
|
25 | 25 | </style>
|
26 | 26 | <script src="/node_modules/mermaid/dist/mermaid.min.js"></script>
|
27 |
| - <script src="/socket.io/socket.io.js"></script> |
28 |
| - <script> |
29 |
| - var socket = io('http://'+ window.location.host +'/'); |
30 |
| - socket.on('connect', function () { |
31 |
| - setDisconnected(false); |
32 |
| - socket.on('newContent', function(newHTML) { |
33 |
| - document.querySelector(".markdown-body").innerHTML = newHTML; |
34 |
| - |
35 |
| - // scroll to the hyperlink with id="marker" |
36 |
| - let marker = document.getElementById("marker"); |
37 |
| - if(marker) { |
38 |
| - marker.scrollIntoView(); |
39 |
| - } |
40 |
| - mermaid.init() |
41 |
| - }); |
42 |
| - socket.on('die', function(newHTML) { |
43 |
| - window.open('', '_self', ''); |
44 |
| - window.close(); |
45 |
| - |
46 |
| - var firefoxWarning = |
47 |
| - "<h1>Oops!</h1>" + |
48 |
| - "<h3>Firefox doesn't allow windows to self-close.</h3>" + |
49 |
| - "<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>" |
50 |
| - document.body.innerHTML = firefoxWarning; |
51 |
| - }); |
52 |
| - }); |
53 |
| - socket.on('disconnect', function() { |
54 |
| - setDisconnected(true); |
55 |
| - }); |
56 |
| - |
57 |
| - try { |
58 |
| - eval('// If CSP is active, then this is blocked'); |
59 |
| - } catch (e) { |
60 |
| - // Detected that the CSP was active (by the user's preference). |
61 |
| - // Drop capabilities to prevent rendered markdown from executing scripts. |
62 |
| - var meta = document.createElement('meta'); |
63 |
| - meta.setAttribute('http-equiv', 'Content-Security-Policy'); |
64 |
| - meta.setAttribute('content', "script-src 'none';"); |
65 |
| - document.head.appendChild(meta); |
66 |
| - } |
67 |
| - |
68 |
| - function setDisconnected(isDisconnected) { |
69 |
| - document.getElementById('con-error').style.display = |
70 |
| - isDisconnected ? 'block' : 'none'; |
71 |
| - } |
| 27 | + <script src="/socket.io/socket.io.min.js"></script> |
| 28 | + <script src="/index.js"></script> |
72 | 29 | </script>
|
73 | 30 | </head>
|
74 | 31 | <body>
|
|
0 commit comments