2015-10-09 21:31:06 +03:00
|
|
|
<!doctype html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>semantic-diff</title>
|
2015-10-09 22:27:44 +03:00
|
|
|
<style type="text/css">
|
2015-10-23 23:53:02 +03:00
|
|
|
#before, #after {
|
2015-10-23 21:00:25 +03:00
|
|
|
width: 50%;
|
|
|
|
}
|
2015-10-23 23:53:02 +03:00
|
|
|
#before {
|
2015-10-23 21:00:25 +03:00
|
|
|
float: left;
|
|
|
|
}
|
2015-10-23 23:53:02 +03:00
|
|
|
#after {
|
2015-10-23 21:00:25 +03:00
|
|
|
float: right;
|
|
|
|
}
|
2015-10-21 18:48:46 +03:00
|
|
|
body {
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
2015-10-22 01:06:45 +03:00
|
|
|
font-family: monospace;
|
2015-10-21 18:48:46 +03:00
|
|
|
}
|
2015-10-13 18:07:40 +03:00
|
|
|
.insert {
|
2015-10-13 18:43:25 +03:00
|
|
|
background-color: #eaffea;
|
2015-10-13 18:43:17 +03:00
|
|
|
outline: 1px solid #c1e9c1;
|
2015-10-13 18:07:40 +03:00
|
|
|
}
|
|
|
|
.delete {
|
2015-10-13 18:43:25 +03:00
|
|
|
background-color: #ffecec;
|
2015-10-13 18:43:17 +03:00
|
|
|
outline: 1px solid #f1c0c0;
|
2015-10-13 18:07:40 +03:00
|
|
|
}
|
2015-10-13 18:25:20 +03:00
|
|
|
.replace {
|
2015-10-24 04:29:02 +03:00
|
|
|
background-color: #ffffec;
|
|
|
|
outline: 1px solid #e9e9c0;
|
2015-10-13 18:25:20 +03:00
|
|
|
}
|
2015-11-03 21:12:35 +03:00
|
|
|
|
|
|
|
.invisible {
|
|
|
|
background-color: #fff;
|
|
|
|
visibility: hidden;
|
|
|
|
}
|
2015-10-22 00:34:10 +03:00
|
|
|
|
2015-10-24 04:19:19 +03:00
|
|
|
.diff div, .diff ul, .diff li, .diff dl, .diff dd, .diff span {
|
2015-10-22 00:34:10 +03:00
|
|
|
white-space: pre-wrap;
|
2015-10-22 00:35:12 +03:00
|
|
|
display: inline;
|
2015-10-22 00:53:57 +03:00
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
2015-11-03 22:31:36 +03:00
|
|
|
color: initial;
|
2015-10-22 00:34:10 +03:00
|
|
|
}
|
2015-10-22 01:07:08 +03:00
|
|
|
|
2015-11-08 23:20:32 +03:00
|
|
|
ul.line-numbers {
|
|
|
|
list-style: none;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
float: left;
|
|
|
|
}
|
|
|
|
|
2015-10-24 04:19:19 +03:00
|
|
|
.diff dt {
|
2015-10-22 01:07:08 +03:00
|
|
|
display: none;
|
|
|
|
}
|
2015-11-03 22:12:41 +03:00
|
|
|
|
|
|
|
/* syntax highlighting */
|
2015-11-03 23:12:44 +03:00
|
|
|
.diff .category-regex,
|
2015-11-03 22:31:22 +03:00
|
|
|
.diff .category-string {
|
2015-11-03 22:12:41 +03:00
|
|
|
color: #183691;
|
|
|
|
}
|
2015-11-03 22:12:45 +03:00
|
|
|
|
2015-11-03 22:54:28 +03:00
|
|
|
.diff .category-false,
|
|
|
|
.diff .category-true,
|
2015-11-03 23:07:17 +03:00
|
|
|
.diff .category-null,
|
2015-11-03 23:07:20 +03:00
|
|
|
.diff .category-undefined,
|
2015-11-03 22:54:28 +03:00
|
|
|
.diff .category-number,
|
2015-11-03 23:00:49 +03:00
|
|
|
.diff .category-function_call>li>.category-identifier,
|
|
|
|
.diff .category-function_call>li>.category-member_access>.category-identifier,
|
2015-11-03 22:48:22 +03:00
|
|
|
.diff .category-member_access>:not(:first-child)>.category-identifier {
|
2015-11-03 22:35:12 +03:00
|
|
|
color: #0086b3;
|
|
|
|
}
|
2015-11-03 22:35:19 +03:00
|
|
|
|
|
|
|
.diff .category-comment {
|
|
|
|
color: #969896;
|
|
|
|
}
|
2015-11-03 22:40:37 +03:00
|
|
|
|
2015-11-03 23:06:58 +03:00
|
|
|
.diff [class^="category-"][class$="_op"],
|
2015-11-03 22:55:51 +03:00
|
|
|
.diff .category-ternary,
|
2015-11-03 22:40:37 +03:00
|
|
|
.diff .category-var_declaration,
|
2015-11-03 23:09:50 +03:00
|
|
|
.diff .category-new_expression,
|
2015-11-03 22:40:37 +03:00
|
|
|
.diff .category-if_statement,
|
|
|
|
.diff .category-do_statement,
|
|
|
|
.diff .category-for_statement,
|
2015-11-03 23:30:34 +03:00
|
|
|
.diff .category-for_in_statement,
|
2015-11-03 22:40:37 +03:00
|
|
|
.diff .category-return_statement,
|
2015-11-03 22:57:22 +03:00
|
|
|
.diff .category-function,
|
|
|
|
.diff .category-assignment,
|
|
|
|
.diff .category-var_assignment {
|
2015-11-03 22:40:37 +03:00
|
|
|
color: #a71d5d;
|
|
|
|
}
|
2015-11-03 22:48:30 +03:00
|
|
|
|
2015-11-03 23:13:39 +03:00
|
|
|
.diff .category-function>li:first-child>.category-identifier,
|
2015-11-03 23:09:55 +03:00
|
|
|
.diff .category-new_expression>li>.category-function_call>li:first-child>.category-identifier,
|
2015-11-03 22:51:41 +03:00
|
|
|
.diff .category-pair>li:first-child>.category-identifier,
|
2015-11-03 22:49:45 +03:00
|
|
|
.diff .category-assignment>li:first-child>.category-member_access>:not(:first-child)>.category-identifier {
|
2015-11-03 22:48:30 +03:00
|
|
|
color: #795da3;
|
|
|
|
}
|
2015-10-09 22:27:44 +03:00
|
|
|
</style>
|
2015-10-27 18:09:48 +03:00
|
|
|
<script type="text/javascript" src="dictionary.js"></script>
|
2015-10-27 18:11:45 +03:00
|
|
|
<script type="text/javascript" src="diff.js"></script>
|
2015-10-27 18:09:16 +03:00
|
|
|
<script type="text/javascript" src="patch.js"></script>
|
2015-10-27 18:10:38 +03:00
|
|
|
<script type="text/javascript" src="syntax.js"></script>
|
|
|
|
<script type="text/javascript" src="term.js"></script>
|
2015-10-09 21:31:06 +03:00
|
|
|
<script type="text/javascript">
|
|
|
|
function loadJSON(path, callback) {
|
|
|
|
var request = new XMLHttpRequest();
|
|
|
|
request.overrideMimeType("application/json");
|
|
|
|
request.open('GET', '' + path, true);
|
|
|
|
request.onreadystatechange = function () {
|
|
|
|
if (request.readyState == 4 && (request.status == "200" || request.status == 0)) {
|
2015-10-09 21:36:18 +03:00
|
|
|
callback(JSON.parse(request.responseText));
|
2015-10-09 21:31:06 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
request.send(null);
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
2015-11-08 23:20:32 +03:00
|
|
|
<div id="before">
|
|
|
|
<ul id="before-lines" class="line-numbers"></ul>
|
|
|
|
<div id="before-diff" class="diff"></div>
|
|
|
|
</div>
|
|
|
|
<div id="after">
|
|
|
|
<ul id="after-lines" class="line-numbers"></ul>
|
|
|
|
<div id="after-diff" class="diff"></div>
|
|
|
|
</div>
|
2015-10-29 22:11:18 +03:00
|
|
|
|
2015-11-09 22:13:47 +03:00
|
|
|
<script type="text/javascript">
|
|
|
|
var unique = function(array) {
|
|
|
|
return array.reduce(function(accum, current) {
|
|
|
|
if (accum.indexOf(current) < 0) {
|
|
|
|
accum.push(current);
|
|
|
|
}
|
|
|
|
return accum;
|
|
|
|
}, []);
|
|
|
|
}
|
2015-11-08 23:20:32 +03:00
|
|
|
|
2015-11-09 22:13:47 +03:00
|
|
|
loadJSON((window.location.search || '?diff.json').substr(1), function (json) {
|
|
|
|
var diff = diffFromJSON(json.diff);
|
2015-11-08 23:20:32 +03:00
|
|
|
|
|
|
|
var beforeLinesEl = document.getElementById("before-lines")
|
|
|
|
var afterLinesEl = document.getElementById("after-lines")
|
|
|
|
|
2015-11-09 20:06:45 +03:00
|
|
|
var dom = diffToDOM(diff,
|
|
|
|
{ "before": json["before"] , "after": json["after"] },
|
|
|
|
{ "before": beforeLinesEl, "after": afterLinesEl });
|
2015-11-08 23:20:32 +03:00
|
|
|
|
2015-11-09 22:13:47 +03:00
|
|
|
var beforeLines = dom.before.getAttribute("data-line-number").split(",")
|
|
|
|
unique(beforeLines).forEach(function(lineNumber) {
|
|
|
|
var node = wrap("li", document.createTextNode(lineNumber));
|
|
|
|
beforeLinesEl.appendChild(node);
|
|
|
|
});
|
|
|
|
var afterLines = dom.after.getAttribute("data-line-number").split(",")
|
|
|
|
unique(afterLines).forEach(function(lineNumber) {
|
|
|
|
var node = wrap("li", document.createTextNode(lineNumber));
|
|
|
|
afterLinesEl.appendChild(node);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
document.getElementById("before-diff").appendChild(dom.before);
|
|
|
|
document.getElementById("after-diff").appendChild(dom.after);
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|