mirror of
https://github.com/github/semantic.git
synced 2024-12-22 06:11:49 +03:00
73 lines
2.4 KiB
HTML
73 lines
2.4 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>semantic-diff</title>
|
|
<link rel="stylesheet" href="style.css">
|
|
<script type="text/javascript" src="dictionary.js"></script>
|
|
<script type="text/javascript" src="diff.js"></script>
|
|
<script type="text/javascript" src="patch.js"></script>
|
|
<script type="text/javascript" src="syntax.js"></script>
|
|
<script type="text/javascript" src="term.js"></script>
|
|
<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)) {
|
|
callback(JSON.parse(request.responseText));
|
|
}
|
|
};
|
|
request.send(null);
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<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>
|
|
|
|
<script type="text/javascript">
|
|
var unique = function(array) {
|
|
return array.reduce(function(accum, current) {
|
|
if (accum.indexOf(current) < 0) {
|
|
accum.push(current);
|
|
}
|
|
return accum;
|
|
}, []);
|
|
}
|
|
|
|
loadJSON((window.location.search || '?diff.json').substr(1), function (json) {
|
|
var diff = diffFromJSON(json.diff);
|
|
|
|
var beforeLinesEl = document.getElementById("before-lines")
|
|
var afterLinesEl = document.getElementById("after-lines")
|
|
|
|
var dom = diffToDOM(diff,
|
|
{ "before": json["before"] , "after": json["after"] },
|
|
{ "before": beforeLinesEl, "after": afterLinesEl });
|
|
|
|
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>
|