2014-09-14 11:18:24 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui">
|
|
|
|
<title>Markdown preview</title>
|
2014-09-15 07:30:13 +02:00
|
|
|
<link href="http://thomasf.github.io/solarized-css/solarized-dark.min.css" rel="stylesheet"></link>
|
2014-10-23 01:14:12 +02:00
|
|
|
<style>
|
2014-10-23 18:04:13 +02:00
|
|
|
code.json {
|
2014-10-23 01:14:12 +02:00
|
|
|
line-height: 1.2em;
|
|
|
|
}
|
|
|
|
</style>
|
2014-09-14 14:39:16 +02:00
|
|
|
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
|
2014-09-14 11:18:24 +02:00
|
|
|
<script>
|
2014-09-14 14:39:16 +02:00
|
|
|
(function($, undefined) {
|
2016-12-05 12:19:43 +01:00
|
|
|
var socket = new WebSocket("ws://${WS_HOST}:${WS_PORT}");
|
2014-09-14 14:39:16 +02:00
|
|
|
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) {
|
2014-09-15 21:21:44 +02:00
|
|
|
loadCSS($(event.data).find("#style").text());
|
|
|
|
$("#markdown-body").html($(event.data).find("#content").html());
|
2014-10-23 01:14:12 +02:00
|
|
|
var scroll = $(document).height() * ($(event.data).find("#position-percentage").html() / 100);
|
|
|
|
$("html, body").animate({ scrollTop: scroll }, 600);
|
2014-09-14 14:39:16 +02:00
|
|
|
};
|
|
|
|
socket.onerror = function(error) {
|
|
|
|
alert("Error: " + error.message);
|
|
|
|
};
|
2014-09-15 21:21:44 +02:00
|
|
|
|
|
|
|
loadCSS = function(href) {
|
|
|
|
var cssLink = $("<link rel='stylesheet' type='text/css' href='"+href+"'>");
|
2015-06-20 20:52:50 +02:00
|
|
|
$("link[rel='stylesheet']").remove();
|
2014-09-15 21:21:44 +02:00
|
|
|
$("head").append(cssLink);
|
|
|
|
};
|
2014-09-14 14:39:16 +02:00
|
|
|
})(jQuery);
|
2014-09-14 11:18:24 +02:00
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
2016-11-22 12:15:00 +01:00
|
|
|
<article id="markdown-body" class="markdown-body">
|
2014-09-14 11:18:24 +02:00
|
|
|
<p>Markdown preview</p>
|
|
|
|
</article>
|
|
|
|
</body>
|
|
|
|
</html>
|