Skip to content

Commit

Permalink
advanced code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
fouber committed Sep 12, 2014
1 parent 24b0b9a commit b73aaa3
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 226 deletions.
21 changes: 20 additions & 1 deletion phantomjs/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,42 @@ module.exports = function(token, diff, opt){
}
}

var count = {
add: 0,
remove: 0,
style: 0,
text: 0
};

// highlight diffs
diff.forEach(function(item){
var node = item.node;
switch (item.type){
var type = item.type;
switch (type){
case CHANGE_TYPE.ADD:
count.add++;
highlightElement(node.rect, CHANGE_STYLE.ADD, rContainer);
break;
case CHANGE_TYPE.REMOVE:
count.remove++;
highlightElement(node.rect, CHANGE_STYLE.REMOVE, lContainer);
break;
case CHANGE_TYPE.TEXT:
count.text++;
highlightElement(node.rect, CHANGE_STYLE.TEXT, rContainer);
break;
default :
if(type & CHANGE_TYPE.STYLE){
count.style++;
}
if(type & CHANGE_TYPE.TEXT){
count.text++;
}
highlightElement(node.rect, CHANGE_STYLE.STYLE, rContainer);
break;
}
});

return count;

};
Loading

0 comments on commit b73aaa3

Please sign in to comment.