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">
|
|
|
|
#left {
|
|
|
|
position: absolute;
|
|
|
|
left: 0; top: 0;
|
|
|
|
width: 50%;
|
|
|
|
outline: 1px solid green;
|
|
|
|
}
|
|
|
|
#right {
|
|
|
|
position: absolute;
|
|
|
|
right: 0; top: 0;
|
|
|
|
width: 50%;
|
|
|
|
outline: 1px solid red;
|
|
|
|
}
|
|
|
|
</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
|
|
|
|
|
|
|
function toDOM(json) {
|
2015-10-13 17:17:17 +03:00
|
|
|
var div = document.createElement("div");
|
2015-10-13 16:47:47 +03:00
|
|
|
if (json instanceof Array) {
|
2015-10-13 17:16:54 +03:00
|
|
|
console.log("it's an array");
|
2015-10-13 16:47:47 +03:00
|
|
|
for (index in json) {
|
2015-10-13 17:16:54 +03:00
|
|
|
console.log(json[index]);
|
2015-10-13 16:47:47 +03:00
|
|
|
}
|
|
|
|
} else if (json instanceof Object) {
|
|
|
|
for (key in json) {
|
2015-10-13 17:16:54 +03:00
|
|
|
console.log(key);
|
2015-10-13 16:47:47 +03:00
|
|
|
}
|
|
|
|
}
|
2015-10-13 17:17:17 +03:00
|
|
|
return div;
|
2015-10-13 16:47:47 +03:00
|
|
|
}
|
2015-10-09 21:31:06 +03:00
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
2015-10-09 22:27:44 +03:00
|
|
|
<div id="left"></div>
|
|
|
|
<div id="right"></div>
|
2015-10-09 21:31:06 +03:00
|
|
|
<script type="text/javascript">
|
2015-10-09 21:36:38 +03:00
|
|
|
loadJSON('Fixtures/swift.json', function (json) {
|
2015-10-13 16:47:52 +03:00
|
|
|
toDOM(json)
|
2015-10-09 21:31:06 +03:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|