Adding adding adding
Welcome message, Time, /who and more
We have made a simple chat with a pop up, a prompt pop up, a form message, a whisper panel, and a /msg input.
We added a room change and we made it look a little nicer. Now we will add a "time and day"
pop up, an entry message that goes on the screen when you load the page, a "/who" which will tell you who is in the room, and we will make two message forms that will send a message but keep the text in the forms.
First we will put in our entry message. We will put this function at the very begining of the script because it will be the first function that is called. We will call the function with the onLoad event handler which goes in the body tag. here is the function definition which will go in the head container.(between the opening and closing head tags).
<script">
function entry( ) {
Chat.addChannelMessage("/msg *¥øü* Welcome to my new chat!!")
}
</script">
To call the function we will use the "onLoad" call, it goes in the body tag. Because the page will load before you connect to a server, we will need to put a delay on the message. We will do this with the "setTimeout()" method.
<body onLoad="timer=setTimeout('entry()',8000)">
The "8000" in there means that the message will be sent 8 seconds after the page loads. That is usually enough time. If the function is executed before you connect, you won't see the message, so give it plenty of time. When you put the onLoad call in, put it in after all the other attributes of the body tag (bgcolor=, text=, etc..).
Now we will make a simple function to show the time. We will use the "Date" object. We must create a new instance of the Date object by giving it a name. Then we can use that variable name in a function to get the date:
<script">
function time( ) {
var tell = new Date() {
Chat.addChannelMessage("the time is "+tell+" ")
}}
</script">
We will execute this function "onClick" of a button:
<form>
<input type="button" value="time" borderimage="file://rom/borders/buttonborder3.bif" usestyle onClick="time()">
</form>
The "/who" function is very simple:
<script">
function who( ) {
Chat.addChannelMessage("/who")
}
</script">
We will execute this function "onClick" of a button also:
<form>
<input type="button" value="who" borderimage="file://rom/borders/buttonborder3.bif" usestyle onClick="who()">
</form>
No we are ready for what I call, "no-dump" messages. These "message boxes" will keep the text in them so you can use them over and over. The functions and forms are much like all the rest of the form message functions except the fuction definitions have no statement in them instructing the script to dump the text after the message is sent. All we have to do is put the form and input id's inside the "addChannelMessage( ) method's parenthesis.:
<script language="JavaScript">
function C( ) {
Chat.addChannelMessage(document.g.h.value)
}
function D( ) {
Chat.addChannelMessage(document.i.j.value)
}
</script>
The forms that go with these functions are much like all the rest.
<table border=0 cellpadding=0 cellspacing=0><tr><td>
<form id="g" action="javascript:C( )">
<input id="h" type="text" value="" bgcolor=262626 cursor=white usestyle nohighlight width=275>
</form>
<td>
<form id="i" action="javascript:D( )">
<input id="j" type="text" bgcolor=262626 cursor=white usestyle nohighlight width=275>
</form>
</td></tr></table></form>
You could assign these form inputs a value so that there would always be a message in it, even when you load and reload the page. Just put it in the input value=""...
That is the entire thing. Now look at the improved chat
Now go to the next page we will add a few more extras
[ IRC list ] [ Server List ] [ First page ] [ page 2 ] [ page 3 ] [ page 4 ]
[ next page ]
T