2015-10-19 11:47:49 +00:00
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* FileListPrinter (file-list-printer.js)
|
|
|
|
|
* Author: nmatpt
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
(function (ctx, undefined) {
|
|
|
|
|
|
|
|
|
|
var printerUtils = require('./printer-utils.js').PrinterUtils;
|
|
|
|
|
var utils = require('./utils.js').Utils;
|
|
|
|
|
|
|
|
|
|
function FileListPrinter() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FileListPrinter.prototype.generateFileList = function (diffFiles) {
|
2015-10-19 14:43:16 +00:00
|
|
|
var hideId = utils.getRandomId("d2h-hide"); //necessary if there are 2 elements like this in the same page
|
2015-10-19 11:47:49 +00:00
|
|
|
var showId = utils.getRandomId("d2h-show");
|
|
|
|
|
return '<div class="d2h-file-list-wrapper">\n' +
|
|
|
|
|
' <div class="d2h-file-list-header">Files changed (' + diffFiles.length + ')  </div>\n' +
|
|
|
|
|
' <a id="' + hideId + '" class="d2h-hide" href="#' + hideId + '">+</a>\n' +
|
|
|
|
|
' <a id="' + showId + 'd2h-show" class="d2h-show" href="#' + showId + '">-</a>\n' +
|
|
|
|
|
' <div class="d2h-clear"></div>\n' +
|
2015-10-28 17:43:06 +00:00
|
|
|
' <table class="d2h-file-list">\n' +
|
2015-10-19 11:47:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
diffFiles.map(function (file) {
|
2015-10-28 17:43:06 +00:00
|
|
|
return ' <tr class="d2h-file-list-line">\n' +
|
|
|
|
|
' <td class="d2h-lines-added">\n' +
|
|
|
|
|
' <span>+' + file.addedLines + '</span>\n' +
|
|
|
|
|
' </td>\n' +
|
|
|
|
|
' <td class="d2h-lines-deleted">\n' +
|
|
|
|
|
' <span>-' + file.deletedLines + '</span>\n' +
|
|
|
|
|
' </td>\n' +
|
|
|
|
|
' <td class="d2h-file-name"><a href="#' + printerUtils.getHtmlId(file) + '"> ' + printerUtils.getDiffName(file) + '</a></td>\n' +
|
|
|
|
|
' </tr>\n'
|
2015-10-19 11:47:49 +00:00
|
|
|
}).join('\n') +
|
2015-10-28 17:43:06 +00:00
|
|
|
'</table></div>\n';
|
2015-10-19 11:47:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports['FileListPrinter'] = new FileListPrinter();
|
|
|
|
|
|
|
|
|
|
})(this);
|