1
+ < html >
2
+ < head >
3
+ < link href ="https://fonts.googleapis.com/css?family=Lato|Roboto|Source+Code+Pro " rel ="stylesheet ">
4
+ < link rel ="stylesheet " href ="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/monokai.min.css ">
5
+ < link rel ="stylesheet " href ="_demo.css ">
6
+ </ head >
7
+
8
+ < body >
9
+
10
+ < div id ="header ">
11
+ < h1 id ="title "> $.csv.fromObjects()</ h1 >
12
+ < div id ="link "> < a href ="https://github.com/evanplaice/jquery-csv "> GitHub</ a > </ div >
13
+ </ div >
14
+ < div id ="container ">
15
+ < section id ="content ">
16
+ < h2 > Description</ h2 >
17
+ < p > Used to format an array of structured objects as CSV.</ p >
18
+ < hr >
19
+ < h2 > Usage</ h2 >
20
+ < pre > < code class ="javascript "> var result = $.csv.fromObjects(input);</ code > </ pre >
21
+ < hr />
22
+ < h2 > Input</ h2 >
23
+ < textarea id ="input " style ="height: 320px; ">
24
+ [
25
+ {
26
+ "ID":"1",
27
+ "iManufacturer":"Evans & Sutherland",
28
+ "iMPartNumber":"230-132-111AA",
29
+ "iSimCategory":"Visual",
30
+ "iPartType":"PCB",
31
+ "iGroup":"1",
32
+ "iLocation":"Offsite"
33
+ },
34
+ {
35
+ "ID":"2",
36
+ "iManufacturer":"Evans & Sutherland",
37
+ "iMPartNumber":"230-132-111AA",
38
+ "iSimCategory":"Visual",
39
+ "iPartType":"PCB",
40
+ "iGroup":"1",
41
+ "iLocation":"Offsite"
42
+ }
43
+ ]
44
+ </ textarea >
45
+ < input id ="run " type ="button " value ="Run " />
46
+ < hr />
47
+ < h2 > Result</ h2 >
48
+ < textarea id ="result " style ="height: 65px; "> </ textarea >
49
+ </ section >
50
+ </ div >
51
+
52
+ < script src ="http://code.jquery.com/jquery-3.3.1.slim.js " integrity ="sha256-fNXJFIlca05BIO2Y5zh1xrShK3ME+/lYZ0j+ChxX2DA= " crossorigin ="anonymous "> </ script >
53
+ < script src ="../src/jquery.csv.js "> </ script >
54
+ < script src ="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js "> </ script >
55
+ < script >
56
+ // enable syntax highlighting
57
+ hljs . initHighlightingOnLoad ( ) ;
58
+
59
+ $ ( document ) . ready ( ( ) => {
60
+ format ( ) ;
61
+ } ) ;
62
+
63
+ $ ( '#run' ) . bind ( 'click' , function ( ) {
64
+ format ( ) ;
65
+ } ) ;
66
+
67
+ function format ( ) {
68
+ const input = JSON . parse ( $ ( '#input' ) . val ( ) ) ;
69
+ const csv = $ . csv . fromObjects ( input ) ;
70
+ $ ( '#result' ) . empty ( ) ;
71
+ $ ( '#result' ) . html ( csv ) ;
72
+ }
73
+ </ script >
74
+ </ body >
75
+ </ html >
0 commit comments