added getRevisionsCount

pull/85/merge
Peter 'Pita' Martischka 2011-08-04 17:24:36 +01:00
parent d5d9830dd3
commit 7b030710d2
2 changed files with 63 additions and 45 deletions

View File

@ -360,13 +360,17 @@ Example returns:
*/ */
exports.getRevisionsCount = function(padID, callback) exports.getRevisionsCount = function(padID, callback)
{ {
//check if this is a valid padID //get the pad
var notValidReason = isValidPadID(padID); getPadSafe(padID, function(err, pad)
if(notValidReason != null)
{ {
callback(notValidReason); if(err)
{
callback(err);
return; return;
} }
callback(null, {revisions: pad.getHeadRevisionNumber()});
});
} }
/** /**
@ -379,13 +383,17 @@ Example returns:
*/ */
exports.deletePad = function(padID, callback) exports.deletePad = function(padID, callback)
{ {
//check if this is a valid padID //get the pad
var notValidReason = isValidPadID(padID); getPadSafe(padID, function(err, pad)
if(notValidReason != null)
{ {
callback(notValidReason); if(err)
{
callback(err);
return; return;
} }
});
} }
/** /**
@ -398,13 +406,7 @@ Example returns:
*/ */
exports.getReadOnlyLink = function(padID, callback) exports.getReadOnlyLink = function(padID, callback)
{ {
//check if this is a valid padID
var notValidReason = isValidPadID(padID);
if(notValidReason != null)
{
callback(notValidReason);
return;
}
} }
/** /**
@ -417,13 +419,17 @@ Example returns:
*/ */
exports.setPublicStatus = function(padID, publicStatus, callback) exports.setPublicStatus = function(padID, publicStatus, callback)
{ {
//check if this is a valid padID //get the pad
var notValidReason = isValidPadID(padID); getPadSafe(padID, function(err, pad)
if(notValidReason != null)
{ {
callback(notValidReason); if(err)
{
callback(err);
return; return;
} }
});
} }
/** /**
@ -436,13 +442,17 @@ Example returns:
*/ */
exports.getPublicStatus = function(padID, callback) exports.getPublicStatus = function(padID, callback)
{ {
//check if this is a valid padID //get the pad
var notValidReason = isValidPadID(padID); getPadSafe(padID, function(err, pad)
if(notValidReason != null)
{ {
callback(notValidReason); if(err)
{
callback(err);
return; return;
} }
});
} }
/** /**
@ -455,13 +465,17 @@ Example returns:
*/ */
exports.setPassword = function(padID, password, callback) exports.setPassword = function(padID, password, callback)
{ {
//check if this is a valid padID //get the pad
var notValidReason = isValidPadID(padID); getPadSafe(padID, function(err, pad)
if(notValidReason != null)
{ {
callback(notValidReason); if(err)
{
callback(err);
return; return;
} }
});
} }
/** /**
@ -474,13 +488,17 @@ Example returns:
*/ */
exports.isPasswordProtected = function(padID, callback) exports.isPasswordProtected = function(padID, callback)
{ {
//check if this is a valid padID //get the pad
var notValidReason = isValidPadID(padID); getPadSafe(padID, function(err, pad)
if(notValidReason != null)
{ {
callback(notValidReason); if(err)
{
callback(err);
return; return;
} }
});
} }
/******************************/ /******************************/

View File

@ -50,8 +50,8 @@ var functions = {
// "deleteAllSessionsOfGroup" : ["groupID"], // "deleteAllSessionsOfGroup" : ["groupID"],
// "deleteAllSessionsOfAuthor" : ["authorID"], // "deleteAllSessionsOfAuthor" : ["authorID"],
"getText" : ["padID", "rev"], "getText" : ["padID", "rev"],
"setText" : ["padID", "text"] "setText" : ["padID", "text"],
// "getRevisionsCount" : ["padID"], "getRevisionsCount" : ["padID"],
// "deletePad" : ["padID"], // "deletePad" : ["padID"],
// "getReadOnlyLink" : ["padID"], // "getReadOnlyLink" : ["padID"],
// "setPublicStatus" : ["padID", "publicStatus"], // "setPublicStatus" : ["padID", "publicStatus"],