and semi working

This commit is contained in:
John McLear 2013-01-22 23:37:53 +00:00
parent 3fb2f02875
commit f1b9c213ee
3 changed files with 47 additions and 3 deletions

View File

@ -213,6 +213,47 @@ Pad.prototype.getInternalRevisionAText = function getInternalRevisionAText(targe
});
};
Pad.prototype.getRevision = function getRevisionChangeset(revNum, callback) {
db.get("pad:"+this.id+":revs:"+revNum, callback);
};
Pad.prototype.getAllAuthorColors = function getAllAuthorColors(callback){
var authors = this.getAllAuthors();
var returnTable = {};
var colorPalette = authorManager.getColorPalette();
async.forEach(authors, function(author, callback){
authorManager.getAuthorColorId(author, function(err, colorId){
if(err){
return callback(err);
}
returnTable[author]=colorPalette[colorId];
callback();
});
}, function(err){
callback(err, returnTable);
});
};
Pad.prototype.getValidRevisionRange = function getValidRevisionRange(startRev, endRev) {
startRev = parseInt(startRev, 10);
var head = this.getHeadRevisionNumber();
endRev = endRev ? parseInt(endRev, 10) : head;
if(isNaN(startRev) || startRev < 0 || startRev > head) {
startRev = null;
}
if(isNaN(endRev) || endRev < startRev) {
endRev = null;
} else if(endRev > head) {
endRev = head;
}
if(startRev !== null && endRev !== null) {
return { startRev: startRev , endRev: endRev }
}
return null;
};
Pad.prototype.getKeyRevisionNumber = function getKeyRevisionNumber(revNum) {
return Math.floor(revNum / 100) * 100;
};

View File

@ -92,7 +92,7 @@ function getPadHTML(pad, revNum, callback)
exports.getPadHTML = getPadHTML;
function getHTMLFromAtext(pad, atext)
exports.getHTMLFromAtext = function(pad, atext)
{
var apool = pad.apool();
var textLines = atext.text.slice(0, -1).split('\n');

View File

@ -244,14 +244,17 @@ PadDiff.prototype.getHtml = function(callback){
},
//get the authorColor table
function(callback){
self._pad.getAllAuthorColors(function(err, _authorColors){
/*
self._pad.getAllAuthorColors(function(err, _authorColors){ // TODO
if(err){
return callback(err);
}
authorColors = _authorColors;
callback();
});
*/
authorColors = {};
callback();
},
//convert the atext to html
function(callback){