Hallo, ich habe mir diesen Chat unter die Lupe genommen:
http://www.plasticshore.com/projects/chat/
Nun möcht ich das Ding auf meine Bedürfnisse modifizieren, dazu gehört vor allem, das das Posten einer Nachricht über ein anderes Interface stattfindet und deshlab rausfliegt.
Im Prinzip tut auch alles, das Problem ist nur, statt einen normalen Refrsh zu machen, hängt er mir alles hinterander an. Also mit jedem neuen Datadownload hängt er einmal alle Daten hinten an, statt sie zu aktualisieren.
Das ganze sieht nun mal so aus:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="default.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript">
var GetChaturl = "get.php";
window.onload = initJavaScript;
function initJavaScript() {
receiveChatText(); //initiates the first data query
}
//initiates the first data query
function receiveChatText() {
if (httpReceiveChat.readyState == 4 || httpReceiveChat.readyState == 0) {
httpReceiveChat.open("GET",GetChaturl + '?sid=<?php echo session_id();?>');
httpReceiveChat.onreadystatechange = handlehHttpReceiveChat;
httpReceiveChat.send(null);
}
}
//deals with the servers' reply to requesting new content
function handlehHttpReceiveChat() {
if (httpReceiveChat.readyState == 4) {
results = httpReceiveChat.responseText.split('---'); //the fields are seperated by ---
if (results.length > 2)
{
for(i=0;i < (results.length-1);i=i+3)
{
//goes through the result one message at a time
insertNewContent(results[i+1],results[i+2]); //inserts the new content into the page
}
lastID = results[results.length-4];
}
setTimeout('receiveChatText();',4000); //executes the next data query in 4 seconds
}
}
//inserts the new content into the page
function insertNewContent(liName,liText) {
insertO = document.getElementById("outputList");
oLi = document.createElement('li');
oSpan = document.createElement('span');
oSpan.setAttribute('className','name'); //for IE's sake
oSpan.setAttribute('class','name');
oName = document.createTextNode(liName+': ');
oText = document.createTextNode(liText);
oSpan.appendChild(oName);
oLi.appendChild(oSpan);
oLi.appendChild(oText);
insertO.insertBefore(oLi, insertO.firstChild);
}
//initiates the XMLHttpRequest object
//as found here: http://www.webpasties.com/xmlHttpRequest
function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
// initiates the two objects for sending and receiving data
var httpReceiveChat = getHTTPObject();
</script>
</head>
<body>
<div id="content">
<div id="chatoutput">
<h2>chat output</h2>
<ul id="outputList">
<li><span class="name">plasticshore chat:</span>welcome</li>
</ul>
</div>
</div>
</body>
</html>
Die File die er sich reinziehen soll sieht so aus:
http://www.plasticshore.com/projects...etChatData.php
Die Parameterübergabe scheint jedoch sinnlos zu sein, weil bringen nichts.
kann mir irgendwer helfen woran das liegt?!
http://www.plasticshore.com/projects/chat/
Nun möcht ich das Ding auf meine Bedürfnisse modifizieren, dazu gehört vor allem, das das Posten einer Nachricht über ein anderes Interface stattfindet und deshlab rausfliegt.
Im Prinzip tut auch alles, das Problem ist nur, statt einen normalen Refrsh zu machen, hängt er mir alles hinterander an. Also mit jedem neuen Datadownload hängt er einmal alle Daten hinten an, statt sie zu aktualisieren.
Das ganze sieht nun mal so aus:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="default.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript">
var GetChaturl = "get.php";
window.onload = initJavaScript;
function initJavaScript() {
receiveChatText(); //initiates the first data query
}
//initiates the first data query
function receiveChatText() {
if (httpReceiveChat.readyState == 4 || httpReceiveChat.readyState == 0) {
httpReceiveChat.open("GET",GetChaturl + '?sid=<?php echo session_id();?>');
httpReceiveChat.onreadystatechange = handlehHttpReceiveChat;
httpReceiveChat.send(null);
}
}
//deals with the servers' reply to requesting new content
function handlehHttpReceiveChat() {
if (httpReceiveChat.readyState == 4) {
results = httpReceiveChat.responseText.split('---'); //the fields are seperated by ---
if (results.length > 2)
{
for(i=0;i < (results.length-1);i=i+3)
{
//goes through the result one message at a time
insertNewContent(results[i+1],results[i+2]); //inserts the new content into the page
}
lastID = results[results.length-4];
}
setTimeout('receiveChatText();',4000); //executes the next data query in 4 seconds
}
}
//inserts the new content into the page
function insertNewContent(liName,liText) {
insertO = document.getElementById("outputList");
oLi = document.createElement('li');
oSpan = document.createElement('span');
oSpan.setAttribute('className','name'); //for IE's sake
oSpan.setAttribute('class','name');
oName = document.createTextNode(liName+': ');
oText = document.createTextNode(liText);
oSpan.appendChild(oName);
oLi.appendChild(oSpan);
oLi.appendChild(oText);
insertO.insertBefore(oLi, insertO.firstChild);
}
//initiates the XMLHttpRequest object
//as found here: http://www.webpasties.com/xmlHttpRequest
function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
// initiates the two objects for sending and receiving data
var httpReceiveChat = getHTTPObject();
</script>
</head>
<body>
<div id="content">
<div id="chatoutput">
<h2>chat output</h2>
<ul id="outputList">
<li><span class="name">plasticshore chat:</span>welcome</li>
</ul>
</div>
</div>
</body>
</html>
Die File die er sich reinziehen soll sieht so aus:
http://www.plasticshore.com/projects...etChatData.php
Die Parameterübergabe scheint jedoch sinnlos zu sein, weil bringen nichts.
kann mir irgendwer helfen woran das liegt?!
Kommentar