/*
OmnomIRC COPYRIGHT 2010,2011 Netham45
This file is part of OmnomIRC.
OmnomIRC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OmnomIRC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OmnomIRC. If not, see .
*/
document.domain=HOSTNAME;
messageList = Array();
UserListArr = Array();
curLine = 0;
//messageBox = document.getElementById("MessageBox");
messageBox = document.createElement("table");
messageBox.style.width="100%";
messageBox.style.height="100%";
messageBox.className='MessageBox';
mBoxCont = document.getElementById("mboxCont");
Userlist = Array();
scrolledDown = true;
//******************************
// Start Request Loop functions*
//******************************
function startLoop()
{
xmlhttp=getAjaxObject();
if (xmlhttp==null) {
alert ("Your browser does not support AJAX! Please update for OmnomIRC compatibility.");
return;
}
xmlhttp.onreadystatechange=getIncomingLine;
sendRequest();
}
inRequest = false;
errorCount = 0;
function cancelRequest()
{
xmlhttp.abort();
inRequest = false;
}
function sendRequest()
{
if (inRequest)
return;
url = "Update.php?lineNum=" + curLine + "&channel=" + getChannelEn() + "&nick=" + base64.encode(userName) + "&signature=" + base64.encode(Signature);
xmlhttp.open("GET",url,true);
if (isBlurred()){
setTimeout("xmlhttp.send(null);",2500); //Only query every 2.5 seconds maximum if not foregrounded.
}
else
{
setTimeout("xmlhttp.send(null);",75); //Wait for everything to get parsed before requesting again.
}
inRequest = true;
}
function getIncomingLine()
{
if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete") {
inRequest = false;
if (xmlhttp.responseText == "Could not connect to SQL DB." || xmlhttp.status != 200)
{
errorCount++;
if (errorCount == 10)
{
OmnomIRC_Error("OmnomIRC has lost connection to server. Please refresh to reconnect.");
return;
}
else
{
sendRequest();
return;
}
}
if (xmlhttp.status == 200) addLines(xmlhttp.responseText); //Filter out 500s from timeouts
errorCount = 0;
sendRequest();
}
}
function getAjaxObject()
{
xmlhttp=new XMLHttpRequest(); //Decent Browsers
if (!xmlhttp || xmlhttp == undefined || xmlhttp == null) xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); //IE7+
if (!xmlhttp || xmlhttp == undefined || xmlhttp == null) xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); //IE6-
return xmlhttp;
}
//******************************
// End Request Loop functions *
//******************************
//******************************
// Start Parser *
//******************************
function addLines(message)
{
parts = message.split("\n");
for (var i=0;i 2)
{
addLine(parts[i]);
}
}
}
function addLine(message)
{
if (!message || message == null || message == undefined)
return;
lnNum = parseInt(message.split(":")[0]);
curLine = parseInt(curLine);
if (lnNum > curLine)
curLine = lnNum;
doScroll = false;
if (mBoxCont.clientHeight + mBoxCont.scrollTop > mBoxCont.scrollHeight - 50) doScroll = true;
//messageBox = document.getElementById("MessageBox");
/*
if ("\v" != "v") //If IE, take the slow but sure route (This is enough of a performance hit in all browsers to use the optimized code if possible. Also, IE can go fuck itself.)
mBoxCont.innerHTML = '