Current Version: 0.35
Last Updated: 4/3/2003 21:25 server time

Hello, and welcome to the Notelet Nodelet Chatterbox Client. This project's goal is to provide a button in your notelet nodelet that will allow you access to a dynamic chatterbox that refreshes every 30 seconds.

How is this different from other chatterbox clients? - Because you are calling it from the everything2 site, there are no user authentication issues. Of course, right now you can't submit messages, but once that is functional it will not require you to go to an untrusted third party.

What do I need to run this? - The current version is functioning in IE 5.5 and above. I have run some basic tests using Phoenix 0.4 and Mozilla 1.2, but those are not supported in this release.

For you IE users: This calls an ActiveX component to do the parsing. You may need to download the MSXML SDK at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/htm/sdk_intro_6g53.asp. Mozilla has the parsing built in natively, so it won't need anything special at all.

How do I get this working?! - Because of the limited amount of space in the notelet nodelet, especially for lower level noders, I suggest copying the code into a .js file and hosting it somewhere you trust, then importing that. You are more than welcome to use the script below as is, I will try hard not to change the .js file I am hosting without testing it first.

I can't get it to work! - Please remember that this is Alpha quality code. If it doesn't work for you please /msg me with your browser (IE), version (5.5) and platform (Windows 98, Mac) and I will do my best to find out what is going on.

The notelet nodelet code:


<script language="javascript" src="http://www.cornetdesign.com/chatterbox.js">
</script>
<form><input type="button" value="Chatterbox" 
onClick="javascript:callChatterbox()"><form>


(Note: you may have to remove the line breaks from the above code)

The .js code

This code takes advantage of the capabilities of newer browsers to parse the DOM of XML structures. By hitting the Universal Message XML Ticker, then parsing that, we get the messages. It also helps reduce server load. Yea!

This is an early release of the code, so it may change. However, the latest "stable code" (we are talking Javascript here) will be available in a .js file at http://www.cornetdesign.com/chatterbox.js

If you have suggestions, concerns, complaints, etc, please /msg them to me. kThanx.

Things I know are missing - lessee, pipelinks, handling of /me, the fact that it is in a textarea box, ability to submit messages. Let me know if you have a feature or bug request not on this list.


Revision History:
0.35 - Combined the timer script and chatterbox to one window. Added start and close buttons.



//Global Window Handler
var vWin;

//temp browser switch. This needs to be 
//determined at run-time
ie = true;

function callChatterbox(){
	openWindow();
}

function init(){
	loadAndParseXML();
}

function loadAndParseXML(){
	var oResponseXML;
	
	oDoc = document;
	
	if(ie){
	//get the XML
	oResponseXML = loadXMLIE();
	
	
	//the start of the msglist is defined here
	msgListNode = oResponseXML.firstChild.nextSibling.firstChild.nextSibling.nextSibling;
	
	//clear out the textarea box
	oDoc.messages.msgs.value = "";
	
	while(msgListNode.hasChildNodes()){
		posterName = msgListNode.lastChild.firstChild.firstChild.firstChild.nodeValue;
		posterText = msgListNode.lastChild.firstChild.nextSibling.firstChild.nodeValue;
		oDoc.messages.msgs.value += posterName+" - "+posterText+"\n\n";
		msgListNode.removeChild(msgListNode.lastChild);
	}

	}else{
	alert("Moz!");
	}
	
	//Set this to refresh every 30 seconds
	window.setTimeout("loadAndParseXML()", "30000");
}


function loadXMLIE(){
	var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    xmlhttp.open("GET", "http://www.everything2.com/index.pl?" + 
		"node=Universal%20Message%20XML%20Ticker", false);
	xmlhttp.Send();
	oResponse = xmlhttp.responseXML;
    return oResponse;
}

function openWindow(){
	var winProps, winURL;
	
	winProps = "width=450,height=250,resizable=yes," + 
		"scrollbars=yes,menubar=yes,status=yes";
	vWin = open("", "", winProps);
	
	oDoc = vWin.document;
	
	//Set up the form
	oDoc.writeln("<h3>Chatterbox</h3>");
	oDoc.writeln("<form name=\"messages\">");
	oDoc.writeln("<textarea rows=\"10\" cols=\"45\" name=\"msgs\">");
	oDoc.writeln("Press start to begin");
	oDoc.writeln("</textarea><br><input type='button' value='start'" + 
               " onClick='javascript:init()'><input type='button' value='close'" + 
                " onClick='javascript:self.close()'></form>");
	oDoc.writeln("<script language='javascript' " + 
		"src='http:\/\/www.cornetdesign.com\/chatterbox_test.js'><\/script>");
	vWin.init();
	
	if(vWin.closed){
		return false;
	}else{
		return true;
	}
}

Log in or register to write something here or to contact authors.