WPCAPI.generateCellIDThis is a featured page


String generateCellID()
This method is overridable 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 override 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;

};

}




superwomyn
superwomyn
Latest page update: made by superwomyn , Oct 29 2008, 2:05 PM EDT (about this update About This Update superwomyn Changing overload to override. - superwomyn

2 words added
2 words deleted

view changes

- complete history)
More Info: links to this page
Started By Thread Subject Replies Last Post
cpatni url encoding of generated id 1 Jun 2 2008, 12:15 PM EDT by ryan_wetpaint
Thread started: Jun 1 2008, 10:01 PM EDT  Watch
Is this method is required to return url safe ids ? For example if the id is "foo bar", should it return "foo bar" or "foo+bar"?
Do you find this valuable?    
Show Last Reply
Showing 1 of 1 threads for this page

Related Content

  (what's this?Related ContentThanks to keyword tags, links to related pages and threads are added to the bottom of your pages. Up to 15 links are shown, determined by matching tags and by how recently the content was updated; keeping the most current at the top. Share your feedback on Wetpaint Central.)