added createPad

This commit is contained in:
Peter 'Pita' Martischka 2011-08-04 19:20:14 +01:00
parent 8dabdc8e95
commit 9fa52c0e66
4 changed files with 102 additions and 32 deletions

View file

@ -31,11 +31,18 @@ globalPads = [];
* @param id A String with the id of the pad
* @param {Function} callback
*/
exports.getPad = function(id, callback)
exports.getPad = function(id, text, callback)
{
if(!exports.isValidPadId(id))
throw new Error(id + " is not a valid padId");
//make text an optional parameter
if(typeof text == "function")
{
callback = text;
text = null;
}
var pad = globalPads[id];
//return pad if its already loaded
@ -49,7 +56,7 @@ exports.getPad = function(id, callback)
pad = new Pad(id);
//initalize the pad
pad.init(function(err)
pad.init(text, function(err)
{
if(err)
{