function shownhide(showit,hideit){
showobj = document.getElementById(showit);
hideobj = document.getElementById(hideit);
showobj.style.display='';
hideobj.style.display='none';
}
function showchat(){
showobj = document.getElementById('chatmax');
hideobj = document.getElementById('chatmin');
showobj.style.width="50em";
showobj.style.display='';
hideobj.style.display='none';
setCookie('chatshow','1',30);
}
function hidechat(){
showobj = document.getElementById('chatmin');
hideobj = document.getElementById('chatmax');
showobj.style.display='';
hideobj.style.display='none';
hideobj.style.width="10em";
setCookie('chatshow','0',30);
}
/****************************************************************
* Most Simple Ajax Chat Script (www.linuxuser.at) *
* Version: 3.1 *
* *
* Author: Chris (chris[at]linuxuser.at) *
* Contributors: Derek, BlueScreenJunky (http://forums.linuxuser.at/viewtopic.php?f=6&t=17)
* *
* Licence: GPLv2 *
****************************************************************/
/* Settings you might want to define */
var waittime=1800;
/* Internal Variables & Stuff */
//chatmsg.focus()
//document.getElementById("chatwindow").innerHTML = "loading...";
var xmlhttp = false;
var xmlhttp2 = false;
var nick = "38.107.191.113";
var chatpath = "/";
var chatfile = chatpath+'chat.txt';
/* Request for Reading the Chat Content */
function ajax_read(url) {
if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
if(xmlhttp.overrideMimeType){
xmlhttp.overrideMimeType('text/xml');
}
} else if(window.ActiveXObject){
try{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
} catch(e){
}
}
}
if(!xmlhttp) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState==4) {
var chattxt = xmlhttp.responseText;
chattxt = chattxt.replace(/\t/g, " | ");
chattxt = chattxt.replace(/\n/g, "
\n");
document.getElementById("chatwindow").innerHTML = chattxt.replace(/\t/g, " | ")
zeit = new Date();
ms = (zeit.getHours() * 24 * 60 * 1000) + (zeit.getMinutes() * 60 * 1000) + (zeit.getSeconds() * 1000) + zeit.getMilliseconds();
intUpdate = setTimeout("ajax_read(chatfile+'?x=" + ms + "')", waittime)
}
}
xmlhttp.open('GET',url,true);
xmlhttp.send(null);
}
/* Request for Writing the Message */
function ajax_write(url){
if(window.XMLHttpRequest){
xmlhttp2=new XMLHttpRequest();
if(xmlhttp2.overrideMimeType){
xmlhttp2.overrideMimeType('text/xml');
}
} else if(window.ActiveXObject){
try{
xmlhttp2=new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try{
xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
} catch(e){
}
}
}
if(!xmlhttp2) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
xmlhttp2.open('GET',url,true);
xmlhttp2.send(null);
}
/* Submit the Message */
function submit_msg(){
msg = document.getElementById("chatmsg").value;
if (nick == "") {
check = prompt("please enter username:");
if (check === null) return 0;
if (check == "") check = "anonymous";
document.getElementById("chatnick").value = check;
nick = check;
}
document.getElementById("chatmsg").value = "";
ajax_write(chatpath+"chat.php?m=" + msg + "&n=" + nick);
}
/* Check if Enter is pressed */
function keyup(arg1) {
if (arg1 == 13) submit_msg();
}
/**** cookie functions ****/
function setCookie(c_name,value,expiredays){
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function getCookie(c_name){
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}
function addchat(target){
var show = getCookie('chatshow');
//alert("loading chat - cookie is " + show);
if(show == 1){
var cmin = "none"
var cmax = "";
} else {
var cmin = ""
var cmax = "none";
}
var myElement = document.createElement('div');
myElement.style.position="fixed";
myElement.style.bottom="10px";
myElement.style.right="10px";
myElement.style.zIndex="100";
myElement.style.border="thin solid black";
myElement.style.backgroundColor="white";
myElement.style.padding="5px";
myElement.id="chatwrap";
//myElement.innerHTML = '