WebChat
-
-
- -
-
Software
----
----
iWeb Server
.Edit
Iosphere

Services
----
Web Development
WAP Development

Articles
----
Net Tips
In Perspective

Community
----

Forums

Resources
----

HTML Reference

General Interest
----

Updates
Links

Key:
LinkOff-site Link
EmailEmail Link
HintAdditional Information
DownloadDownload
Private AreaPrivate Area (requires login)
-
Home Home -> WebChat! -> Windows Client -> Help -> Scripting Printer Version - Hide navigation bars Printer Version

Scripting

Version 1.0 of WebChat, which is still under development, supports scripting using standard ECMAScript (JavaScript). This is the same language found in web browsers (the library used in WebChat is the JavaScript library from the Mozilla browser).

Using Scripts

WebChat looks for scripts in the "Scripts" folder, below the main WebChat install folder. If you just wish to use scripts that is all you need to do. If you add a new script, you must restart WebChat for it to be loaded (however, if you modify an existing script the changes will be picked up immediately).

Writing Scripts

WebChat executes a script as soon as it loads it - your initialisation code should be placed outside of any script functions. In the sample below, the initialisation code simply declares some variables for use later:

  // Begin initialisation code
  var room;
  // End initialisation code  

  function oncommand(strCommand, strParams)
  {
    // Code here would do something
    return false;
  }

There are then two things that you can do - respond to incoming server commands and respond to user commands (typed as /command parameters in the speech box).

Responding to Server Commands

If you include a function called oncommands (as above) it receives all incoming commands from the server. For example, if someone sets their status as away, then strCommand will be set to "AWAY" and strParams will be the name of the person followed by the reason they are away.

A script can also prevent commands from being processed any further. By returning the value true, (return true;) the script indicates that it has processed the command itself so it shouldn't be passed to the main program.

NOTE: Your function must contain the line return false; at the bottom - if it doesn't, it is assumed that your script has handled the command and it isn't passed to the main program.

Responsing to User Commands

If you include a function of the form:

  function userFunction(strParams)
  {
    // Code here would do something
    return false;
  }

It can be called by the user by typing /userFunction parameters in the speech box (in the same way as /away command).

 

-