Code: Select all
session_start();
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
header( "Cache-Control: no-store, no-cache, must-revalidate" );
header( "Cache-Control: post-check=0, pre-check=0", false );
header( "Pragma: no-cache" );
header("Content-type: application/x-javascript");Code: Select all
function checkKey ( evt ) {
if ( evt.keyCode == 13 ) {
writeToConversation( document.conv.msg.value );
document.conv.msg.value = '';
}
}
function getHTTPObject() {
var xmlhttp;
xmlhttp = false;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
xmlhttp.overrideMimeType('text/html');
} else if (window.ActiveXObject)
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
return xmlhttp;
}
xmlhttp = getHTTPObject();
isBusy = false;
function writeToConversation ( msg ) {
try {
url = "/Scripts/Conversation.php?c=<?= $_GET['rm']; ?>&m=" + msg;
if ( isBusy ) xmlhttp.abort();
isBusy = true;
xmlhttp.open( "GET", url, true );
xmlhttp.onreadystatechange=function() {
if ( xmlhttp.readyState == 4 )
updateConv();
isBusy = false;
}
xmlhttp.send(null);
} catch ( e ) { }
}
function updateConv ( ) {
try {
url = "/Scripts/Conversation.php?c=<?= $_GET['rm']; ?>";
if ( isBusy ) xmlhttp.abort();
isBusy = true;
xmlhttp.open( "GET", url, true );
xmlhttp.onreadystatechange=function() {
if ( xmlhttp.readyState == 4 ) {
i = document.getElementById( 'convo' );
if ( i.length > 0 )
i.innerHTML = xmlhttp.responseText;
isBusy = false;
}
}
xmlhttp.send(null);
} catch ( e ) { }
setTimeout( "updateConv()", 300 );
}
updateConv();