Do a JavaScript alert if we fail to open the Instant Messenger window.
authorArt Cancro <ajc@citadel.org>
Fri, 27 Jan 2006 20:04:11 +0000 (20:04 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 27 Jan 2006 20:04:11 +0000 (20:04 +0000)
webcit/ChangeLog
webcit/paging.c

index c85fa733d42c4671de3aa3c142f53c9537486c28..1a4feaa4ed62506bc4a13642a6c54a6d54573294 100644 (file)
@@ -1,5 +1,8 @@
 $Id$
 
+Fri Jan 27 15:03:42 EST 2006 ajc
+* Do a JavaScript alert if we fail to open the Instant Messenger window.
+
 Fri Jan 27 13:50:38 EST 2006 ajc
 * Page popups work again.
 
index 097b6b74ba6b68caccb2508610b3c7f8e2dc81cb..3dee4f53319e9eca518ce0e03c59a0bda0eace54 100644 (file)
@@ -160,34 +160,52 @@ void page_popup(void)
 {
        char buf[SIZ];
 
+       /** JavaScript function to alert the user that popups are probably blocked */
+       wprintf("<script type=\"text/javascript\">      "
+               "function PopUpFailed() {       "
+               " alert(\"%s\");        "
+               "}      "
+               "</script>\n",
+               _("You have one or more instant messages waiting, but the Citadel Instant Messenger "
+                 "window failed to open.  This is probably because you have a popup blocker "
+                 "installed.  Please configure your popup blocker to allow popups from this site "
+                 "if you wish to receive instant messages.")
+       );
+
        /** 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=700,height=400');"
+                               " var oWin = window.open('static/instant_messenger.html', "
+                               " 'CTDL_MESSENGER', 'width=700,height=400');    "
+                               " if (oWin==null || typeof(oWin)==\"undefined\") {      "
+                               "  PopUpFailed();       "
+                               " }     "
                                "</script>"
                        );      
                }
        }
 
        /** Then schedule it to happen again a minute from now if the user is idle. */
-       wprintf("<script type=\"text/javascript\">      \n"
-               " function HandleSslp(sslg_xmlresponse) {       \n"
-               "  sslg_response = sslg_xmlresponse.responseText.substr(0, 1);  \n"
-               "  if (sslg_response == 'Y') {  \n"
-               "   window.open('static/instant_messenger.html', 'CTDL_MESSENGER',      \n"
-               "    'width=700,height=400');   \n"
-               "   }   \n"
-               " }     \n"
-               " function CheckPager() {       \n"
-               "  new Ajax.Request('sslg', { method: 'get', parameters: Math.random(), \n"
-               "   onSuccess: HandleSslp } );  \n"
-               " }     \n"
-               " new PeriodicalExecuter(CheckPager, 30);       \n"
-               "</script>      \n"
+       wprintf("<script type=\"text/javascript\">      "
+               " function HandleSslp(sslg_xmlresponse) {       "
+               "  sslg_response = sslg_xmlresponse.responseText.substr(0, 1);  "
+               "  if (sslg_response == 'Y') {  "
+               "   var oWin = window.open('static/instant_messenger.html', 'CTDL_MESSENGER',   "
+               "    'width=700,height=400');   "
+               "   if (oWin==null || typeof(oWin)==\"undefined\") {    "
+               "    PopUpFailed();     "
+               "   }   "
+               "  }    "
+               " }     "
+               " function CheckPager() {       "
+               "  new Ajax.Request('sslg', { method: 'get', parameters: Math.random(), "
+               "   onSuccess: HandleSslp } );  "
+               " }     "
+               " new PeriodicalExecuter(CheckPager, 30);       "
+               "</script>      "
        );
 }