Commits

Juha Kuitunen committed 3120dd4

a line of diff contents starts with +, - or space; others are headers or additional information

  • Participants
  • Parent commits 3ee1e39

Comments (0)

Files changed (1)

 	for (i=0; i<lines.length; i++) {
 		var lines_modified = lines[i].match(/@@[ \-\+\d,]+@@/);
 		if (lines_modified != null) {
-			colored += "<span style=\"background-color: #DEB887;\">" + lines_modified[0] + "</span>" + lines[i].substring(lines_modified[0].length) + "\n";
+			// range information (and optional section heading)
+			colored += "<span style=\"background-color: #DEB887;\">" + lines_modified[0] + "</span>" +
+				"<span style=\"background-color: #EED5B7;\">" + lines[i].substring(lines_modified[0].length) + "</span>\n";
 		} else if (lines[i].startsWith("+")) {
+			// added line
 			colored += "<span style=\"background-color: #CCFFCC;\">" + lines[i] + "</span>\n";
 		} else if (lines[i].startsWith("-")) {
+			// deleted line
 			colored += "<span style=\"background-color: #FFDDDD;\">" + lines[i] + "</span>\n";
-		} else if ( lines[i].startsWith("diff") ||
-					lines[i].startsWith("index") ||
-					lines[i].startsWith("new file mode") ||
-					lines[i].startsWith("Binary file") ) {
+		} else if (lines[i].startsWith(" ")) {
+			// nothing changed
+			colored += lines[i] + "\n";
+		} else {
+			// header information
 			colored += "<span style=\"color: #A0A0A0;\">" + lines[i] + "</span>\n";
-		} else {
-			colored += lines[i] + "\n";
 		}
 	}
 	document.getElementById("code").innerHTML = colored;