Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
MDL-15370, remove old html and javascript code, merged from 1.9
  • Loading branch information
dongsheng committed Oct 8, 2008
1 parent 494f9df commit 1f8abb8
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 49 deletions.
37 changes: 20 additions & 17 deletions mod/chat/chatd.php
Expand Up @@ -250,23 +250,26 @@ function get_user_window($sessionid) {
}

ob_start();
echo '<html><head>';
echo '<script text="text/javascript">';
echo "//<![CDATA[\n";

echo 'function openpopup(url,name,options,fullscreen) {';
echo 'fullurl = "'.$CFG->wwwroot.'" + url;';
echo 'windowobj = window.open(fullurl,name,options);';
echo 'if (fullscreen) {';
echo ' windowobj.moveTo(0,0);';
echo ' windowobj.resizeTo(screen.availWidth,screen.availHeight); ';
echo '}';
echo 'windowobj.focus();';
echo 'return false;';
echo "}\n//]]>\n";
echo '</script></head><body style="font-face: serif;" bgcolor="#FFFFFF">';

echo '<table style="width: 100%;"><tbody>';
$refresh_inval = $CFG->chat_refresh_userlist * 1000;
echo <<<EOD
<html><head>
<meta http-equiv="refresh" content="$refresh_inval">
<style type="text/css"> img{border:0} </style>
<script type="text/javascript">
//<![CDATA[
function openpopup(url,name,options,fullscreen) {
fullurl = "$CFG->wwwroot" + url;
windowobj = window.open(fullurl,name,options);
if (fullscreen) {
windowobj.moveTo(0,0);
windowobj.resizeTo(screen.availWidth,screen.availHeight);
}
windowobj.focus();
return false;
}
//]]>
</script></head><body><table><tbody>
EOD;

// Get the users from that chatroom
$users = $this->chatrooms[$info['chatid']]['users'];
Expand Down
2 changes: 1 addition & 1 deletion mod/chat/gui_header_js/chatinput.php
Expand Up @@ -53,7 +53,7 @@ function enableForm() {
onsubmit="return empty_field_and_submit()" style="margin:0">
<input type="text" id="input_chat_message" name="chat_message" size="50" value="" />
<?php helpbutton('chatting', get_string('helpchatting', 'chat'), 'chat', true, false); ?><br />
<input type="checkbox" id="auto" size="50" value="" checked='true' /><?php echo get_string('autoscroll', 'chat');?>
<input type="checkbox" id="auto" size="50" value="" checked='true' /><label for="auto"><?php echo get_string('autoscroll', 'chat');?></label>
</form>

<form action="insert.php" method="post" target="empty" id="sendForm">
Expand Down
9 changes: 8 additions & 1 deletion mod/chat/gui_header_js/jsupdated.php
Expand Up @@ -193,7 +193,14 @@
}
}

print 'parent.msg.scroll(1,5000000);' . "\n\n";
print <<<EOD
if(parent.input){
var autoscroll = parent.input.document.getElementById('auto');
if(parent.msg && autoscroll && autoscroll.checked){
parent.msg.scroll(1,5000000);
}
}
EOD;
print "//]]>\n";
print '</script>' . "\n\n";
if ($beep) {
Expand Down
27 changes: 4 additions & 23 deletions mod/chat/gui_sockets/chatinput.php
Expand Up @@ -20,8 +20,6 @@
ob_start();
?>
<script type="text/javascript">
<!--

scroll_active = true;
function empty_field_and_submit() {
var cf = document.getElementById('sendform');
Expand All @@ -33,38 +31,21 @@ function empty_field_and_submit() {
inpf.chat_message.focus();
return false;
}
function prepareusers() {
var frm = window.parent.frames;
for(i = 0; i < frm.length; ++i) {
if(frm[i].name == "users") {
window.userFrame = frm[i];
window.userHREF = frm[i].location.href;
window.setTimeout("reloadusers();", <?php echo $CFG->chat_refresh_userlist; ?> * 1000);
}
}
}
function reloadusers() {
if(window.userFrame) {
window.userFrame.location.href = window.userFrame.location.href;
window.setTimeout("reloadusers();", <?php echo $CFG->chat_refresh_userlist; ?> * 1000);
}
}
function setfocus(){
document.getElementsByName("chat_message")[0].focus();
function setfocus() {
document.getElementsByName("chat_message")[0].focus();
}
// -->
</script>
<?php

$meta = ob_get_clean();
// TODO: there will be two onload in body tag, does it matter?
print_header('', '', '', 'inputform.chat_message', $meta, false, '&nbsp;', '', false, 'onload="setfocus(); prepareusers();"');
print_header('', '', '', 'inputform.chat_message', $meta, false, '&nbsp;', '', false, 'onload="setfocus();"');

?>

<form action="../empty.php" method="get" target="empty" id="inputform"
onsubmit="return empty_field_and_submit();">
&gt;&gt;<input type="text" name="chat_message" size="60" value="" />
<input type="text" name="chat_message" size="60" value="" />
<?php helpbutton("chatting", get_string("helpchatting", "chat"), "chat", true, false); ?>
</form>

Expand Down
4 changes: 2 additions & 2 deletions mod/chat/gui_sockets/index.php
Expand Up @@ -64,8 +64,8 @@
</head>
<frameset cols="*,200" border="5" framespacing="no" frameborder="yes" marginwidth="2" marginheight="1">
<frameset rows="0,*,50" border="0" framespacing="no" frameborder="no" marginwidth="2" marginheight="1">
<frame src="empty.php" name="empty" scrolling="auto" noresize marginwidth="2" marginheight="0">
<frame src="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=chat&amp;$params"; ?>" name="msg" scrolling="auto" noresize marginwidth="2" marginheight="0">
<frame src="../empty.php" name="empty" scrolling="auto" noresize marginwidth="2" marginheight="0">
<frame src="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=chat&amp;$params"; ?>" scrolling="auto" name="msg" noresize marginwidth="2" marginheight="0">
<frame src="chatinput.php?<?php echo $params ?>" name="input" scrolling="no" marginwidth="2" marginheight="1">
</frameset>
<frame src="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=users&amp;$params"; ?>" name="users" scrolling="auto" marginwidth="5" marginheight="5">
Expand Down
26 changes: 21 additions & 5 deletions mod/chat/lib.php
Expand Up @@ -4,16 +4,32 @@
require_once($CFG->libdir.'/pagelib.php');

// The HTML head for the message window to start with (<!-- nix --> is used to get some browsers starting with output
$CHAT_HTMLHEAD = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"><html><head></head>\n<body bgcolor=\"#FFFFFF\">\n\n".padding(200);
$CHAT_HTMLHEAD = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"><html><head></head>\n<body>\n\n".padding(200);

// The HTML head for the message window to start with (with js scrolling)
$CHAT_HTMLHEAD_JS = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"><html><head><script type=\"text/javascript\">\n//<![CDATA[\nfunction move()\n{\nif (scroll_active) window.scroll(1,400000);\nwindow.setTimeout(\"move()\",100);\n}\nscroll_active = true;\nmove();\n//]]>\n</script>\n</head>\n<body bgcolor=\"#FFFFFF\" onBlur=\"scroll_active = true\" onFocus=\"scroll_active = false\">\n\n".padding(200);
$CHAT_HTMLHEAD_JS = <<<EOD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><head><script type="text/javascript">
//<![CDATA[
function move(){
if (scroll_active)
window.scroll(1,400000);
window.setTimeout("move()",100);
}
var scroll_active = true;
move();
//]]>
</script>
</head>
<body onBlur="scroll_active = true" onFocus="scroll_active = false">
EOD;
$CHAT_HTMLHEAD_JS .= padding(200);

// The HTML code for standard empty pages (e.g. if a user was kicked out)
$CHAT_HTMLHEAD_OUT = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"><html><head><title>You are out!</title></head><body bgcolor=\"#FFFFFF\"></body></html>";
$CHAT_HTMLHEAD_OUT = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"><html><head><title>You are out!</title></head><body></body></html>";

// The HTML head for the message input page
$CHAT_HTMLHEAD_MSGINPUT = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"><html><head><title>Message Input</title></head><body bgcolor=\"#FFFFFF\">";
$CHAT_HTMLHEAD_MSGINPUT = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"><html><head><title>Message Input</title></head><body>";

// The HTML code for the message input page, with JavaScript
$CHAT_HTMLHEAD_MSGINPUT_JS = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"><html><head><title>Message Input</title>\n<script type=\"text/javascript\">\n//<![CDATA[\nscroll_active = true;\nfunction empty_field_and_submit()\n{\ndocument.fdummy.arsc_message.value=document.f.arsc_message.value;\ndocument.fdummy.submit();\ndocument.f.arsc_message.focus();\ndocument.f.arsc_message.select();\nreturn false;\n}\n//]]>\n</script>\n</head><body bgcolor=\"#FFFFFF\" OnLoad=\"document.f.arsc_message.focus();document.f.arsc_message.select();\">";
Expand All @@ -24,7 +40,7 @@
function padding($n){
$str = '';
for($i=0; $i<$n; $i++){
$str.='<!-- nix -->\n';
$str.="<!-- nix -->\n";
}
return $str;
}
Expand Down

0 comments on commit 1f8abb8

Please sign in to comment.