var GetChaturl = "getChatData.php";
var SendChaturl = "sendChatData.php";
var lastID = -1; //initial value will be replaced by the latest known id
window.onload = initJavaScript;
function initJavaScript() {
document.forms['chatForm'].elements['chatbarText'].setAttribute('autocomplete','off'); //prevents autofill function clash with this script
document.forms['chatForm'].elements['name'].setAttribute('autocomplete','off'); //prevents autofill function clash with this script
checkStatus(''); //sets the initial value and state of the input comment
checkName(); //checks the initial value of the input name
receiveChatText(); //initiates the first data query
// getPageif();
// getPageif1();
}
//initiates the first data query
function receiveChatText() {
if (httpReceiveChat.readyState == 4 || httpReceiveChat.readyState == 0) {
httpReceiveChat.open("GET",GetChaturl + '?bid=' + document.chatForm.bid.value + '&lastID=' + lastID + '&rand='+Math.floor(Math.random() * 1000000), true);
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+4) { //goes through the result one message at a time
insertNewContent(results[i],results[i+1],results[i+2],results[i+3]); //inserts the new content into the page
}
lastID = results[results.length-5];
}
setTimeout('receiveChatText();',4000); //executes the next data query in 4 seconds
}
}
//inserts the new content into the page
function insertNewContent(aa,liName,liText, blah) {
insertO = document.getElementById("outputList");
oLi = document.createElement('li');
oSpan = document.createElement('span');
oSpan.setAttribute('className','name'); //for IE's sake
oSpan.setAttribute('class','name');
oSpan.setAttribute('title',blah);
oName = document.createTextNode( liName + ': ');
oText = document.createTextNode(liText);
oSpan.appendChild(oName);
oLi.appendChild(oSpan);
ty= admin_delete(aa);
tx= special_features(aa);
oLi.innerHTML += jal_apply_filters(liText) + ty + tx;
insertO.insertBefore(oLi, insertO.firstChild);
}
//stores a new comment on the server
function sendComment() {
currentChatBid = document.forms['chatForm'].elements['bid'].value;
currentChatText = document.forms['chatForm'].elements['chatbarText'].value;
if (currentChatText != '' & (httpSendChat.readyState == 4 || httpSendChat.readyState == 0)) {
currentName = document.forms['chatForm'].elements['name'].value;
param = 'n='+ currentName+'&c='+ currentChatText + '&bid='+ currentChatBid;
httpSendChat.open("POST", SendChaturl, true);
httpSendChat.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
httpSendChat.onreadystatechange = handlehHttpSendChat;
httpSendChat.send(param);
document.forms['chatForm'].elements['chatbarText'].value = '';
} else {
setTimeout('sendComment();',1000);
}
}
//deals with the servers' reply to sending a comment
function handlehHttpSendChat() {
if (httpSendChat.readyState == 4) {
receiveChatText(); //refreshes the chat after a new comment has been added (this makes it more responsive)
}
}
//does celver things to the input and submit
function checkStatus(focusState) {
currentChatText = document.forms['chatForm'].elements['chatbarText'];
oSubmit = document.forms['chatForm'].elements['submit'];
if (currentChatText.value != '' || focusState == 'active') {
oSubmit.disabled = false;
} else {
oSubmit.disabled = true;
}
}
//autoasigns a random name to a new user
function checkName() {
currentName = document.forms['chatForm'].elements['name'];
if (currentName.value == '') {
currentName.value = 'guest_'+ Math.floor(Math.random() * 10000);
}
}
//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();
var httpSendChat = getHTTPObject();
var x = 10000;
/* clears default values from input boxes */
function clearText(thefield){
//if (thefield.defaultValue==thefield.value)
thefield.value = ""
}
function jal_apply_filters(s) {
return filter_smilies(make_links((s)));
}
var smilies = [
[':\\)', 'smile.gif'],
[':\\-\\)', 'smile.gif'],
[':D', 'biggrin.gif'],
[':\\(', 'sad.gif'],
[':o', 'splat.gif'],
[':eek:', 'eek.gif'],
[':s', 'confused.gif'],
[':lol:', 'lol.gif'],
[':cool:', 'cool.gif'],
[':mad:', 'mad.gif'],
[':razz:', 'razz.gif'],
[':\\$', 'redface.gif'],
[':evil:', 'evil.gif'],
[':tongue:','tongue.gif'],
[':cry:', 'cry.gif'],
[':roll:', 'rolleyes.gif'],
[':wink:', 'wink.gif'],
[':!:', 'exclaim.gif'],
[':\\?:', 'question.gif'],
[':shocked:', 'shocked.gif'],
[':>:', '04.gif'],
[':t', 'thumbup.gif'],
[':mrgreen:', 'mrgreen.gif']
];
function special_features(aa) {
text = ' ?';
//text = "";
return text;
}
function admin_delete(aa) {
text = "";
return text;
}
function special_featur(aa) {
var xmlhttp=false; //Clear our fetching variable
try {
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
} catch (e) {
try {
xmlhttp = new
ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
}
var file = 'special_features.php?id=' + aa; //This is the path to the file we just finished making *
xmlhttp.open('GET', file, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
var content = xmlhttp.responseText; //The content data which has been retrieved ***
// if( content ){ //Make sure there is something in the content variable
document.getElementById(debug).innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
// }
}
}
xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}
function admin_del(aa) {
var xmlhttp=false; //Clear our fetching variable
try {
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
} catch (e) {
try {
xmlhttp = new
ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
}
var file = 'del.php?id=' + aa; //This is the path to the file we just finished making *
xmlhttp.open('GET', file, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
var content = xmlhttp.responseText; //The content data which has been retrieved ***
if( content ){ //Make sure there is something in the content variable
document.getElementById('debug').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
}
}
}
xmlhttp.send(null) //Nullify the XMLHttpRequest
document.location.reload()
document.getElementById ("outputList").removeChild (aa);
return;
}
function make_links (s) {
var re = /((http|https|ftp):\/\/[^ ]*)/gi;
text = s.replace(re,"«link»");
return text;
}
function filter_smilies(s) {
for (var i = 0; i < smilies.length; i++) {
var search = smilies[i][0];
var replace = '
';
re = new RegExp(search, 'gi');
s = s.replace(re, replace);
}
return s;
};
function Toggle(item) {
obj=document.getElementById(item);
visible=(obj.style.display!="none")
if (visible) {
obj.style.display="none";
} else {
obj.style.display="block";
}
}
imgs_a=Array("images/star_on.gif","images/star_off.gif","images/star_on.gif");
var x_a = 0;
function change_a() {
document.getElementById("bob_a").src=imgs_a[++x_a];
if (x_a == 2) { x_a = 0; }
}
function getPageif(){
setTimeout("getPageif()",10000); //executes the next data query in 4 seconds
var xmlhttp1=false; //Clear our fetching variable
try {
xmlhttp1 = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
} catch (e) {
try {
xmlhttp1 = new
ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
} catch (E) {
xmlhttp1 = false;
}
}
if (!xmlhttp1 && typeof XMLHttpRequest!='undefined') {
xmlhttp1 = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
}
var file1 = ''; //This is the path to the file we just finished making *
xmlhttp1.open('GET', file1, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
xmlhttp1.onreadystatechange=function() {
if (xmlhttp1.readyState==4) { //Check if it is ready to recieve data
var content1 = xmlhttp1.responseText; //The content data which has been retrieved ***
if( content1 ){ //Make sure there is something in the content variable
document.getElementById('blah').innerHTML = content1; //Change the inner content of your div to the newly retrieved content ****
}
}
}
xmlhttp1.send(null) //Nullify the XMLHttpRequest
return;
}
function getPageif1(){
setTimeout("getPageif()",10000); //executes the next data query in 4 seconds
var xmlhttp1=false; //Clear our fetching variable
try {
xmlhttp1 = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
} catch (e) {
try {
xmlhttp1 = new
ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
} catch (E) {
xmlhttp1 = false;
}
}
if (!xmlhttp1 && typeof XMLHttpRequest!='undefined') {
xmlhttp1 = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
}
var file1 = ''; //This is the path to the file we just finished making *
xmlhttp1.open('GET', file1, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
xmlhttp1.onreadystatechange=function() {
if (xmlhttp1.readyState==4) { //Check if it is ready to recieve data
var content1 = xmlhttp1.responseText; //The content data which has been retrieved ***
if( content1 ){ //Make sure there is something in the content variable
document.getElementById('blah').innerHTML = content1; //Change the inner content of your div to the newly retrieved content ****
}
}
}
xmlhttp1.send(null) //Nullify the XMLHttpRequest
return;
}