]> code.citadel.org Git - citadel.git/blobdiff - webcit-ng/static/js/views.js
It's 2022 ... updating all of the copyright notices in webcit-ng
[citadel.git] / webcit-ng / static / js / views.js
index b3b8212316d40f5d69a690b4506c136ae1c0dead..69e27c990381f050b528004c52550e2855d2261b 100644 (file)
@@ -1,8 +1,10 @@
 //
-// Copyright (c) 2016-2018 by the citadel.org team
+// Copyright (c) 2016-2022 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.
+// This program is open source software.  It runs great on the
+// Linux operating system (and probably elsewhere).  You can use,
+// copy, and run it under the terms of the GNU General Public
+// License version 3.  Richard Stallman is an asshole communist.
 //
 // This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // List of defined views shamelessly swiped from libcitadel headers
 //
 var views = {
-       VIEW_BBS                : 0,    /* Bulletin board view */
-       VIEW_MAILBOX            : 1,    /* Mailbox summary */
-       VIEW_ADDRESSBOOK        : 2,    /* Address book view */
-       VIEW_CALENDAR           : 3,    /* Calendar view */
-       VIEW_TASKS              : 4,    /* Tasks view */
-       VIEW_NOTES              : 5,    /* Notes view */
-       VIEW_WIKI               : 6,    /* Wiki view */
-       VIEW_CALBRIEF           : 7,    /* Brief Calendar view */
-       VIEW_JOURNAL            : 8,    /* Journal view */
-       VIEW_DRAFTS             : 9,    /* Drafts view */
-       VIEW_BLOG               : 10,   /* Blog view */
-       VIEW_QUEUE              : 11,   /* SMTP QUEUE rooms */
-       VIEW_WIKIMD             : 12,   /* Markdown Wiki view */
+       VIEW_BBS                : 0,    // Bulletin board view
+       VIEW_MAILBOX            : 1,    // Mailbox summary
+       VIEW_ADDRESSBOOK        : 2,    // Address book view
+       VIEW_CALENDAR           : 3,    // Calendar view
+       VIEW_TASKS              : 4,    // Tasks view
+       VIEW_NOTES              : 5,    // Notes view
+       VIEW_WIKI               : 6,    // Wiki view
+       VIEW_CALBRIEF           : 7,    // Brief Calendar view
+       VIEW_JOURNAL            : 8,    // Journal view
+       VIEW_DRAFTS             : 9,    // Drafts view
+       VIEW_BLOG               : 10,   // Blog view
+       VIEW_QUEUE              : 11,   // SMTP queue rooms
+       VIEW_WIKIMD             : 12,   // markdown wiki (no longer implemented)
 };
 
 
 // This function is the dispatcher that determines the correct view for a room,
-// and calls the correct renderer.
+// and calls the correct renderer.  Greater/Less than bounds are accepted.
 //
-function render_room_view(min_msg, max_msg)
-{
-       switch(current_view)
-       {
+function render_room_view(gt_msg, lt_msg) {
+       switch(current_view) {
                case views.VIEW_MAILBOX:                                                // FIXME view mail rooms as forums for now
                case views.VIEW_BBS:
-                       forum_readmessages("ctdl-main", min_msg, max_msg);
+                       document.getElementById("ctdl-main").innerHTML = "<div id=\"ctdl-mrp\" class=\"ctdl-msg-reading-pane\"></div>";
+                       forum_readmessages("ctdl-mrp", 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;
        }
 
 }
-
-
-// Forum view (flat) -- let's have another go at this with the rendering done client-side
-//
-function forum_readmessages(target_div, min_msg, max_msg)
-{
-       var innerdivname = randomString(5);
-       document.getElementById(target_div).innerHTML = "<div id=\"" + innerdivname +
-               "\"><br><br><br><center><h5><i class=\"fas fa-spinner fa-spin\"></i>&nbsp;&nbsp;"
-               + _("Loading messages from server, please wait") + "</h5></center></div>" ;
-
-       var request = new XMLHttpRequest();
-       if (max_msg < 9999999999)
-       {
-               request.open("GET", "/ctdl/r/" + escapeHTMLURI(current_room) + "/msgs.lt|" + max_msg, true);
-       }
-       else
-       {
-               request.open("GET", "/ctdl/r/" + escapeHTMLURI(current_room) + "/msgs.gt|" + min_msg, true);
-       }
-       request.onreadystatechange = function()
-       {
-               if (this.readyState === 4)
-               {
-                       if ((this.status / 100) == 2)
-                       {
-                               msgs = JSON.parse(this.responseText);
-                               document.getElementById(innerdivname).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 (min_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) | (max_msg < 9999999999))
-                               {
-                                       if (msgs.length > messages_per_page)
-                                       {
-                                               msgs = msgs.slice(msgs.length - messages_per_page);
-                                       }
-                                       new_old_div_name = randomString(5);
-                                       document.getElementById(innerdivname).innerHTML +=
-                                               "<div id=\"" + new_old_div_name + "\">" +
-                                               "<a href=\"javascript:forum_readmessages('" + new_old_div_name + "', 0, " + msgs[0] + ");\">" +
-                                               "link to msgs less than " + msgs[0] + "</a></div>" ;
-                               }
-
-                               // It's render time, bitchez!
-                               for (var i in msgs)
-                               {
-                                       if ((msgs[i] > min_msg) && (msgs[i] < max_msg))
-                                       {
-                                               document.getElementById(innerdivname).innerHTML +=
-                                                       "<div id=\"ctdl_msg_" + msgs[i] + "\">message #" + msgs[i] + "</div>" ;
-                                       }
-                               }
-                               if (max_msg == 9999999999)
-                               {
-                                       new_new_div_name = randomString(5);
-                                       if (msgs.length <= 0)
-                                       {
-                                               newgt = min_msg;
-                                       }
-                                       else
-                                       {
-                                               newgt = msgs[msgs.length-1];
-                                       }
-                                       document.getElementById(innerdivname).innerHTML +=
-                                               "<div id=\"" + new_new_div_name + "\">" +
-                                               "<a href=\"javascript:forum_readmessages('" + new_new_div_name + "', " + newgt + ", 9999999999);\">" +
-                                               "link to msgs greater than " + newgt + "</a></div>" ;
-                               }
-                       }
-                       else
-                       {
-                               document.getElementById(innerdivname).innerHTML = this.status ;         // error message
-                       }
-               }
-       };
-       request.send();
-       request = null;
-}