You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.4 KiB
44 lines
1.4 KiB
<!DOCTYPE html> |
|
<html> |
|
<head> |
|
<meta charset="utf-8"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui"> |
|
<title>Markdown preview</title> |
|
<link href="${MD_STYLE}" rel="stylesheet"></link> |
|
<style> |
|
code.json { |
|
line-height: 1.2em; |
|
} |
|
</style> |
|
${MD_JS} |
|
<script> |
|
(function($, undefined) { |
|
var socket = new WebSocket("ws://${WS_HOST}:${WS_PORT}"); |
|
socket.onopen = function() { |
|
console.log("Connection established."); |
|
}; |
|
socket.onclose = function(event) { |
|
if (event.wasClean) { |
|
alert('Connection closed gracefully.'); |
|
} else { |
|
alert('Connection terminated.'); |
|
} |
|
console.log('Code: ' + event.code + ' reason: ' + event.reason); |
|
}; |
|
socket.onmessage = function(event) { |
|
$("#markdown-body").html($(event.data).find("#content").html()); |
|
var scroll = $(document).height() * ($(event.data).find("#position-percentage").html() / 100); |
|
$("html, body").animate({ scrollTop: scroll }, 600); |
|
}; |
|
socket.onerror = function(error) { |
|
alert("Error: " + error.message); |
|
}; |
|
})(jQuery); |
|
</script> |
|
</head> |
|
<body> |
|
<article id="markdown-body" class="markdown-body"> |
|
<p>Markdown preview</p> |
|
</article> |
|
</body> |
|
</html>
|
|
|