Hi, if anyone can improve on this, I'd be very greatful.
It's an application for a live chat, where the messages are updated imidiatly, and where you can send messages inbetween users as well.
- Ideas anyone??
The first part is the clientside code, and the other is the server-file.
It's just one, and it's using ASP.
<pre>
<html>
<head>
<title>Live_chat v.1.0</title>
<script
id="register"
mode="chat"
template="<br><font style='color:black;border:solid black 2px;width:200;padding:3px;font-face:verdana;font-size:10pt;'><b>[TITLE]</b><br><span style='text-align:center;margin:1px;font-family:verdana;font-size:9px;cursor:hand;color:black;background-color:buttonhighlight;border:solid black 1px;width:70;font-size:9px;display:block' onclick='callUp()' visitor='[THE_ID]'>Send to..</span><br><span id='account'><span onclick='parent.viewTheCodeNow(this.parentElement.children(1).innerText)' style='text-align:center;margin:1px;border:black 1px solid;background-color:buttonhighlight;font-family:verdana;font-size:9px;cursor:hand;display:block;width:70'>Codeview</span><span>[POST]</span></span>< ;/font>";
src="http://www.naltabyte.se/rent_a_chat/files/mail.asp">
</script>
</head>
<body >
<center>
<table style="width:100%;height:100%;background-color:butt****ce;border utset 2px;z-index:8;padding:10">
<tr valign="top" style="width:100%;height:100%">
<td align="right" style="width:30%;height:100%">
<input type="text" id="title" style="background-color:white;border:solid butt****ce 1px;width:100%"><b>Name:</b><br />
<textarea id="post" style="background-color:white;border:solid butt****ce 1px;width:100%;height:70%"></textarea>
<br />
<button onclick="Call()" style="height:20;width:50;font-size:10">Post</button>
</td>
<td style="width:50%;height:100%;border-left:dotted butt****ce 1px">
<div id="printOut" style="position:relative;top:3;left:0;padding:15;background-color:white;width:100%;height:100%;overflow:scroll">
</div>
</td>
</tr>
<tr>
<td colspan="2" align="right" style="width:100%;height:100%">
</td>
</tr>
</table>
</center>
</body>
</html>
</pre>
And the server-part.
<pre>
<% @ LANGUAGE=JScript %>
<% Response.ContentType = "application/x-javascript .js" %>
<%
ForAppending=8;
ForWriting=2;
ForReading=1;
tribuned=new String(Request.Querystring);
tribuned=tribuned.split("<cut>");
if(!tribuned[1])
{
%>
reply="";
num="";
adress="liquid21";
document.write("<script id='call'><"+"/script>");
window.onload=signOn;
function thePackage()
{
str=document.all.register.template;
if(str=="0"){str="<br/><font style='color:black;border:solid black 2px;width:200;padding:3px;font-face:verdana;font-size:10pt;'><b>[TITLE]</b><br/><b style='cursor:hand;color:black;background-color:silver;border:solid red 1px;padding:2px;height:15;overflow:hidden;width:70;font-size:9px' onclick='callUp()' visitor='[THE_ID]'>Send to..</b><br/><br/>Post: <span id='account'>[POST]</span></font>";}
if(document.all.title){str=str.replace("[TITLE]",document.all.title.value);}
if(document.all.post){str=str.replace("[POST]",document.all.post.value);}
if(document.all.link_to){str=str.replace("[LINK_TO]",document.all.link_to.value);}
if(document.all.mail){str=str.replace("[MAIL_TO]",document.all.mail.value);}
str=str.replace("[THE_ID]",document.body.timestamp);
package=escape(str);
return package
}
function Call()
{
document.all.post.active="yes";
validate(document.all.post.value);
conn="http://www.naltabyte.se/rent_a_chat/files/mail.asp?the_mail_out<cut>";
num++;
thePackage();
act=adress+"<cut>"+package+"<cut> 'the_"+num+"'";
document.all.call.src=conn+act;
document.all.post.value="";
if(reply==""){return false;}
else
{
num++;
reply="";
setTimeout('CallOne(0)',2000);
}
}
function CallOne(addon)
{
conn="http://www.naltabyte.se/rent_a_chat/files/mail.asp?the_mail_in<cut>";
num++;
act=addon+"<cut>"+document.body.setTime+"<cut>"+document.all.post.value+"<cut>-<cut> 'the_"+num+"'";
call.src=conn+act;
if(reply==""){return false;}
else
{
num++;
reply="";
}
}
function signOn()
{
if(document.all.post){document.all.post.active="no";}
document.onkeypress=SetAt;
day=new Date();
day=day.toGMTString();
day=day.replace(/:/g,".");
if(!document.body.timestamp)
{
document.body.timestamp=day;
document.body.setTime="0";
setInterval('CallOne(0)',2000)
}
}
function SetAt(){if(document.all.post){document.all.post.active='no';}}
function validate(data)
{
ndata=document.all.post.value;
for(i=0;i < ndata.length;i++)
{
ndata=ndata.replace("<","<");
ndata=ndata.replace(">",">");
ndata=ndata.replace("(","acccc");
ndata=ndata.replace(")","cccca");
ndata=ndata.replace('"','"');
}
document.all.post.value=ndata;
}
function callUp()
{
document.body.setTime=event.srcElement.visitor;
CallOne('send');
document.all.post.active='yes';
}
<%
}
if(tribuned[0]=="the_mail_out"){finish();}
if(tribuned[0]=="the_mail_in"){startup();}
if(tribuned[1]=="send"){sender();}
function finish()
{
strFil="";
indata=" ";
Fsave=" ";
Fstore="";
fso=new ActiveXObject("Scripting.FileSystemObject");
if(fso.FileExists(Server.MapPath("liquid21")))
{
ofil=fso.OpenTextFile(Server.MapPath("liquid21"), ForReading, true);
while(!ofil.AtEndOfStream){strFil+=ofil.ReadLine();}
var x=unescape(strFil);
x=x.split("#");
for(i=0;i < 5;i++){if(!x[i]){break;}indata+=x[i]+"#";}
ofil.Close();
File=fso.OpenTextFile(Server.MapPath("liquid21"), ForWriting, true);
Fsave+=tribuned[2];
Fsave+="<span style='visibility:hidden'>#</span><br>";
File.WriteLine(unescape(Fsave));
File.Write(unescape(indata));
File.Close();
}
if(!fso.FileExists(Server.MapPath("liquid21")))
{
objFile=fso.CreateTextFile(Server.MapPath("liquid21"), true);
objFile.Write(" ")
objFile.Close();
}
%>
<%
}
function startup()
{
strFil="";
indata="";
fso=new ActiveXObject("Scripting.FileSystemObject");
if(fso.FileExists(Server.MapPath("liquid21")))
{
ofil=fso.OpenTextFile(Server.MapPath("liquid21"), ForReading, true);
while(!ofil.AtEndOfStream){strFil+=ofil.ReadLine();}
ofil.Close();
x=unescape(strFil);
x=x.split("#");
for(i=0;i < 6;i++){if(!x[i]){break;}indata+=x[i];}
str="";
fso=new ActiveXObject("Scripting.FileSystemObject");
ofile=fso.OpenTextFile(Server.MapPath("mail.txt"));
while(!ofile.AtEndOfStream) {str += ofile.ReadLine();}
ofile.Close();
%>
printoutdata="<% Response.Write(indata) %>";
printoutdata1=printoutdata.replace(/acccc/g, "(");
printoutdata1=printoutdata1.replace(/cccca/g, ")");
document.all.printOut.innerHTML=printoutdata1;
reply="Success";
recalling();
function recalling()
{
x="<% Response.Write(str) %>";
identity=x.split("<cut>");
if(identity[0]==document.body.timestamp && document.all.post.active=="yes")
{
document.all.post.value=identity[1];
}
}
<%
}
}
function sender()
{
objFSO=new ActiveXObject("Scripting.FileSystemObject");
objFile=objFSO.CreateTextFile(Server.MapPath("mail.txt"), true);
objFile.Write(unescape(tribuned[2])+"<cut>"+unescape(tribuned[3]))
objFile.Close();
}
%>
</pre>
(^-^)b