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

@ -310,9 +310,15 @@ Class('Pad', {
});
},
init : function (callback)
init : function (text, callback)
{
var _this = this;
//replace text with default text if text isn't set
if(text == null)
{
text = settings.defaultPadText;
}
//try to load the pad
db.get("pad:"+this.id, function(err, value)
@ -338,7 +344,7 @@ Class('Pad', {
//this pad doesn't exist, so create it
else
{
var firstChangeset = Changeset.makeSplice("\n", 0, 0, exports.cleanText(settings.defaultPadText));
var firstChangeset = Changeset.makeSplice("\n", 0, 0, exports.cleanText(text));
_this.appendRevision(firstChangeset, '');
}