]> code.citadel.org Git - citadel.git/blobdiff - webcit/who.c
* Discovered that Prototype makes it easy to auto-refresh, so I switched
[citadel.git] / webcit / who.c
index 0a8cc142039b71b015dc2f363d830b5026a7019e..91fe3d5a01d90d4c2ac246ef2215105b361100d1 100644 (file)
@@ -123,36 +123,6 @@ void who_inner_div(void) {
 }
 
 
-/*
- * XML-encapsulated version of wholist inner html
- */
-void who_inner_html(void) {
-       output_headers(0, 0, 0, 0, 0, 0, 0);
-
-       wprintf("Content-type: text/xml;charset=UTF-8\r\n"
-               "Server: %s\r\n"
-               "Connection: close\r\n"
-               "Pragma: no-cache\r\n"
-               "Cache-Control: no-store\r\n",
-               SERVER);
-       begin_burst();
-
-       wprintf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
-               "<ajax-response>\r\n"
-               "<response type=\"element\" id=\"fix_scrollbar_bug\">\r\n"
-       );
-
-       who_inner_div();
-
-       wprintf("</response>\r\n"
-               "</ajax-response>\r\n"
-               "\r\n"
-       );
-
-       wDumpContent(0);
-}
-
-
 /*
  * who is on?
  */
@@ -160,7 +130,7 @@ void who(void)
 {
        char title[256];
 
-       output_headers(1, 1, 2, 0, 0, 0, 0);
+       output_headers(1, 1, 2, 0, 0, 0);
 
        wprintf("<script type=\"text/javascript\">\n"
                "function ConfirmKill() { \n"
@@ -174,7 +144,6 @@ void who(void)
        wprintf("<IMG SRC=\"/static/usermanag_48x.gif\" ALT=\" \" "
                "ALIGN=MIDDLE "
                ">");
-               /* "onLoad=\"javascript:bodyOnLoad()\" " */
        wprintf("<SPAN CLASS=\"titlebar\"> ");
 
        snprintf(title, sizeof title, _("Users currently on %s"), serv_info.serv_humannode);
@@ -188,7 +157,7 @@ void who(void)
        wprintf("<div id=\"content\">\n");
 
        wprintf("<div style=\"display:inline\" id=\"fix_scrollbar_bug\">");
-       who_inner_div();        /* Actual data handled by another function */
+       who_inner_div();
        wprintf("</div>\n");
 
        wprintf("<div id=\"instructions\" align=center>");
@@ -199,20 +168,17 @@ void who(void)
        wprintf("</div>\n");
 
        /* JavaScript to make the ajax refresh happen:
-        * 1. Register the request 'getWholist' which calls the WebCit action 'who_inner_html'
-        * 2. Register the 'fix_scrollbar_bug' div as one we're interested in ajaxifying
-        * 3. setInterval to make the ajax refresh happen every 30 seconds.  The random number
-        *    in the request is there to prevent the eternally moronic Internet Explorer from
-        *    caching the XML even though it's been told not to.
+        * See http://www.sergiopereira.com/articles/prototype.js.html for info on Ajax.PeriodicalUpdater
+        * It wants: 1. The div being updated
+        *           2. The URL of the update source
+        *           3. Other flags (such as the HTTP method and the refresh frequency)
         */
        wprintf(
-               "<script type=\"text/javascript\">                                                              \n"
-               "       ajaxEngine.registerRequest('getWholist', 'who_inner_html');                             \n"
-               "       ajaxEngine.registerAjaxElement('fix_scrollbar_bug');                                    \n"
-               "       setInterval(\"ajaxEngine.sendRequest('getWholist', 'junk='+Math.random());\", 30000);   \n"
-               "</script>                                                                                      \n"
+               "<script type=\"text/javascript\">                                      "
+               " new Ajax.PeriodicalUpdater('fix_scrollbar_bug', '/who_inner_html',    "
+               "                            { method: 'get', frequency: 30 }  );       "
+               "</script>                                                              \n"
        );
-
        wDumpContent(1);
 }
 
@@ -249,7 +215,7 @@ void edit_me(void)
        } else if (strlen(bstr("cancel_button")) > 0) {
                http_redirect("/who");
        } else {
-               output_headers(1, 1, 0, 0, 0, 0, 0);
+               output_headers(1, 1, 0, 0, 0, 0);
 
                wprintf("<div id=\"banner\">\n");
                wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");