Skip to content
Browse files

added colours

  • Loading branch information...
1 parent 3a8b4d5 commit 81128bb22c99404ec5ca6854b64b3dbea94645b4 @dziemid committed
Showing with 31 additions and 1 deletion.
  1. +31 −1 browser.html
View
32 browser.html
@@ -10,6 +10,19 @@
background-color: #FFCC33;
}
+ .add {
+ background-color: #adff2f;
+ }
+
+ .remove {
+ background-color: red;
+ }
+
+ .line {
+ margin: 0 0 0 40px; /*--Left Margin--*/
+ font-size: 12px;
+ }
+
-->
</style>
@@ -18,6 +31,13 @@
<body>
<script type="text/javascript">
+
+ if (typeof String.prototype.startsWith != 'function') {
+ String.prototype.startsWith = function (str) {
+ return this.indexOf(str) == 0;
+ };
+ }
+
var base_url = "http://github.com";
var base_api_url = base_url + "/api/v2/json/commits/show";
@@ -25,7 +45,17 @@
var diff = "<div>";
if (commit.modified) {
for (var i = 0; i < commit.modified.length; i++) {
- diff += commit.modified[i].diff.replace(/\n/g, '<br>');
+ var lines = commit.modified[i].diff.split(/\n/g);
+ for (var y = 0; y < lines.length; y++) {
+ var modClass = "";
+ if (lines[y].startsWith("+")) {
+ modClass = " add";
+ }
+ if (lines[y].startsWith("-")) {
+ modClass = " remove";
+ }
+ diff += "<div class=\"line" + modClass + "\">" + lines[y] + "</div>";
+ }
}
}
diff += "</div>";

0 comments on commit 81128bb

Please sign in to comment.
Something went wrong with that request. Please try again.