update from nodejs cleanup

This commit is contained in:
Rodrigo Fernandes 2015-04-11 21:48:55 +01:00
parent e2725db461
commit 10b2c89a25
6 changed files with 396 additions and 424 deletions

View file

@ -2,8 +2,6 @@
*
* Diff to HTML (diff2html.css)
* Author: rtfpessoa
* Date: Friday 29 August 2014
* Last Update: Friday 30 January 2015
*
*/

View file

@ -2,18 +2,11 @@
*
* Diff to HTML (diff2html.js)
* Author: rtfpessoa
* Date: Friday 29 August 2014
* Last Update: Sunday 2 February 2015
*
* Diff command:
* Diff commands:
* git diff
*/
(function (window) {
var ClassVariable;
ClassVariable = (function () {
var LINE_TYPE = {
INSERTS: "d2h-ins",
DELETES: "d2h-del",
@ -420,30 +413,10 @@
function diffHighlight(diffLine1, diffLine2) {
/* remove the initial -/+ to avoid always having diff in the first char */
var highlightedLine = diffString(diffLine1.substr(1), diffLine2.substr(1));
var highlightedLine = JsDiff(diffLine1.substr(1), diffLine2.substr(1));
return {
o: diffLine1.charAt(0) + removeIns(highlightedLine),
n: diffLine2.charAt(0) + removeDel(highlightedLine)
}
}
/* singleton pattern */
var instance;
return {
getInstance: function () {
if (instance === undefined) {
instance = new Diff2Html();
/* Hide the constructor so the returned objected can't be new'd */
instance.constructor = null;
}
return instance;
}
};
})();
window.Diff2Html = ClassVariable.getInstance();
return window.Diff2Html;
})(window);

2
diff2html.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -181,7 +181,8 @@
'-});\n';
$(document).ready(function () {
var diffJson = Diff2Html.getJsonFromDiff(lineDiffExample);
var diff2Html = new Diff2Html();
var diffJson = diff2Html.getJsonFromDiff(lineDiffExample);
var languages = diffJson.map(function (line) {
return line.language;
@ -191,13 +192,13 @@
});
hljs.configure({languages: uniqueLanguages});
$("#line-by-line").html(Diff2Html.getPrettyHtmlFromJson(diffJson));
$("#line-by-line").html(diff2Html.getPrettyHtmlFromJson(diffJson));
var code = $(".d2h-code-line");
code.map(function (i, line) {
hljs.highlightBlock(line);
});
$("#side-by-side").html(Diff2Html.getPrettySideBySideHtmlFromJson(diffJson));
$("#side-by-side").html(diff2Html.getPrettySideBySideHtmlFromJson(diffJson));
var codeSide = $(".d2h-code-side-line");
codeSide.map(function (i, line) {
hljs.highlightBlock(line);

View file

@ -10,7 +10,7 @@
* http://ejohn.org/projects/javascript-diff-algorithm/
*/
function diffString(o, n) {
function JsDiff(o, n) {
o = o.replace(/\s+$/, '');
n = n.replace(/\s+$/, '');