aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.ditz/issue-9465e033d968b2c64f02b71bce62d5a0323a60be.yaml20
-rw-r--r--.ditz/project.yaml8
-rw-r--r--.gitignore1
-rw-r--r--.gitmodules15
m---------hinnerup0
-rw-r--r--json_diff.js158
m---------test/data0
m---------xdiff/UM-C0
m---------xdiff/UM-J0
m---------xdiff/ruby0
10 files changed, 118 insertions, 84 deletions
diff --git a/.ditz/issue-9465e033d968b2c64f02b71bce62d5a0323a60be.yaml b/.ditz/issue-9465e033d968b2c64f02b71bce62d5a0323a60be.yaml
new file mode 100644
index 0000000..4f052d1
--- /dev/null
+++ b/.ditz/issue-9465e033d968b2c64f02b71bce62d5a0323a60be.yaml
@@ -0,0 +1,20 @@
+--- !ditz.rubyforge.org,2008-03-06/issue
+title: There must be an exclude parameter
+desc: |-
+ Some properties must be excluded. I.e., piglit's JSON produces a lot of
+ time properties which are not interesting.
+type: :bugfix
+component: json_diff
+release:
+reporter: Matej Cepl <mcepl@redhat.com>
+status: :unstarted
+disposition:
+creation_time: 2011-10-10 21:31:46.437278 Z
+references: []
+
+id: 9465e033d968b2c64f02b71bce62d5a0323a60be
+log_events:
+- - 2011-10-10 21:31:48.551344 Z
+ - Matej Cepl <mcepl@redhat.com>
+ - created
+ - ""
diff --git a/.ditz/project.yaml b/.ditz/project.yaml
new file mode 100644
index 0000000..9a8c903
--- /dev/null
+++ b/.ditz/project.yaml
@@ -0,0 +1,8 @@
+--- !ditz.rubyforge.org,2008-03-06/project
+name: json_diff
+version: "0.5"
+components:
+- !ditz.rubyforge.org,2008-03-06/component
+ name: json_diff
+releases: []
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a6c57f5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.json
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..f5387b2
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,15 @@
+[submodule "xdiff/ruby"]
+ path = xdiff/ruby
+ url = git://github.com/cmsd2/xdiff.git
+[submodule "xdiff/UM-C"]
+ path = xdiff/UM-C
+ url = git@gitorious.org:json_diff/x-diff_c.git
+[submodule "xdiff/UM-J"]
+ path = xdiff/UM-J
+ url = git@gitorious.org:json_diff/x-diff_j.git
+[submodule "test/data"]
+ path = test/data
+ url = git@gitorious.org:json_diff/test-data.git
+[submodule "hinnerup"]
+ path = hinnerup
+ url = git@gitorious.org:json_diff/jsonhandler.git
diff --git a/hinnerup b/hinnerup
new file mode 160000
+Subproject 99e4146bc3f49d19b9769f2e1f4e9870514acb9
diff --git a/json_diff.js b/json_diff.js
index 27973aa..07068cb 100644
--- a/json_diff.js
+++ b/json_diff.js
@@ -1,86 +1,77 @@
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-var jsonBoxA, jsonBoxB;
-
-var HashStore = {
- load : function(callback) {
- if (window.location.hash) {
- try {
- var hashObject = JSON.parse(decodeURIComponent(window.location.hash.slice(1)));
- callback && callback(hashObject.d);
- return;
- } catch (e) {
- console.log()
- }
- }
- callback && callback(null);
- },
- sync : function(object) {
- var hashObject = { d : object };
- window.location.hash = "#" + encodeURIComponent(JSON.stringify(hashObject));
- }
-};
-
-function init() {
- document.addEventListener("click", clickHandler, false);
+#!/usr/bin/rhino
+/*
+This is for now just reimplementation of tlrobinson's json-diff (http://tlrobinson.net/projects/javascript-fun/jsondiff/).
- jsonBoxA = document.getElementById("jsonA");
- jsonBoxB = document.getElementById("jsonB");
-
- HashStore.load(function(data) {
- if (data) {
- jsonBoxA.value = data.a;
- jsonBoxB.value = data.b;
- }
- });
-
- startCompare();
-}
-
-function swapBoxes() {
- var tmp = jsonBoxA.value;
- jsonBoxA.value = jsonBoxB.value;
- jsonBoxB.value = tmp;
-}
+However, later I would like to incorporate algorightm from
+https://github.com/cmsd2/xdiff (which is an implementation in Ruby of
+http://pages.cs.wisc.edu/~yuanwang/xdiff.html)
+ */
-function clearBoxes() {
- jsonBoxA.value = "";
- jsonBoxB.value = "";
-}
-
-function startCompare() {
- var aValue = jsonBoxA.value;
- var bValue = jsonBoxB.value;
-
- var objA, objB;
- try {
- objA = JSON.parse(aValue);
- jsonBoxA.style.backgroundColor = "";
- } catch(e) {
- jsonBoxA.style.backgroundColor = "rgba(255,0,0,0.5)";
- }
- try {
- objB = JSON.parse(bValue);
- jsonBoxB.style.backgroundColor = "";
- } catch(e) {
- jsonBoxB.style.backgroundColor = "rgba(255,0,0,0.5)";
- }
-
- HashStore.sync({
- a : aValue,
- b : bValue
- });
-
- results = document.getElementById("results");
- removeAllChildren(results);
+var jsonBoxA, jsonBoxB;
- compareTree(objA, objB, "root", results);
-}
+//var HashStore = {
+// load : function(callback) {
+// if (window.location.hash) {
+// try {
+// var hashObject = JSON.parse(decodeURIComponent(window.location.hash.slice(1)));
+// callback && callback(hashObject.d);
+// return;
+// } catch (e) {
+// console.log()
+// }
+// }
+// callback && callback(null);
+// },
+// sync : function(object) {
+// var hashObject = { d : object };
+// window.location.hash = "#" + encodeURIComponent(JSON.stringify(hashObject));
+// }
+//};
+
+//function init() {
+// document.addEventListener("click", clickHandler, false);
+
+// jsonBoxA = document.getElementById("jsonA");
+// jsonBoxB = document.getElementById("jsonB");
+
+// HashStore.load(function(data) {
+// if (data) {
+// jsonBoxA.value = data.a;
+// jsonBoxB.value = data.b;
+// }
+// });
+
+// startCompare();
+//}
+
+//function startCompare() {
+// var aValue = jsonBoxA.value;
+// var bValue = jsonBoxB.value;
+
+// var objA, objB;
+// try {
+// objA = JSON.parse(aValue);
+// jsonBoxA.style.backgroundColor = "";
+// } catch(e) {
+// jsonBoxA.style.backgroundColor = "rgba(255,0,0,0.5)";
+// }
+// try {
+// objB = JSON.parse(bValue);
+// jsonBoxB.style.backgroundColor = "";
+// } catch(e) {
+// jsonBoxB.style.backgroundColor = "rgba(255,0,0,0.5)";
+// }
+
+// HashStore.sync({
+// a : aValue,
+// b : bValue
+// });
+
+// results = document.getElementById("results");
+// removeAllChildren(results);
+
+// compareTree(objA, objB, "root", results);
+//}
function compareTree(a, b, name, results) {
var typeA = typeofReal(a);
@@ -161,11 +152,8 @@ function removeAllChildren(node) {
}
}
-function isArray(value) {
- return value && typeof value === "object" && value.constructor === Array;
-}
function typeofReal(value) {
- return isArray(value) ? "array" : typeof value;
+ return Array.isArray(value) ? "array" : typeof value;
}
function clickHandler(e) {
@@ -177,3 +165,5 @@ function clickHandler(e) {
e.target.setAttribute("closed", "yes");
}
}
+
+/* vim: set ts=2 et sw=2 tw=80: */
diff --git a/test/data b/test/data
new file mode 160000
+Subproject cd6d79b5106d74504ea090c7b864fd015ec9a49
diff --git a/xdiff/UM-C b/xdiff/UM-C
new file mode 160000
+Subproject d96a555ed150d291a8f3426f8895cf54f251ede
diff --git a/xdiff/UM-J b/xdiff/UM-J
new file mode 160000
+Subproject 450e5c70e807efb944573b3ec7e48d4c0d8c098
diff --git a/xdiff/ruby b/xdiff/ruby
new file mode 160000
+Subproject 5fc6532326cd4456db19b29c1e24a201f44454c