From 3b3c4c880427373283d4f6b2d798d503fc4a813f Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 21 Feb 2018 23:19:35 -0500 Subject: [PATCH] scroll to --- webcit-ng/static/js/views.js | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) 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