added the listPads and createGroupPad

This commit is contained in:
Peter 'Pita' Martischka 2011-08-08 17:35:40 +01:00
parent 8d28fcbf23
commit 4670cbc60a
4 changed files with 128 additions and 49 deletions

View file

@ -33,8 +33,12 @@ globalPads = [];
*/
exports.getPad = function(id, text, callback)
{
//check if this is a valid padId
if(!exports.isValidPadId(id))
throw new Error(id + " is not a valid padId");
{
callback({stop: id + " is not a valid padId"});
return;
}
//make text an optional parameter
if(typeof text == "function")
@ -43,6 +47,24 @@ exports.getPad = function(id, text, callback)
text = null;
}
//check if this is a valid text
if(text != null)
{
//check if text is a string
if(typeof text != "string")
{
callback({stop: "text is not a string"});
return;
}
//check if text is less than 100k chars
if(text.length > 100000)
{
callback({stop: "text must be less than 100k chars"});
return;
}
}
var pad = globalPads[id];
//return pad if its already loaded