PDA

View Full Version : shoutbox...



Maikeru-
18th July 2006, 04:14 AM
<center>
<div class='tableborder'><div class="maintitle">Shoutbox</div><div id="shoutdiv" style="width:100%; height:100px; overflow:auto; border:0px"><b><center>Please Enable JavaScript to view the ShoutBox.</b></center></div><div class="titlemedium"><div id="shoutlinkarea"></div><br /><form name="shoutform" style="display:none" onSubmit="SetShout(document.shoutform.shouter.value)" action="JavaScript:void(0)"><b>Shout Here:</b><input class="forminput" type="text" name="shouter"><input type="submit" class="forminput" value="Shout!"><br /></form></div></div>
<script>
/* IF Internal ShoutBox Code v2.0
By IceMetalPunk */
function Request() {
if (window.XMLHttpRequest ) { return new XMLHttpRequest(); }
else if (window.ActiveXObject) {
try {
return new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
return false;
}
}
}
}
function Subscribe(themall) {
req=Request();
url=main+"/index.php?act=Track&f="+f2;
if (themall==1) { whichone="this room."; url+="&t="+t2; }
else { url+="&type=forum"; whichone="the entire shoutbox."; }
req.open("GET",url);

req.onreadystatechange=function() {
if (req.readyState==4) {
txt=req.responseText;
if (txt.match(/already subscribed/i)!=null) {
alert("You are already tracking "+whichone);
}
else { alert("Shoutbox tracker set for "+whichone); }
}
}
req.send(null);
}
function GetShouts() {
flood=5;
document.shoutform.style.display="";
main=document.location.href.split("/index.php")[0];
if (main.charAt(main.length-1)=="/") { main=main.substring(0,main.length-1); }
div=document.all?document.all.shoutdiv:document.ge tElementById("shoutdiv");
req2=Request();
req2.open("GET",main+"/index.php?act=Post&CODE=02&f="+f2+"&t="+t2);
req2.onreadystatechange=function() {
if (req2.readyState==4) {
txt=req2.responseText;
if (txt.match(/<div class="tableborder">[\s\S]*?<div class="pformstrip">Last 10 Posts \[ In reverse order \]<\/div>([\s\S]*)<\/div>/ig)!=null) {
temp=RegExp.$1;
temp.match(/(<table.*?>[\s\S]*<\/table>)/ig);
temp=RegExp.$1;
temp=temp.replace(/(<td class=["']row4["'] valign=["']top["'] width=["']20%["']>.*?)<\/td>/ig,"$1");
temp=temp.replace(/<td class=["']row4["'] valign=["']top["'] width=["']80%["']>.*?(on[\s][\s\S]*?)<tr>[\s\S]*?<\/td>/ig,"<small>Shouted $1</small>");
temp=temp.replace(/<td/ig,"<td height='25px'").replace(/<tr/ig,"<tr height='25px'").replace(/<br(?: \/)?>/ig," ");
temp=temp.replace(/:\)/ig,"<img src='http://209.85.12.227/html/emoticons/smile.gif'>").replace(/;\)/ig,"<img src='http://209.85.12.227/html/emoticons/wink.gif'>").replace(/:lol\:/ig,"<img src='http://209.85.12.227/html/emoticons/laugh.gif'>");
div.innerHTML="<div class='tableborder'>"+temp+"</div>";
tout=setTimeout("GetShouts()",flood*1000);
}
else {
if (txt.match(/(Flood[\s]control is enabled.*?wait.*?second(?:s)?)/ig)!=null) {
div.innerHTML="<center><b>"+RegExp.$1+" before shouting again.</b></center>";
}
else if (txt.match(/You[\s]do not have permission/ig)!=null) {
div.innerHTML="<center><b>Please log in to view the ShoutBox.</b></center>";
document.shoutform.style.display='none';
}
else {
div.innerHTML="<center><b>No Shouts Found</b></center>";
}
}
}
}
req2.send(null);
}
function GetAuth() {
req=Request();
req.open("GET",main+"/index.php?act=Post&CODE=02&f="+f2+"&t="+t2);
req.onreadystatechange=function() {
if (req.readyState==4) {
txt=req.responseText;
txt.match(/<input type=['"]hidden['"] name=["']auth_key["'] value=["']([0-9a-z]+)['"].*?>/ig);
auth=RegExp.$1;
DoShout();
}
}
req.send(null);
}
function SetShout(post) {
if (post.replace(/\s/ig,"")=="") { alert("You must first enter a shout!"); }
else {
if (window.tout) { clearTimeout(tout); }
post2=post;
document.shoutform.shouter.value="Please Wait...";
document.shoutform.shouter.disabled=true;
GetAuth();
}
}
function ChangeRoom(num) {
linksarea=document.all?document.all.shoutlinkarea: document.getElementById("shoutlinkarea");
t2=num;
linksarea.innerHTML=linksarea.innerHTML.replace(/<!--Start Room List-->.*?<!--End Room List-->/ig,"");
SetRoomLinks(num);
GetShouts();
}
function DoShout() {
req=Request();
req.open("POST",main+"/index.php");
req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
req.onreadystatechange=function() {if (req.readyState==4) { document.shoutform.shouter.value=""; document.shoutform.shouter.disabled=false; GetShouts(); }}
req.send("act=Post&CODE=03&f="+f2+"&t="+t2+"&auth_key="+auth+"&Post="+escape(post2));
}
function SetRoomLinks(num) {
linksarea.innerHTML+="<!--Start Room List--><b>";
for (p=0; p<rooms.length; p++) {
if (rooms[p][1]==num) {
linksarea.innerHTML+=rooms[p][0];
}
else {
linksarea.innerHTML+="<a href='JavaScript:ChangeRoom("+rooms[p][1]+"); void(0)'>"+rooms[p][0]+"</a>";
}
if (p!=rooms.length-1) { linksarea.innerHTML+=" | "; }
}
linksarea.innerHTML+="<br /><small><a href='JavaScript:Subscribe(1)'>Track Shouts In The Current Room</a> | <a href='JavaScript:Subscribe(0)'>Track Shouts In All Rooms</a></small>";
linksarea.innerHTML+="<!--End Room List-->";
setTimeout("GetShouts()",100);
}
rooms=[];

f2=18;

rooms[rooms.length]=["Shoutbox",30];

ChangeRoom(rooms[0][1]);
</script></center>


whats wrong?

Tavix
19th July 2006, 08:52 PM
what type of forum are you trying to attach the shoutbox to?

Phyrus
22nd July 2006, 04:48 AM
what problem(s) are you having exactly?

Maikeru-
23rd July 2006, 04:31 PM
nevermind i got it sorted you can close :)