Skip to content

Commit

Permalink
"MDL-12304, fix double text"
Browse files Browse the repository at this point in the history
  • Loading branch information
dongsheng committed Jun 18, 2008
1 parent 315e4bc commit 654b0ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
22 changes: 14 additions & 8 deletions mod/chat/gui_header_js/jsupdate.php
Expand Up @@ -60,8 +60,8 @@
$chat_newrow = ($chat_lastrow + $num) % 2;

// no & in url, does not work in header!
$refreshurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&chat_lastrow=$chat_newrow";
$refreshurlamp = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&chat_lastrow=$chat_newrow";
$refreshurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&chat_lastrow=$chat_newrow";
$refreshurlamp = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&chat_lastrow=$chat_newrow";

header('Expires: Sun, 28 Dec 1997 09:32:45 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
Expand All @@ -88,7 +88,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript">
//<![CDATA[
if (parent.msg.document.getElementById("msgStarted") == null) {
if (parent.msg && parent.msg.document.getElementById("msgStarted") == null) {
parent.msg.document.close();
parent.msg.document.open("text/html","replace");
parent.msg.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
Expand All @@ -114,6 +114,7 @@
$refreshusers = true;
}
$us[$message->userid] = $timenow - $message->timestamp;
echo "if(parent.msg)";
echo "parent.msg.document.write('".addslashes_js($formatmessage->html)."\\n');\n";
}
}
Expand All @@ -122,21 +123,26 @@
set_field('chat_users', 'lastping', $chatuser->lastping, 'id', $chatuser->id );

if ($refreshusers) {
echo "if (parent.users.document.anchors[1] != null) {" .
"parent.users.location.href = parent.users.document.anchors[1].href;}\n";
?>
var link = parent.users.document.getElementById('refreshLink');
if (link != null) {
parent.users.location.href = link.href;
}
<?php
} else {
foreach($us as $uid=>$lastping) {
$min = (int) ($lastping/60);
$sec = $lastping - ($min*60);
$min = $min < 10 ? '0'.$min : $min;
$sec = $sec < 10 ? '0'.$sec : $sec;
$idle = $min.':'.$sec;
echo "if (parent.users.document.getElementById('uidle{$uid}') != null) {".
echo "if (parent.users && parent.users.document.getElementById('uidle{$uid}') != null) {".
"parent.users.document.getElementById('uidle{$uid}').innerHTML = '$idle';}\n";
}
}
?>
parent.msg.scroll(1,5000000);
if(parent.msg)
parent.msg.scroll(1,5000000);
//]]>
</script>
</head>
Expand All @@ -153,7 +159,7 @@

// support HTTP Keep-Alive
header("Content-Length: " . ob_get_length() );
ob_end_flush();
ob_end_flush();
exit;


Expand Down
2 changes: 1 addition & 1 deletion mod/chat/gui_header_js/users.php
Expand Up @@ -114,7 +114,7 @@ function update() {
$strbeep = get_string('beep', 'chat');


echo '<div style="display: none"><a href="'.$refreshurl.'" name="refreshLink">Refresh link</a></div>';
echo '<div style="display: none"><a href="'.$refreshurl.'" id="refreshLink">Refresh link</a></div>';
echo '<table width="100%">';
foreach ($chatusers as $chatuser) {
$lastping = $timenow - $chatuser->lastmessageping;
Expand Down

0 comments on commit 654b0ca

Please sign in to comment.