* 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)
|
return proc.communicate(input=data)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.debug = True
|
app.debug = False
|
||||||
app.run()
|
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/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://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">
|
<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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="col-md-2"></div>
|
<div class="col-md-2"></div>
|
||||||
<div id="input" class="col-md-4">
|
<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>
|
||||||
<div class="container col-md-4">
|
<div class="container col-md-4">
|
||||||
<article>
|
<article>
|
||||||
|
@ -21,17 +32,33 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2"></div>
|
<div class="col-md-2"></div>
|
||||||
<script>
|
<script>
|
||||||
$('#input').on('input',
|
// Background-Call nur noch wenn der User >= 1 Sekunde nichts tippt.
|
||||||
function(){
|
// Adaptiert von https://css-tricks.com/snippets/jquery/fire-event-when-user-is-idle/
|
||||||
$.ajax({
|
idleTimer = null;
|
||||||
url: "http://localhost:5000/parse",
|
idleState = false;
|
||||||
success: function(result) {
|
idleWait = 1000;
|
||||||
$('#output').html(result);
|
|
||||||
},
|
$(document).ready(
|
||||||
data: { markdown: $('#markdown').val() },
|
function(){
|
||||||
type: 'POST'
|
$('#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>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue