mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
diffHighlighter.js: Record the line index as attribute.
This commit is contained in:
@@ -98,7 +98,7 @@ var highlightDiff = function(diff, element, callbacks) {
|
|||||||
startname = "";
|
startname = "";
|
||||||
endname = "";
|
endname = "";
|
||||||
}
|
}
|
||||||
for (var lineno = 0; lineno < lines.length; lineno++) {
|
for (var lineno = 0, lindex = 0; lineno < lines.length; lineno++) {
|
||||||
var l = lines[lineno];
|
var l = lines[lineno];
|
||||||
|
|
||||||
var firstChar = l.charAt(0);
|
var firstChar = l.charAt(0);
|
||||||
@@ -186,6 +186,7 @@ var highlightDiff = function(diff, element, callbacks) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sindex = "index=" + lindex.toString() + " ";
|
||||||
if (firstChar == "+") {
|
if (firstChar == "+") {
|
||||||
// Highlight trailing whitespace
|
// Highlight trailing whitespace
|
||||||
if (m = l.match(/\s+$/))
|
if (m = l.match(/\s+$/))
|
||||||
@@ -193,11 +194,11 @@ var highlightDiff = function(diff, element, callbacks) {
|
|||||||
|
|
||||||
line1 += "\n";
|
line1 += "\n";
|
||||||
line2 += ++hunk_start_line_2 + "\n";
|
line2 += ++hunk_start_line_2 + "\n";
|
||||||
diffContent += "<div class='addline'>" + l + "</div>";
|
diffContent += "<div " + sindex + "class='addline'>" + l + "</div>";
|
||||||
} else if (firstChar == "-") {
|
} else if (firstChar == "-") {
|
||||||
line1 += ++hunk_start_line_1 + "\n";
|
line1 += ++hunk_start_line_1 + "\n";
|
||||||
line2 += "\n";
|
line2 += "\n";
|
||||||
diffContent += "<div class='delline'>" + l + "</div>";
|
diffContent += "<div " + sindex + "class='delline'>" + l + "</div>";
|
||||||
} else if (firstChar == "@") {
|
} else if (firstChar == "@") {
|
||||||
if (header) {
|
if (header) {
|
||||||
header = false;
|
header = false;
|
||||||
@@ -210,12 +211,13 @@ var highlightDiff = function(diff, element, callbacks) {
|
|||||||
}
|
}
|
||||||
line1 += "...\n";
|
line1 += "...\n";
|
||||||
line2 += "...\n";
|
line2 += "...\n";
|
||||||
diffContent += "<div class='hunkheader'>" + l + "</div>";
|
diffContent += "<div " + sindex + "class='hunkheader'>" + l + "</div>";
|
||||||
} else if (firstChar == " ") {
|
} else if (firstChar == " ") {
|
||||||
line1 += ++hunk_start_line_1 + "\n";
|
line1 += ++hunk_start_line_1 + "\n";
|
||||||
line2 += ++hunk_start_line_2 + "\n";
|
line2 += ++hunk_start_line_2 + "\n";
|
||||||
diffContent += "<div class='noopline'>" + l + "</div>";
|
diffContent += "<div " + sindex + "class='noopline'>" + l + "</div>";
|
||||||
}
|
}
|
||||||
|
lindex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
finishContent();
|
finishContent();
|
||||||
@@ -227,3 +229,4 @@ var highlightDiff = function(diff, element, callbacks) {
|
|||||||
if (false)
|
if (false)
|
||||||
Controller.log_("Total time:" + (new Date().getTime() - start));
|
Controller.log_("Total time:" + (new Date().getTime() - start));
|
||||||
}
|
}
|
||||||
|
diffContent += "<div " + sindex + "class='addline'>" + l + "</div>";
|
||||||
|
|||||||
Reference in New Issue
Block a user