From 33c6624e549c58755932fee74d8fa49f10fc3a79 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 20 Jul 2009 13:42:58 +0000 Subject: Fixed minor logfiles tail bug in Firefox by using .val instead of .append. Only scroll on input. --- logfiles-tail-html.lsp | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/logfiles-tail-html.lsp b/logfiles-tail-html.lsp index 94bc4a8..af04da4 100644 --- a/logfiles-tail-html.lsp +++ b/logfiles-tail-html.lsp @@ -11,31 +11,32 @@ '<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action) %>', {name:'<% io.write(html.html_escape(form.value.filename.value)) if form.value.grep.value ~= "" then io.write("',grep:'"..html.html_escape(form.value.grep.value)) end %>', offset:currentoffset}, function(data) { - data.value.filecontent.value = data.value.filecontent.value.split("\n").join("
\n"); + if (currentoffset != data.value.filesize.value){ - /* 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; + /* 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); + $("#filecontent").val($("#filecontent").val() + data.value.filecontent.value); - /* Now, set the scroll. */ - if (scrollTop < currentHeight) - content.scrollTop = scrollTop; - else - content.scrollTop = content.scrollHeight; + /* 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); + currentoffset = data.value.filesize.value; + $("DT:contains('File size')").next().text(currentoffset); + }; } ); ID=window.setTimeout("Update();", 1000); -- cgit v1.2.3