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-21 18:11:14 +03:00
|
|
|
#before {
|
|
|
|
width: 50%;
|
2015-10-21 18:11:37 +03:00
|
|
|
background: #ffecec;
|
2015-10-21 18:11:14 +03:00
|
|
|
float: left;
|
2015-10-21 18:11:30 +03:00
|
|
|
white-space: pre-wrap;
|
2015-10-21 18:11:14 +03:00
|
|
|
}
|
|
|
|
#after {
|
|
|
|
width: 50%;
|
2015-10-21 18:11:37 +03:00
|
|
|
background: #eaffea;
|
2015-10-21 18:11:14 +03:00
|
|
|
float: right;
|
2015-10-21 18:11:30 +03:00
|
|
|
white-space: pre-wrap;
|
2015-10-21 18:11:14 +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:24:55 +03:00
|
|
|
margin-left: 50%;
|
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:24:55 +03:00
|
|
|
margin-right: 50%;
|
2015-10-13 18:07:40 +03:00
|
|
|
}
|
2015-10-13 18:25:20 +03:00
|
|
|
.replace {
|
2015-10-13 20:17:18 +03:00
|
|
|
background-color: #eee;
|
2015-10-13 18:25:20 +03:00
|
|
|
}
|
2015-10-09 22:27:44 +03:00
|
|
|
</style>
|
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);
|
|
|
|
}
|
2015-10-13 16:47:47 +03:00
|
|
|
|
2015-10-13 18:10:54 +03:00
|
|
|
function wrap(tagName, element) {
|
2015-10-13 18:22:56 +03:00
|
|
|
if (element == null) { return null; }
|
2015-10-13 18:10:54 +03:00
|
|
|
var node = document.createElement(tagName);
|
|
|
|
node.appendChild(element);
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2015-10-21 18:17:16 +03:00
|
|
|
function indexed(array) {
|
|
|
|
for (index in array) {
|
|
|
|
syntax(array[index]);
|
|
|
|
}
|
|
|
|
}
|
2015-10-21 18:17:25 +03:00
|
|
|
|
|
|
|
function keyed(object) {
|
|
|
|
for (key in object) {
|
|
|
|
syntax(object[key]);
|
|
|
|
}
|
|
|
|
}
|
2015-10-21 18:17:33 +03:00
|
|
|
|
|
|
|
function syntax(json) {
|
|
|
|
if (json instanceof Array) { return indexed(json); }
|
|
|
|
if (json instanceof Object) { return keyed(json); }
|
|
|
|
}
|
2015-10-09 21:31:06 +03:00
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
2015-10-21 18:11:01 +03:00
|
|
|
<div id="before"></div>
|
|
|
|
<div id="after"></div>
|
2015-10-13 18:05:13 +03:00
|
|
|
<div id="diff"></div>
|
2015-10-09 21:31:06 +03:00
|
|
|
<script type="text/javascript">
|
2015-10-21 00:52:04 +03:00
|
|
|
loadJSON('diff.json', function (json) {
|
2015-10-21 18:11:50 +03:00
|
|
|
document.getElementById("before").textContent = json.a;
|
|
|
|
document.getElementById("after").textContent = json.b;
|
2015-10-21 18:17:39 +03:00
|
|
|
|
|
|
|
syntax(json["diff"]);
|
2015-10-09 21:31:06 +03:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|