Skip to content

Commit

Permalink
Merge pull request #5 from jongha/dictheader
Browse files Browse the repository at this point in the history
Implement auto header column for dict data.
  • Loading branch information
jongha committed Aug 20, 2014
2 parents ad4fdd9 + 25d8d51 commit 9aededf
Show file tree
Hide file tree
Showing 7 changed files with 385 additions and 306 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: node_js
node_js:
- "0.8"
- "0.10"
before_script:
- npm install -g grunt-cli
- npm update -g npm
- npm install -g grunt-cli
52 changes: 40 additions & 12 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
$(document).ready(function() {
var arr = [
[1, 2, 3],
['one', 'two', 'three']
["one", "two", "three"]
];

/* Array To Table */
var input = JSON.stringify(arr);
$("#jsontotable-arr")
.append($("<h1></h1>").html("Array To Table"))
Expand All @@ -39,6 +40,7 @@

$.jsontotable(arr, { id: "#jsontotable-arr", header: true });

/* Array To Table (Without Header) */
$("#jsontotable-arr")
.append($("<h1></h1>").html("Array To Table (Without Header)"))
.append($("<h2></h2>").html("Input"))
Expand All @@ -56,6 +58,7 @@
{"Title1": "Ciao", "Title2": "Bene", "Title3": "Grazie"}
];

/* JSON To Table (Has Header) */
input = JSON.stringify(obj);
$("#jsontotable-obj")
.append($("<h1></h1>").html("JSON To Table (Has Header)"))
Expand All @@ -65,6 +68,7 @@

$.jsontotable(obj, { id: "#jsontotable-obj" });

/* JSON To Table (Without Header) */
$("#jsontotable-obj")
.append($("<h1></h1>").html("JSON To Table (Without Header)"))
.append($("<h2></h2>").html("Input"))
Expand All @@ -73,15 +77,36 @@

$.jsontotable(obj, { id: "#jsontotable-obj", header: false });


var objmissing = [
{"Title1": "Hello", "Title2": "Fine", "Title3": "Thank you"},
{"Title1": "안녕하세요", "Title2": "좋아요", "Title3": "감사합니다"},
{"Title4": "こんにちは", "Title2": "ファイン", "Title5": "ありがとう"},
{"Title1": "你好", "Title5": "精", "Title3": "谢谢"},
{"Title5": "Bonjour", "Title4": "Beaux", "Title3": "Merci"},
{"Title1": "Ciao", "Title6": "Bene", "Title7": "Grazie"}
];

/* JSON To Table (Has Header and Missing some columns in body */
input = JSON.stringify(objmissing);
$("#jsontotable-obj")
.append($("<h1></h1>").html("JSON To Table (Has Header and Missing some columns in body)"))
.append($("<h2></h2>").html("Input"))
.append($("<code></code>").html(input))
.append($("<h2></h2>").html("Output"));

$.jsontotable(objmissing, { id: "#jsontotable-obj" , header: true });

var objwithdata = [
{ id: 'header', class: 'header-class', _data:['Hello','Fine', 'Thank you'] },
{ id: "header", "class": "header-class", _data:{"Title1": "안녕하세요", "Title2": "좋아요", "Title3": "감사합니다"} },
{"Title1": "안녕하세요", "Title2": "좋아요", "Title3": "감사합니다"},
{"Title1": "こんにちは", "Title2": "ファイン", "Title3": "ありがとう"},
{"Title1": "你好", "Title2": "精", "Title3": "谢谢"},
{"Title1": "Bonjour", "Title2": "Beaux", "Title3": "Merci"},
{"Title1": "Ciao", "Title2": "Bene", "Title3": "Grazie"}
];


/* JSON To Table with _data attribute (Has Header) */
input = JSON.stringify(objwithdata);
$("#jsontotable-objwithdata")
.append($("<h1></h1>").html("JSON To Table with _data attribute (Has Header)"))
Expand All @@ -91,6 +116,8 @@

$.jsontotable(objwithdata, { id: "#jsontotable-objwithdata" });


/* JSON To Table with _data attribute (Without Header) */
$("#jsontotable-objwithdata")
.append($("<h1></h1>").html("JSON To Table with _data attribute (Without Header)"))
.append($("<h2></h2>").html("Input"))
Expand All @@ -99,15 +126,16 @@

$.jsontotable(objwithdata, { id: "#jsontotable-objwithdata", header: false });

var str = '[\
{"Title1": "Hello", "Title2": "Fine", "Title3": "Thank you"}, \
{"Title1": "안녕하세요", "Title2": "좋아요", "Title3": "감사합니다"}, \
{"Title1": "こんにちは", "Title2": "ファイン", "Title3": "ありがとう"}, \
{"Title1": "你好", "Title2": "精", "Title3": "谢谢"}, \
{"Title1": "Bonjour", "Title2": "Beaux", "Title3": "Merci"}, \
{"Title1": "Ciao", "Title2": "Bene", "Title3": "Grazie"} \
]';
var str = "[\
{\"Title1\": \"Hello\", \"Title2\": \"Fine\", \"Title3\": \"Thank you\"}, \
{\"Title1\": \"안녕하세요\", \"Title2\": \"좋아요\", \"Title3\": \"감사합니다\"}, \
{\"Title1\": \"こんにちは\", \"Title2\": \"ファイン\", \"Title3\": \"ありがとう\"}, \
{\"Title1\": \"你好\", \"Title2\": \"精\", \"Title3\": \"谢谢\"}, \
{\"Title1\": \"Bonjour\", \"Title2\": \"Beaux\", \"Title3\": \"Merci\"}, \
{\"Title1\": \"Ciao\", \"Title2\": \"Bene\", \"Title3\": \"Grazie\"} \
]";

/* JSON (String Format) To Table" */
$("#jsontotable-str")
.append($("<h1></h1>").html("JSON (String Format) To Table"))
.append($("<h2></h2>").html("Input"))
Expand All @@ -121,4 +149,4 @@
});
</script>
</body>
</html>
</html>
4 changes: 2 additions & 2 deletions dist/jquery.jsontotable.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
"name": "jquery.jsontotable",
"version": "1.1.2",
"engines": {
"node": ">= 0.8.0"
"node": ">=0.10.26"
},
"scripts": {
"test": "grunt travis --verbose"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.7.2",
"grunt-contrib-uglify": "~0.2.7",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-cssmin": "~0.7.0",
"grunt": "~0.4.2",
"grunt-shell": "~0.6.1",
"coveralls": "~2.5.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-qunit-istanbul": "~0.3.0"
"coveralls": "^2.11.1",
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-cssmin": "^0.10.0",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-uglify": "^0.5.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-qunit-istanbul": "^0.4.5",
"grunt-shell": "^0.7.0"
}
}

0 comments on commit 9aededf

Please sign in to comment.