From 6bd3da59930f2ccfdd143b265e7716b3decfe184 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 5 Jan 2009 19:03:31 +0000 Subject: Fixed logfiles tail bug on FireFox. Actually made it much better so scroll sticks. git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@1665 ab2d0c66-481e-0410-8bed-d214d4d58bed --- logfiles-tail-html.lsp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/logfiles-tail-html.lsp b/logfiles-tail-html.lsp index 6bfe26d..72725ad 100644 --- a/logfiles-tail-html.lsp +++ b/logfiles-tail-html.lsp @@ -12,7 +12,28 @@ {name:'<% io.write(form.value.filename.value) if form.value.grep.value ~= "" then io.write("',grep:'"..form.value.grep.value) end %>', offset:currentoffset}, function(data) { data.value.filecontent.value = data.value.filecontent.value.split("\n").join("
\n"); - $("#filecontent").append(data.value.filecontent.value).scrollTop(999999999); + + /* Before updating content, determine where we're scrolled to. If we're within 25 pixels of + the bottom, we'll stick to the bottom. */ + var content = $("#filecontent").get(0); + var currentHeight = 0; + var scrollTop = content.scrollTop; + if (content.scrollHeight > 0) + currentHeight = content.scrollHeight; + else + if (content.offsetHeight > 0) + currentHeight = content.offsetHeight; + if (currentHeight - scrollTop - ((content.style.pixelHeight) ? content.style.pixelHeight : content.offsetHeight) < 25) + scrollTop = currentHeight; + + $("#filecontent").append(data.value.filecontent.value); + + /* Now, set the scroll. */ + if (scrollTop < currentHeight) + content.scrollTop = scrollTop; + else + content.scrollTop = content.scrollHeight; + currentoffset = data.value.filesize.value; $("DT:contains('File size')").next().text(currentoffset); } -- cgit v1.2.3