It's very irritating when shoutbox reloads during writing. There is a small patch to that. It resets reload timer during typing into choutbox. Workflow:
Remove this one (from line 667):

  if ($auto_refresh = variable_get('shoutbox_refresh', 0)) {
    // TODO: Add code here to make sure the auto-refresh does not interrupt what a user is doing.
    // (ex: typing a shout, editing a shout, etc.)
     $output .= "<meta http-equiv=\"refresh\" content=\"$auto_refresh;url=" . url('shoutbox', NULL, NULL, true) . "\">\n";
  }

In line 405, jus before '//-->' add this code:

var mytime;
function doLoad()
{
	clearTimeout(mytime);
    mytime=setTimeout( "refresh()", <?php if ($auto_refresh = variable_get('shoutbox_refresh', 0)) print $auto_refresh; else print '9999' ?>*1000 );
}
function refresh()
{
    window.location.href = window.location.href;
}  
doLoad();

Insert attribute 'onkeypress' => 'doLoad();' into attributes (lines 181, 188, 194):

'#attributes' => array('onfocus' => 'javascript: if (this.value == "' . $default_nick . '") { this.value = "" };'),
'#attributes' => array('onfocus' => 'javascript: if (this.value == "' . $default_msg . '") { this.value = "" };'),
'#attributes' => array('onfocus' => 'javascript: if (this.value == "' . $default_url . '") { this.value = "" };'),

Change to:

'#attributes' => array('onfocus' => 'javascript: if (this.value == "' . $default_nick . '") { this.value = "" };', 'onkeypress' => 'doLoad();'),
'#attributes' => array('onfocus' => 'javascript: if (this.value == "' . $default_msg . '") { this.value = "" };', 'onkeypress' => 'doLoad();'),
'#attributes' => array('onfocus' => 'javascript: if (this.value == "' . $default_url . '") { this.value = "" };', 'onkeypress' => 'doLoad();'),

TODO: make this this code work during meassage editing (after posting). I have no ideas about that :|

Comments

disterics’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev
Category: task » feature

Will have to update this to use jquery.

disterics’s picture

Status: Needs work » Closed (duplicate)

Decided against this patch. Marking as duplicate of issue 128189