58 lines
1.9 KiB
HTML
58 lines
1.9 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Live Markdown</title>
|
|
<meta charset="utf-8">
|
|
<script src="https://cdn.jsdelivr.net/jquery/2.2.3/jquery.min.js"></script>
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/font-hack/2.018/css/hack.min.css">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css" type="text/css" media="screen">
|
|
<link rel="stylesheet" href="mdlive.css" type="text/css">
|
|
<link rel="stylesheet" href="{{ config.CSS }}" type="text/css" media="screen">
|
|
</head>
|
|
<body>
|
|
<div class="col-md-2">
|
|
{% include 'help.html' %}
|
|
</div>
|
|
<div id="input" class="col-md-4">
|
|
<textarea id="markdown" name="markdown"></textarea>
|
|
</div>
|
|
<div class="container col-md-4">
|
|
<article>
|
|
<div id="output">
|
|
</div>
|
|
</article>
|
|
</div>
|
|
<div class="col-md-2"></div>
|
|
<script>
|
|
// Background-Call nur noch wenn der User >= 1 Sekunde nichts tippt.
|
|
// Adaptiert von https://css-tricks.com/snippets/jquery/fire-event-when-user-is-idle/
|
|
idleTimer = null;
|
|
idleState = false;
|
|
idleWait = 1000;
|
|
|
|
$(document).ready(
|
|
function(){
|
|
$('#input').bind('keydown', function() {
|
|
clearTimeout(idleTimer);
|
|
if(idleState == true){
|
|
// User ist wieder aktiv
|
|
}
|
|
idleState = false;
|
|
idleTimer = setTimeout(function(){
|
|
$.ajax({
|
|
url: "{{ url_for('parse') }}",
|
|
success: function(result) {
|
|
$('#output').html(result);
|
|
},
|
|
data: { markdown: $('#markdown').val() },
|
|
type: 'POST'
|
|
});
|
|
idleState = true;
|
|
}, idleWait);
|
|
});
|
|
}
|
|
);
|
|
</script>
|
|
</body>
|
|
</html>
|