My favorites | Sign in
Project Logo
                
Search
for
Updated Dec 25, 2006 by KrocCamen
Labels: Featured, Phase-Deploy
jaxAPI  
API for using jax.js

jax.js is a javascript class that you can use to send small bits of data between two people on different computers. Jax Games is a set of turn-based two player games written in HTML/Javascript using Jax.

At the moment Jax relies upon Prototype & Prototype-compatible json.js. Prototype is quite large, so if your site is not using Prototype, it can be an added burden. It is still early for Jax, and it may be improved in the future to work without Prototype, and use your own choice of AJAX module (such as SACK)

This document explains Jax's programming interface so that you can utilize the script yourself, in your own projects.

key

1. Jax

Jax itself is just a single class that manages the AJAX calls to the server. It uses Prototype to provide a constructor, you can (optionally) provide the URL to Jax's response.php page, relative to the HTMl/PHP page that the user is viewing. The default value is "server/response.php" assuming that your page is on webroot, and response.php is in a folder named server, as is provided by default with Jax.

parameters

Example:

var jax = new Jax ();                          //use the default URL (server/response.php)
var jax = new Jax ("../server/response.php");  //use a different URL to response.php

1.1 version

Version number of Jax. presented as "major.minor.revision.build.tag". Major and minor are as normal version numbers, e.g. '1.3', the revision is a security/bug release (e.g. '1.3.1'), build is the four digit build number, incremented at each new build and does not reset and finally the tag is for 'alpha', 'beta' or 'rc' status tags (always all lowercase please). Split the string by "." to extract each piece.

Example:

var jax = new Jax ();
alert (jax.version);

1.2 conn_id

'Connection ID'. See open below. When you open a new person-to-person connection you're given a Connection ID that the other user needs to join the connection. Connection ID's are six letters long, 0-9, A-Z. e.g. M5CIVK

How you get the Connection ID to the other user is up to you. Jax Games puts the code on screen, and expects the user to IM/e-mail/FedEx the code to the other person. You could get the other person to query the server for new connections started and give them the join key that way, but this is up to you to decide.

1.3 open

The person hosting starts a new connection with this function.

parameters

1.4 connect

1.5 timerStart

1.6 timerStop

1.7 listenFor

1.8 sendRequest

1.9 sendToQueue

1.10 disconnect


Sign in to add a comment
Hosted by Google Code