plain-reload: Scroll down at document load.

When visiting the tail-reload page, for a short amount of time the
"unscrolled" version is shown. To circumvent that, let's scroll down
immediately at the first possibility to fill the gap between the loading
of the document and the first AJAX request coming in.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2015-04-03 00:00:27 +02:00
parent c251598241
commit 7a48ad375a
No known key found for this signature in database
GPG key ID: D0EBD0EC8C2DC961

View file

@ -9,18 +9,23 @@
[% IF reload %]
<script>
function scrollDown() {
$("#contents").scrollTop($("#contents").get(0).scrollHeight);
}
function injectTail() {
$.ajax({
url: "[% url %]",
dataType: "text",
success: function (tail) {
$("#contents").text(tail);
$("#contents").scrollTop($("#contents").get(0).scrollHeight);
scrollDown();
}
});
}
$(document).ready(function() {
scrollDown();
injectTail();
setInterval(injectTail, 5000);
});