Closed (duplicate)
Project:
Shoutbox
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
22 May 2006 at 11:16 UTC
Updated:
8 May 2007 at 06:47 UTC
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
Comment #1
disterics commentedWill have to update this to use jquery.
Comment #2
disterics commentedDecided against this patch. Marking as duplicate of issue 128189