The Node.js API

You will find here the detailed API of the Atlas toolkit for Node.js. The API overview contains also useful information about the API.

The optional callback parameter is called once the corresponding function is executed. Unless specified, it takes no parameters.

Once installed, the Atlas toolkit is accessible through a require('atlastk').

Functions

launch

launch(callback,action[,type])

Launches the server, with callback being called for each new session. This callback must return an instantiation of the DOM class (see below), or a subclass of it.

action (string) is one of the tag registered with below register(...) function, whose callback will be called for each new connection.

type, if given, must be types.DESKTOP to launch the desktop interface (default one), or types.WEB to launch the web one.

register

register(tagsAndCallbacks)

Register for each event tag (data-xdh-onevent(s)) the callback to be called. tagsAndCallbacks must have following form:

{
    'tag1': callback1,
    'tag2': callback2,
    'tag3': callback3,
    ...
}

tagx are the event tag as defined in data-xdh-onevent(s) HTML tags, and callbackx, callbacks which receive as first parameter the object returned by the callback given to the listen function, and, as second parameter, the id of the element which receives the event.

Tree object

Tree constructor

It takes no parameter.

popTag

popTag()

Closes the tag previously opened by pushTag(...), and the parent one becomes the current one.

pushTag

pushTag(name);

Create a new tag of name name (a string) as child of the current one, and becomes the current one.

putAttribute

putAttribute(name,value);

Add attribute of name name and value value (both being strings) to the current tag.

putValue

putValue(name);

Set the string value as value for the current tag.

DOM object

The object containing data for each users' session, and with method to manipulate the DOM displayed by the web browser.

All methods with a parameter callback are called asynchronously, and callback is called once the method is achieved, with no parameter unless specified otherwise.

Global

DOM constructor

Takes no parameter.

alert

alert(message[,callback])

Displays an alert box with the string message as message.

confirm

confirm(message[,callback])

Displays a confirmation box with the string message as message. Optional callback is called with a boolean parameter set to true when the user clicks the OK button, and false when the user clicks the cancel button.

focus

focus(id[,callback])

Gives the focus to element of id id (string).

Attribute

getAttribute

getAttribute(id,name[,callback])

Calls optional callback callback with, as parameter, a string with the value of attribute named name (string) of the element of id id (string).

removeAttribute

removeAttribute(id,name[,callback])

Removes attribute named name (string) from element of id id (string).

setAttribute

setAttribute(id,name,value[,callback])

Set value as value (string) for the attribute named name (string) of the element of id id (string).

Class

Following methods allows to handle classes (the CSS related class attributes of HTML tags), by respectively add, remove or toggle (i.e. adds if not present, otherwise removes) a class to elements identified by their ids (the content of the id attribute from HTML tags).

idsAndClasses must have following form:

{
    'id1': 'class1',
    'id2': 'class2',
    'id3': 'class3',
    ...
}

addClass

addClass(id,class[,callback])

addClasses

addClasses(idsAndClasses[,callback])

removeClass

removeClass(id,class[,callback])

removeClasses

removeClasses(idsAndClasses[,callback])

toggleClass

toggleClass(id,class[,callback])

toggleClasses

toggleClasses(idsAndClasses[,callback])

Content

getContent

getContent(id[,callback])

Retrieve the content of the element of id id (string) and calls optional callback callback with, as parameter, the asked content(as string).

getContents

getContents(ids[,callback])

Retrieves the content of the elements of ids ids (array of strings) and calls optional callback callback with, as parameter, an array of strings containing the asked contents, in the same order as ids.

setContent

setContent(id,value[,callback])

Set the content of element of id id (string) to value (string).

setContents

setContents(idsAndValues[,callback])

Set the content all element which id are in idsAndValues to corresponding value.

idsAndValues must have following form:

{
    'id1': 'value1',
    'id2': 'value2',
    'id3': 'value3',
    ...
}

idx is the id as set as value for the id attribute of the concerned HTML tag, and valuex the string corresponding to the content.

Element

enableElement

enableElement(id[,callback])

Enable element of id id.

enableElements

enableElements(ids[,callback])

Enable element of ids ids (array of strings).

disableElement

disableElement(id[,callback])

Disable element of if id.

disableElements

disableElements(ids[,callback])

Disable element of ids ids (array of strings).

Layout

setLayout

setLayout(id,tree,xslFilename[,callback])

Replaces the content of element with string id as id with the result of the transformation of the XSL file with name xslFilename (string) applied to the tree instance of a Tree class (see above).

If id is an empty string, the content of the entire document is replaced by the resulting transformation.

Property

getProperty

getProperty(id,name[,callback])

Calls optional callback callback with, as parameter, a string with the value of property named name (string) of the element of id id (string).

setProperty

setProperty(id,name,value[,callback])

Set value as value (string) for the property named name (string) of the element of id id (string).

Widget

dressWidgets

dressWidgets(id[,callback])

Create the widget for each elements which are children of the element of id id (string) and which have a data-xdh-widget attribute.