From: Art Cancro Date: Thu, 22 Feb 2018 04:19:35 +0000 (-0500) Subject: scroll to X-Git-Tag: v939~403 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=3b3c4c880427373283d4f6b2d798d503fc4a813f;hp=debc07dc6e5d3a2a77f75a85899911ee6a394b6b;p=citadel.git scroll to --- diff --git a/webcit-ng/static/js/views.js b/webcit-ng/static/js/views.js index 7945035cb..5ce6f762c 100644 --- a/webcit-ng/static/js/views.js +++ b/webcit-ng/static/js/views.js @@ -126,8 +126,26 @@ function forum_readmessages(target_div, gt_msg, lt_msg) "link to msgs greater than " + newgt + "" ; } + // Now figure out where to scroll to after rendering. + if (gt_msg > 0) + { + scroll_to = msgs[0]; + } + else if (lt_msg < 9999999999) + { + scroll_to = msgs[msgs.length-1]; + } + else if ( (logged_in) && (gt_msg == 0) && (lt_msg == 9999999999) ) + { + scroll_to = msgs[msgs.length-1]; + } + else + { + scroll_to = msgs[0]; // FIXME this is too naive + } + // Render the individual messages in the divs - render_messages(msgs, "ctdl_msg_", views.VIEW_BBS); + forum_render_messages(msgs, "ctdl_msg_", scroll_to) } else { @@ -140,22 +158,22 @@ function forum_readmessages(target_div, gt_msg, lt_msg) } -// Render a range of messages, in the view specified, with the div prefix specified +// Render a range of messages, with the div prefix specified // -function render_messages(msgs, prefix, view) +function forum_render_messages(msgs, prefix, scroll_to) { for (i=0; i