var scrolledToBottom = ($(window).scrollTop() + $(window).height() == $(document).height());

var lines = '<%=j render :partial => 'output_line_set', :collection => @line_sets %>';
var target = $("div.terminal div.printable");

<% if @since %>
  target.append(lines);
<% else %>
  target.html(lines);
<% end %>

<%= render :partial => 'refresh.js' %>

if (scrolledToBottom) {
  $("html, body").animate({ scrollTop: $(document).height() }, "slow");
}
