* More updates to instant messenger:
authorArt Cancro <ajc@citadel.org>
Thu, 12 Jan 2006 04:23:38 +0000 (04:23 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 12 Jan 2006 04:23:38 +0000 (04:23 +0000)
  - Better delineation of input box.  Added an icon and a slightly darker
    background color so you can see where the input box actually is.
  - Auto refresh every 5 seconds instead of 30
  - WebCit now fires off a JavaScript test after 30 seconds of inactivity
    to see if the instant messenger window needs to be opened

webcit/ChangeLog
webcit/paging.c
webcit/static/instant_messenger.html
webcit/webcit.c

index 4794c837f276285c8448fa5fb636a9b4751a0e6c..9230411098c21cf3551529bf68498f3cf316383c 100644 (file)
@@ -1,5 +1,13 @@
 $Id$
 
+Wed Jan 11 23:20:48 EST 2006 ajc
+* More updates to instant messenger:
+  - Better delineation of input box.  Added an icon and a slightly darker
+    background color so you can see where the input box actually is.
+  - Auto refresh every 5 seconds instead of 30
+  - WebCit now fires off a JavaScript test after 30 seconds of inactivity
+    to see if the instant messenger window needs to be opened
+
 Wed Jan 11 16:59:54 EST 2006 ajc
 * More updates to instant messenger.  When new messages arrive, the window
   automatically scrolls to the bottom and the input box is refocused.
index a72dba26bcff1e5346f1126d9188acdd33703426..e15515691a4577884507f35d00ae2073b376e9f7 100644 (file)
@@ -156,17 +156,34 @@ void page_popup(void)
 {
        char buf[SIZ];
 
+       /* First, do the check as part of our page load. */
        serv_puts("NOOP");
        serv_getln(buf, sizeof buf);
        if (buf[3] == '*') {
                if ((time(NULL) - WC->last_pager_check) > 60) {
                        wprintf("<script type=\"text/javascript\">"
                                " window.open('static/instant_messenger.html', 'CTDL_MESSENGER', "
-                               " 'width=600,height=400');"
+                               " 'width=700,height=400');"
                                "</script>"
                        );      
                }
        }
+
+       /* Then schedule it to happen again a minute from now if the user is idle. */
+       wprintf("<script type=\"text/javascript\">      "
+               " function HandleSslp(sslg_xmlresponse) {       "
+               "  sslg_response = sslg_xmlresponse.responseText.substr(0, 1);  "
+               "  if (sslg_response == 'Y') {  "
+               "   window.open('static/instant_messenger.html', 'CTDL_MESSENGER',      "
+               "    'width=700,height=400');   "
+               "   }   "
+               " }     "
+               " function CheckPager() {       "
+               "  new Ajax.Request('sslg', { method: 'get', onSuccess: HandleSslp } ); "
+               " }     "
+               " new PeriodicalExecuter(CheckPager, 30);       "
+               "</script>\n"
+       );
 }
 
 
index 57666ac8cc8e3d620e67bb4cc057c1f82092f7c9..87f9ab533e7189db3c97409501a8e818e23c8a16 100644 (file)
@@ -4,7 +4,7 @@
        <script type="text/javascript" src="prototype.js"></script>
        <script type="text/javascript" src="wclib.js"></script>
 </head>
-<body>
+<body onLoad='FetchNewMsgs();'>
 
 <div id="thetop" style="position:fixed;width:100%;height:15%;top:0%;left:0%">
 <div id="spacer1" style="background:#aaaaaa"><br></div>
@@ -115,13 +115,14 @@ function ShowNewMsg(gexp_xmlresponse) {
                        + '<div id=\"tab_' + which_div + '\" style=\"display:none;cursor:pointer\">'
                        + '<div id=\"' + which_div + '\">'
                        + '</div>'
-                       + '<div id=\"response_' + which_div + '\">'
+                       + '<div id=\"response_' + which_div + '\" style=\"background:#ddddee\">'
                        + '<br><form method=\"post\" action=\"null\" name=\"sendform_' + which_div + '\" '
                        + 'onSubmit=\"return SendSomething(\'' + which_div + '\', \'sendform_'
                        + which_div + '\', \'' + sender + '\');\">'
-                       + '<input type=\"text\" size=\"80\" maxlength=\"80\" name=\"sendthis\">'
+                       + '<img src=\"citadelchat_16x.gif\">&nbsp;'
+                       + '<input type=\"text\" size=\"72\" maxlength=\"72\" name=\"sendthis\">'
                        + '</form>'
-                       + '</div>'
+                       + '<br></div>'
                        + '</div>\n';
                $('tab_bar').innerHTML =
                          $('tab_bar').innerHTML
@@ -196,7 +197,7 @@ function GrabMyName(greg_xmlresponse) {
 
 
 // Cause FetchNewMsgs() to be called periodically.
-new PeriodicalExecuter(FetchNewMsgs, 3);
+new PeriodicalExecuter(FetchNewMsgs, 5);
 
 </script>
 
index 046c603d738e6408dec77c9748727058139d4a3b..92eed0d9395f666797211bdb70ff84e673ecf71a 100644 (file)
@@ -407,7 +407,6 @@ void output_headers(        int do_httpheaders,     /* 1 = output HTTP headers
                if ( (WC->logged_in) && (!unset_cookies) ) {
                        wprintf("<div id=\"iconbar\">");
                        do_selected_iconbar();
-                       wprintf("</div>\n");
                }
                if (do_room_banner == 1) {
                        wprintf("<div id=\"banner\">\n");
@@ -819,11 +818,9 @@ void ajax_servcmd(void)
 
        begin_ajax_response();
 
-       /* lprintf(9, "Sending cmd: %s\n", bstr("g_cmd")); */
        serv_printf("%s", bstr("g_cmd"));
        serv_getln(buf, sizeof buf);
        wprintf("%s\n", buf);
-       /* lprintf(9, "   Response: %s\n", buf); */
 
        if (buf[0] == '8') {
                serv_printf("\n\n000");
@@ -853,9 +850,42 @@ void ajax_servcmd(void)
        }
 
        end_ajax_response();
+       
+       /* This is kind of an ugly hack, but this is the only place it can go.
+        * If the command was GEXP, then the instant messenger window must be
+        * running, so reset the "last_pager_check" watchdog timer so
+        * that page_popup() doesn't try to open it a second time.
+        */
+       if (!strncasecmp(bstr("g_cmd"), "GEXP", 4)) {
+               WC->last_pager_check = time(NULL);
+       }
 }
 
 
+/*
+ * Helper function for the asynchronous check to see if we need
+ * to open the instant messenger window.
+ */
+void seconds_since_last_gexp(void)
+{
+       char buf[256];
+
+       begin_ajax_response();
+       if ( (time(NULL) - WC->last_pager_check) < 30) {
+               wprintf("NO\n");
+       }
+       else {
+               serv_puts("NOOP");
+               serv_getln(buf, sizeof buf);
+               if (buf[3] == '*') {
+                       wprintf("YES");
+               }
+               else {
+                       wprintf("NO");
+               }
+       }
+       end_ajax_response();
+}
 
 
 
@@ -1248,6 +1278,8 @@ void session_loop(struct httprequest *req)
                display_main_menu();
        } else if (!strcasecmp(action, "who")) {
                who();
+       } else if (!strcasecmp(action, "sslg")) {
+               seconds_since_last_gexp();
        } else if (!strcasecmp(action, "who_inner_html")) {
                begin_ajax_response();
                who_inner_div();