diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..16f5197 --- /dev/null +++ b/.gitignore @@ -0,0 +1,110 @@ +# Created by .ignore support plugin (hsz.mobi) +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm + +*.iml + +## Directory-based project format: +.idea/ +# if you remove the above rule, at least ignore the following: + +# User-specific stuff: +# .idea/workspace.xml +# .idea/tasks.xml +# .idea/dictionaries + +# Sensitive or high-churn files: +# .idea/dataSources.ids +# .idea/dataSources.xml +# .idea/sqlDataSources.xml +# .idea/dynamic.xml +# .idea/uiDesigner.xml + +# Gradle: +# .idea/gradle.xml +# .idea/libraries + +# Mongo Explorer plugin: +# .idea/mongoSettings.xml + +## File-based project format: +*.ipr +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties + + +### Python template +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + + diff --git a/bin/jsond b/bin/jsond deleted file mode 100644 index 6b8f4d3..0000000 --- a/bin/jsond +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env node - -var sys = require("sys"), - fs = require("fs"), - argv = require('optimist').argv, - colors = require("colors"), - jsond = require("../js/lib/jsond"); - -// To-Do: seperate rendering to provision for nodejs output using colors etc. \ No newline at end of file diff --git a/closed.png b/closed.png deleted file mode 100644 index 147c717..0000000 Binary files a/closed.png and /dev/null differ diff --git a/img/bg.jpg b/img/bg.jpg deleted file mode 100644 index 260fa20..0000000 Binary files a/img/bg.jpg and /dev/null differ diff --git a/js/app.js b/js/app.js index 541866a..22a9eec 100644 --- a/js/app.js +++ b/js/app.js @@ -84,7 +84,7 @@ if(!window.console){ }, false); document.getElementById("compare").addEventListener("click", function() { - jsond.compare(JSON.parse(jsonBoxA.value), JSON.parse(jsonBoxB.value), "root", populateResults); + self.startCompare(); }, false); jsond.feedback = self.markChanged; diff --git a/js/lib/json-diff.js b/js/lib/json-diff.js deleted file mode 100644 index 353a743..0000000 --- a/js/lib/json-diff.js +++ /dev/null @@ -1,125 +0,0 @@ - -var jsonDiff = (typeof exports !== "undefined" ? exports : window).jsonDiff = (function(){ - - function isArray(value) { - if(Array.isArray) { - return Array.isArray(value); - } - else { - return value && typeof value === "object" && value.constructor === Array; - } - } - - function typeofReal(value) { - return isArray(value) ? "array": value === null ? 'null' : typeof value; - } - - return { - - a: [], // first structure - b: [], // second structure - - feedback: function() { - - }, - - swapValues: function() { - console.log('>>> swapBoxes()'); - this.a = [this.b, this.b = this.a][0]; - }, - - clearValues: function() { - console.log('>>> clearBoxes()'); - this.a = this.b = null; - }, - - compareTree: function(a, b, name, results) { - - var self = this; - - var typeA = typeofReal(a); - var typeB = typeofReal(b); - - console.log('>>> compareTree(a=(' + typeA + ')' + a + - ', b=(' + typeB + ')' + b + - ', name=(' + typeof name + ')' + name + - ', results=(' + typeof results + ')' + results + ')'); - - var typeSpanA = document.createElement("span"); - typeSpanA.appendChild(document.createTextNode("(" + typeA + ")")) - typeSpanA.setAttribute("class", "typeName"); - - var typeSpanB = document.createElement("span"); - typeSpanB.appendChild(document.createTextNode("(" + typeB + ")")) - typeSpanB.setAttribute("class", "typeName"); - - var aString = (typeA === "object" || typeA === "array") ? "": String(a) + " "; - var bString = (typeB === "object" || typeB === "array") ? "": String(b) + " "; - - var leafNode = document.createElement("span"); - leafNode.appendChild(document.createTextNode(name)); - if (a === undefined) - { - leafNode.setAttribute("class", "added"); - leafNode.appendChild(document.createTextNode(": " + bString)); - leafNode.appendChild(typeSpanB); - self.feedback(leafNode); - } - else if (b === undefined) - { - leafNode.setAttribute("class", "removed"); - leafNode.appendChild(document.createTextNode(": " + aString)); - leafNode.appendChild(typeSpanA); - self.feedback(leafNode); - } - else if (typeA !== typeB || (typeA !== "object" && typeA !== "array" && a !== b)) - { - leafNode.setAttribute("class", "changed"); - leafNode.appendChild(document.createTextNode(": " + aString)); - leafNode.appendChild(typeSpanA); - leafNode.appendChild(document.createTextNode(" => " + bString)); - leafNode.appendChild(typeSpanB); - - if (name === 'key') leafNode.setAttribute('class', 'changed key'); - else self.feedback(leafNode); - } - else - { - leafNode.appendChild(document.createTextNode(": " + aString)); - leafNode.appendChild(typeSpanA); - } - - if (typeA === "object" || typeA === "array" || typeB === "object" || typeB === "array") - { - var keys = []; - for (var i in a) keys.push(i); - for (var i in b) keys.push(i); - keys.sort(); - - var listNode = document.createElement("ul"); - listNode.appendChild(leafNode); - - for (var i = 0; i < keys.length; i++) - { - if (keys[i] === keys[i - 1]) - continue; - - var li = document.createElement("li"); - listNode.appendChild(li); - - self.compareTree(a && a[keys[i]], b && b[keys[i]], keys[i], li); - } - - results.appendChild(listNode); - } - else - { - results.appendChild(leafNode); - } - - } - - }; - -})(); - diff --git a/json-diff.css b/json-diff.css deleted file mode 100644 index 04dc054..0000000 --- a/json-diff.css +++ /dev/null @@ -1,73 +0,0 @@ -body { - background-color: lightblue; -} - -#results li > span, #results ul > span { - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - padding-right: 5px; - padding-left: 5px; -} - -#results li { - margin-top: 1px; - padding-left: 15px; -} -#results ul { - padding-left: 15px; - margin-left: -15px; - padding-top: 0px; - margin-top: 0px; - background: url(open.png) no-repeat 2px 5px; - list-style-type: none; -} -#results ul[closed="yes"] { - background: url(closed.png) no-repeat 2px 5px; -} -#results ul[closed="yes"] > * { - display: none; -} -#results ul[closed="yes"] > *:first-child { - display: block; -} -.typeName { - color: gray; -} -.changed { - background-color: #fcff7f; -} -.changed.key { - background-color: #eee; -} - -.added { - background-color: #8bff7f; -} -.removed { - background-color: #fd7f7f; -} - -textarea { - width: 49%; - height: 200px; -} - -.contentbox { - border: 1px dashed black; - background-color: white; - padding: 15px; - margin: 10px; -} - -h2 { - text-align: center; - margin: 0px;; -} - -#results { - padding-left: 40px; -} - -#inputs { - text-align: center; -} \ No newline at end of file diff --git a/jsond.py b/jsond.py new file mode 100755 index 0000000..3aba86e --- /dev/null +++ b/jsond.py @@ -0,0 +1,15 @@ +#!/usr/bin/python + +import sys +import SocketServer +from SimpleHTTPServer import SimpleHTTPRequestHandler as Handler + +if sys.argv[1:]: + port = int(sys.argv[1]) +else: + port = 8888 + +httpd = SocketServer.TCPServer(('0.0.0.0', port), Handler) +sa = httpd.socket.getsockname() +print "Serving HTTP on", sa[0], "port", sa[1], "..." +httpd.serve_forever() \ No newline at end of file diff --git a/open.png b/open.png deleted file mode 100644 index 1d48c6a..0000000 Binary files a/open.png and /dev/null differ diff --git a/package.json b/package.json deleted file mode 100644 index 3628d21..0000000 --- a/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "jsond", - "description": "compare json with a web interface/CLI or API", - "version": "0.0.1", - "author": "hij1nx ", - "contributors": [ - { "name": "hij1nx", "email": "hi1jnx.dev@gmail.com" }, - { "name": "Tom Robinson", "email": "tlr@gmail.com" }, - { "name": "Sami Samhuri", "email": "sami.samhuri@gmail.com" } - ], - "repository": { - "type": "git", - "url": "https://github.com/samsonjs/json-diff" - }, - "keywords": ["cli", "json", "diff", "tools"], - "dependencies": { - "optimist": ">= 0.0.6", - "colors": ">= 0.3.0" - }, - "bin": { "forever": "./bin/jsond" }, - "main": "./lib/jsond", - "engines": { "node": ">= 0.2.0" } -}