X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=webcit-ng%2Fstatic%2Fjs%2Fviews.js;h=cf975ba0417442e0bb57fa609ccbc8d753cd14dc;hp=3df8843153a9944bb78130de89f6bcd6e72e96b0;hb=269decbb69b66c91c370b640101069084ecbfab7;hpb=a2e2b0eab5e29c1bd61ec21737d28d3cb70ee364 diff --git a/webcit-ng/static/js/views.js b/webcit-ng/static/js/views.js index 3df884315..cf975ba04 100644 --- a/webcit-ng/static/js/views.js +++ b/webcit-ng/static/js/views.js @@ -1,5 +1,5 @@ // -// Copyright (c) 2016-2017 by the citadel.org team +// Copyright (c) 2016-2018 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. @@ -32,9 +32,10 @@ var views = { // This function is the dispatcher that determines the correct view for a room, // and calls the correct renderer. // -function render_room_view() { - - switch(current_view) { +function render_room_view() +{ + switch(current_view) + { case views.VIEW_MAILBOX: // FIXME view mail rooms as forums for now case views.VIEW_BBS: forum_readmessages("flat"); @@ -51,18 +52,25 @@ function render_room_view() { // The inner div exists so that if the user clicks away early, the main div doesn't get clobbered when the load completes. // The parameter can be set to "flat" or "threads" which is passed directly to the API // -function forum_readmessages(flat_or_threads) { +function XX_forum_readmessages(flat_or_threads) +{ var innerdivname = randomString(5); - document.getElementById("main").innerHTML = "
" + _("Loading messages from server, please wait") + "
" ; + document.getElementById("main").innerHTML = "



  " + + _("Loading messages from server, please wait") + "
" ; var request = new XMLHttpRequest(); request.open("GET", "/ctdl/r/" + escapeHTMLURI(current_room) + "/" + flat_or_threads, 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) + { document.getElementById(innerdivname).outerHTML = this.responseText; } - else { + else + { document.getElementById(innerdivname).outerHTML = "ERROR " + this.status ; } } @@ -70,3 +78,39 @@ function forum_readmessages(flat_or_threads) { request.send(); request = null; } + + +// Forum view -- let's have another go at this with the rendering done client-side +// +function forum_readmessages(flat_or_threads) +{ + var innerdivname = randomString(5); + document.getElementById("main").innerHTML = "



  " + + _("Loading messages from server, please wait") + "
" ; + + var request = new XMLHttpRequest(); + request.open("GET", "/ctdl/r/" + escapeHTMLURI(current_room) + "/msgs.all", true); + request.onreadystatechange = function() + { + if (this.readyState === 4) + { + if ((this.status / 100) == 2) + { + document.getElementById(innerdivname).innerHTML = "Are we logged in? " + logged_in + "" ; + } + else + { + document.getElementById(innerdivname).innerHTML = this.status ; // error message + } + } + }; + request.send(); + request = null; +}