X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit-ng%2Fstatic%2Fjs%2Fviews.js;h=eae090ccc075854f51367f2e1d203270a140a086;hb=86ab29cd7358cd0793a2fab867e1432b33acd55d;hp=171fdf93576dc4b3fe54d5c336db5249ef0b6121;hpb=3da35ead77f2920042ddd54c3559d58a21abe3e3;p=citadel.git diff --git a/webcit-ng/static/js/views.js b/webcit-ng/static/js/views.js index 171fdf935..eae090ccc 100644 --- a/webcit-ng/static/js/views.js +++ b/webcit-ng/static/js/views.js @@ -1,5 +1,5 @@ // -// Copyright (c) 2016-2018 by the citadel.org team +// Copyright (c) 2016-2019 by the citadel.org team // // This program is open source software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 3. @@ -34,14 +34,14 @@ var views = { // function render_room_view(gt_msg, lt_msg) { - switch(current_view) - { + switch(current_view) { case views.VIEW_MAILBOX: // FIXME view mail rooms as forums for now case views.VIEW_BBS: forum_readmessages("ctdl-main", gt_msg, lt_msg); break; default: - document.getElementById("ctdl-main").innerHTML = "The view for " + current_room + " is " + current_view + " but there is no renderer." ; + document.getElementById("ctdl-main").innerHTML = + "The view for " + current_room + " is " + current_view + " but there is no renderer." ; break; } @@ -58,80 +58,83 @@ function forum_readmessages(target_div, gt_msg, lt_msg) + _("Loading messages from server, please wait") ; var request = new XMLHttpRequest(); - if (lt_msg < 9999999999) - { + if (lt_msg < 9999999999) { request.open("GET", "/ctdl/r/" + escapeHTMLURI(current_room) + "/msgs.lt|" + lt_msg, true); } - else - { + else { request.open("GET", "/ctdl/r/" + escapeHTMLURI(current_room) + "/msgs.gt|" + gt_msg, true); } - request.onreadystatechange = function() - { - if (this.readyState === 4) - { - if ((this.status / 100) == 2) - { + request.onreadystatechange = function() { + if (this.readyState === 4) { + if ((this.status / 100) == 2) { msgs = JSON.parse(this.responseText); document.getElementById(target_div).innerHTML = "" ; // If we were given an explicit starting point, by all means start there. // Note that we don't have to remove them from the array because we did a 'msgs gt|xxx' command to Citadel. - if (gt_msg > 0) - { + if (gt_msg > 0) { msgs = msgs.slice(0, messages_per_page); } - // show us the last 20 messages and scroll to the bottom (this will become the not-logged-in behavior) - else if ((logged_in) | (!logged_in) | (lt_msg < 9999999999)) - { - if (msgs.length > messages_per_page) - { + // Otherwise, show us the last 20 messages + else { + if (msgs.length > messages_per_page) { msgs = msgs.slice(msgs.length - messages_per_page); } new_old_div_name = randomString(5); - if (msgs.length < 1) - { + if (msgs.length < 1) { newlt = lt_msg; } - else - { + else { newlt = msgs[0]; } document.getElementById(target_div).innerHTML += - "