WPCAPI.generateCellID |

Version 9 - view current page


String generateCellID()
This method is overloadable and should not be called directly.

This method generates an identifier for a new cell. By default, a new cell ID is requested from Wetpaint. You should overload this method if you wish to generate and manage your own cell IDs.

Parameters
StringparentIDThe identifier for the newly generated cell's parent cell.Required
StringtitleThe title of the newly generated cell.Required
String []tagsThe keyword tags for the newly generated cell.Defaults to []
Returns a unique identifier for the newly generated cell.

Usage


Synchronous
if( window.WPCAPI ) {
WPCAPI.generateCellID = function( parentID, title, tags ) {
var id = location.href;
id = id.split('/').pop();
id += '/';
id += encodeURIComponent(title);
return id;
};
}

Asynchronous
if( window.WPCAPI ) {
WPCAPI.generateCellID = function( parentID, title, tags ) {

var params = '?'
+ "parentID=" + encodeURIComponent(parentID)
+ "&title=" + encodeURIComponent(title)
+ "&tags=" + encodeURIComponent(tags);

var request = new XMLHttpRequest();
request.open( "GET","/path/to/addPage/action" + params );
request.onreadystatechange = function() {
if( request.readyState == 4 ) {
var response = request.responseXML; // Format: <cell id="..."/>
var id = response ? response.getAttribute("id") : null;
WPCAPI.generateCellID_Callback(id);
}
};
request.send(null);

return null;

};

}