Doesn't refresh (AJAX)

ubul - May 15, 2007 - 09:40
Project:Chatblock
Version:5.x-1.0.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:dwees
Status:closed
Description

Messages could be sent through AJAX, but they're showed only after page refresh. I have tried this on Linux/Firefox 2, Windows/Firefox 2, Windows/IE 6.

As far as I can see the setInterval instruction at the end of chatblock.js is not working because

  • there is no such as $rate (this may be an incidental exchange of the PHP variable $rate and JS variable chatblock.rate),
  • chatblock.rate is not yet defined.

Also, JS functions of jQuery are not reachable (out of scope?) in the iframe that is used to show the messages.

There were some typos in the filenames of the smileys.

Here are the patches:

--- chatblock.module    2007-05-15 11:18:55.000000000 +0200
+++ chatblock.original/chatblock.module 2007-05-08 20:56:02.000000000 +0200
@@ -280,13 +280,11 @@
     $output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
     $output .= "<head>\n";
     $output .= "<title>Chatbox Iframe<title>\n";
-    $output .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $url . '/css/chatblock.css' . "\" />\n";
-    $output .= "<script type=\"text/javascript\" src=\"" . $url . '/chatblock.js' . "\"></script>\n";
-    $output .= "<script type=\"text/javascript\" src=\"" . base_path() . 'misc/jquery.js' . "\"></script>\n";
+    $output .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . url($url . '/css/chatblock.css') . "\" />\n";
+    $output .= "<script type=\"text/javascript\" src=\"" . url($url . '/chatblock.js') . "\"></script>\n";
     $output .= "<script type=\"text/javascript\">\n";
     $output .= "chatblock.url = '". url('chatblock/view') . "';\n";
-    $output .= "chatblock.rate = ". $rate . ";\n";
-    $output .= "setInterval(chatboxGetMessage, chatblock.rate);\n";
+               $output .= "chatblock.rate = ". $rate . ";\n";
     $output .= "</script>\n";
     $output .= "</head>\n";
     $output .= "<body style=\"width:180px; background-color: white;\" onload=\"chatboxInitScroll();\">\n";
@@ -321,14 +319,14 @@
  *  This function filters the messages and adds the smileys and extra if any.
  */
function chatblock_filter_message($message) {
-  $url = drupal_get_path('module', 'chatblock');
+  $url = '/' . drupal_get_path('module', 'chatblock');
   $message = strip_tags($message);
-  $message = preg_replace("/>\:>/" , '<img src="'.$url.'/images/twisted.gif" alt=":twisted:" />', $message);
-  $message = preg_replace("/\?\:\)/" , '<img src="'.$url.'/images/think.gif" alt=":think:" />', $message);
+  $message = preg_replace("/>\:>/" , '<img src="'.$url.'/images  wisted.gif" alt=":twisted:" />', $message);
+  $message = preg_replace("/\?\:\)/" , '<img src="'.$url.'/images  hink.gif" alt=":think:" />', $message);
   $message = preg_replace("/N\:\)/" , '<img src="'.$url.'/images/naughty.gif" alt=":naughty:" />', $message);
   $message = preg_replace("/O\:\)/" , '<img src="'.$url.'/images/angel.gif" alt=":angel:" />', $message);
   $message = preg_replace("/\:D/" , '<img src="'.$url.'/images/biggrin.gif" alt=":biggrin:" />', $message);
-  $message = preg_replace("/\:P/" , '<img src="'.$url.'/images/tongue.gif" alt=":tongue:" />', $message);
+  $message = preg_replace("/\:P/" , '<img src="'.$url.'/images  ongue.gif" alt=":tongue:" />', $message);
   $message = preg_replace("/\:o/" , '<img src="'.$url.'/images/impressed.gif" alt=":impressed:" />', $message);
   $message = preg_replace("/\:\|/" , '<img src="'.$url.'/images/neutral.gif" alt=":neutral:" />', $message);
   $message = preg_replace("/8-\)/" , '<img src="'.$url.'/images/cool.gif" alt=":cool:" />', $message);

And for the chatblock.js:

--- chatblock.js        2007-05-15 11:03:32.000000000 +0200
+++ chatblock.original/chatblock.js     2007-05-08 20:56:02.000000000 +0200
@@ -14,7 +14,7 @@
   }
}

-var chatblock = new Object();
+var chatblock;

/**
  * Creates an HTTP POST request and sends the response to the callback function
@@ -80,4 +80,4 @@
         return;
}

-// chatBlockInterval = window.setInterval(chatboxGetMessage, chatblock.rate);
\ No newline at end of file
+chatBlockInterval = window.setInterval(chatboxGetMessage, $rate);
\ No newline at end of file

Use Firebug!

#1

dwees - May 15, 2007 - 17:38
Assigned to:Anonymous» dwees

I do actually use Firebug but it seems to have some issues with displaying errors from my domain. Not sure totally why, I've tried changing all the settings I can. It shows errors on my local machine just fine.

I'll try out these patches and see if they fix these problems, thank you.

Dave

#2

dwees - May 15, 2007 - 17:54

Actually I deliberated copied the functions out of the old drupal.js because I noticed IE was having problems with the double inclusion of jQuery.js on the same page (it seems to me that IE can't handled two different frames using the same JS functions, but maybe it was my imagination).

So I've replaced the line that does the Ajax with what I think should be the Drupal.js equivalent.

The line starting $.Ajax(blah blah... etc..) becomes instead

chatblock.HTTPPost(chatblock.url, chatblockResponse, false, message);

Also, this isn't a huge issue, but I believe you've created your patch in the opposite direction...from new to old.

Dave

#3

ubul - May 16, 2007 - 05:38

I didn't know the old version. I started to use Drupal and Chatblock recently, with Drupal 5. This patch is a quick and dirty solution to make Chatblock work. But now I see that it doesn't work for IE.

JQuery claims that it is cross-platform and more importantly cross-browser compliant, and it's in the Drupal core. Wouldn't it be better if you would swap the iframe with a div? Then you could use JQuery to append new messages and IE wouldn't have a problem. I know that then the JS disabled browsers simply couldn't use the chat, but with which option would you exclude more users?

I'll try to implement the forementioned version.

#4

dwees - May 16, 2007 - 05:50

That's a good solution. It would save on page load times as well. I think the reason why I used an iframe in the first place was to make the scrolling automatic, and to eventually allow for users with JavaScript disabled to use the chat without refreshing the whole page.

Dave

#5

pclux - May 18, 2007 - 16:40

so these patches are not good to go as they are here correct? after dwees testing, is there an updated patch... by the way , there are display issues in Safari just FYI. chatbox doesn't display nor does content. Works fine in Mac firefox, camino, etc.

#6

nepf - August 27, 2007 - 20:08

i have the same problem: no ajax refresh.
very sad!

#7

manolopm - August 30, 2007 - 00:31

Still the problem of the refresh is there... Any solution? a Patch?

#8

dwees - November 6, 2007 - 16:52
Status:needs review» fixed

#9

autofab - November 19, 2007 - 13:10

I just downloaded and installed the chatblock this morning. it seems like I have this same issue since the page doesn't automatically refresh. I'm sorry I didn't really understand what is the real status of this issue: has this been solved in the module version I downloaded today or does it need a patch that is still under development (there was no patch file or folder in the package)?
thank you so much, and please excuse me if I'm wrongly re-opening an already solved issue...

#10

dwees - November 19, 2007 - 14:33
Status:fixed» postponed (maintainer needs more info)

Hi there,

Can you give me some more information so I can figure out what's going on?

What browser are you using?
What version of Php do you have?
What is your version of Drupal?
How did you test that this module is not refreshing?

Dave

#11

autofab - November 19, 2007 - 18:37

hello!
I use both IExplorer 6 sp2 and FireFox 2.0.0.9
PHP Version is 4.4.7 on a Linux server Apache/2.0
Drupal version is 5.1
I simply tested by entering words and waiting for some time. nothing happens unless I manually refresh the webpage.
thanks so much for you help, but please consider I'm a simple user and I easily could have done something wrong ;)

#12

dwees - November 19, 2007 - 22:04

Have you ever used this module before, and if so, did you run the database upgrade script? What version of MySQL are you using? Can you confirm that the database tables have been created correctly? The timestamp column should be 'bigint'.

Also, can you try upgrading your version of Drupal? This is a reasonably easy matter of over-writing your core Drupal files and running the update script.

Dave

#13

dwees - November 19, 2007 - 22:50

Just downloaded the module and used a fresh install of Drupal and had the same problem. Apparently I forgot to change the column type for 'timestamp'. It should be 'bigint'. I'll fix this in the current version in CVS and hopefully this will be the end of the problems with this module.

Dave

#14

autofab - November 20, 2007 - 08:45
Status:postponed (maintainer needs more info)» fixed

wow... great news Dave!
it was indeed that timestamp issue that blocked everything. I made the change in the db and now everything runs smoothly!
thank you very much for your code and your kind support!

#15

Anonymous - December 4, 2007 - 08:51
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.