* Längerer Text scrollt nicht mehr die Eingabe raus
* Vorschau wird erst nach 1 Sekunde ohne Tippen aktualisiert, reduziert die Calls im Hintergrund
This commit is contained in:
parent
22cf9316a3
commit
458433a9f5
|
@ -20,5 +20,5 @@ def parse():
|
|||
return proc.communicate(input=data)
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.debug = True
|
||||
app.debug = False
|
||||
app.run()
|
||||
|
|
|
@ -7,11 +7,22 @@
|
|||
<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="https://ludikovsky.name/blog/blog.css" type="text/css" media="screen">
|
||||
<style>
|
||||
textarea {
|
||||
width: 100%;
|
||||
height: 800px;
|
||||
font-family: Hack, monospace;
|
||||
}
|
||||
div.container {
|
||||
height: 800px;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="col-md-2"></div>
|
||||
<div id="input" class="col-md-4">
|
||||
<textarea id="markdown" name="markdown" rows="25" cols="80" style="max-width: 100%"></textarea>
|
||||
<textarea id="markdown" name="markdown"></textarea>
|
||||
</div>
|
||||
<div class="container col-md-4">
|
||||
<article>
|
||||
|
@ -21,17 +32,33 @@
|
|||
</div>
|
||||
<div class="col-md-2"></div>
|
||||
<script>
|
||||
$('#input').on('input',
|
||||
function(){
|
||||
$.ajax({
|
||||
url: "http://localhost:5000/parse",
|
||||
success: function(result) {
|
||||
$('#output').html(result);
|
||||
},
|
||||
data: { markdown: $('#markdown').val() },
|
||||
type: 'POST'
|
||||
});
|
||||
}
|
||||
// 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: "http://localhost:5000/parse",
|
||||
success: function(result) {
|
||||
$('#output').html(result);
|
||||
},
|
||||
data: { markdown: $('#markdown').val() },
|
||||
type: 'POST'
|
||||
});
|
||||
idleState = true;
|
||||
}, idleWait);
|
||||
});
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
|
|
Loading…
Reference in New Issue