-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.html
189 lines (173 loc) · 5.68 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>reformed</title>
<link rel="stylesheet" type="text/css" href="reformed.css" />
</head>
<body>
<a href="http://github.com/BigBlueHat/reformed"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
<h1>re:form.ed by <a href="http://www.bigbluehat.com/">Big<em>Blue</em>Hat</a>
<span class="download">
<a href="http://github.com/BigBlueHat/reformed/zipball/master">
<img border="0" width="70" src="http://github.com/images/modules/download/zip.png" /></a>
<a href="http://github.com/BigBlueHat/reformed/tarball/master">
<img border="0" width="70" src="http://github.com/images/modules/download/tar.png" /></a>
</span>
</h1>
<h5>converting JSON into an HTML Form and back</h5>
<div style="overflow:hidden">
<div class="left">
<div><a id="examplejson" href="">Example JSON</a> | <a id="cardschema" href="">Card Schema</a></div>
<textarea id="input">
{
"id": "507401517",
"name": "Benjamin Young",
"first_name": "Benjamin",
"last_name": "Young",
"link": "http://www.facebook.com/benjaminyoung",
"about": "Dreamer, Inventor, Web Developer. I run this: http://bigbluehat.com/ and build this: http://blueinkcms.com/",
"location": {
"id": 107600062603098,
"name": "Greenville, South Carolina"
},
"work": [
{
"employer": {
"id": 111737955518707,
"name": "BigBlueHat"
},
"start_date": "2003-07"
}
],
"meeting_for": [
"Friendship",
"Networking"
]
}
</textarea>
<div class="buttons">
re:form for
<input type="button" value="JSON editing" id="reformforjson" />
<input type="button" value="data entry" id="reformfordataentry" />
<input type="button" value="data entry (schema)" id="reformforschemadataentry" />
<input type="button" value="pretty the JSON" id="prettythis" />
</div>
</div>
<div class="right">
<textarea id="output">
</textarea>
<div class="buttons">
<input type="button" value="re:JSON the form below" id="jsonthis" />
</div>
</div>
</div>
<form id="reformed">
</form>
<!-- sample JSON serialization in HTML -->
<form id="formed" style="display:none">
<div class="kvp">
<input type="text" value="name" />
<input type="text" value="Benjamin Young" />
</div>
<div class="kvp">
<input type="text" value="location" />
<fieldset class="object">
<div class="kvp">
<input type="text" name="" value="name" />
<input type="text" name="" value="Greenville, South Carolina" />
</div>
</fieldset>
</div>
<div class="kvp">
<input type="text" value="work" />
<fieldset class="array"><!-- array -->
<fieldset class="object"><!-- object -->
<div class="kvp">
<input type="text" value="employer" />
<fieldset class="object"><!-- object -->
<div class="kvp">
<input type="text" value="id" />
<input type="text" value="111737955518707" />
</div>
<div class="kvp">
<input type="text" value="name" />
<input type="text" value="BigBlueHat" />
</div>
</fieldset>
</div>
<div class="kvp">
<input type="text" value="start_date" />
<input type="text" value="2003-07" />
</div>
</fieldset>
<fieldset class="object"><!-- object -->
<div class="kvp">
<input type="text" value="employer" />
<fieldset class="object"><!-- object -->
<div class="kvp">
<input type="text" value="id" />
<input type="text" value="123" />
</div>
<div class="kvp">
<input type="text" value="name" />
<input type="text" value="Other Employer" />
</div>
</fieldset><!-- end object -->
</div>
</fieldset><!-- end object -->
</fieldset><!-- end array -->
</div>
<div class="kvp">
<input type="text" value="meeting_for" />
<fieldset class="array"><!-- array -->
<input type="text" value="Friendship" />
<input type="text" value="Networking" />
</fieldset>
</div>
</form>
<script type="text/javascript" src="js/jquery.1.4.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.2.custom.min.js"></script>
<script type="text/javascript" src="js/jquery.hotkeys.js"></script>
<script type="text/javascript" src="js/jquery.reformed.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// JSON loaders
$('#examplejson').click(function(ev) {
ev.preventDefault();
$.get('example.json',function(data) { $('#input').val(data); }, 'text');
});
$('#cardschema').click(function(ev) {
ev.preventDefault();
$.get('schemas/card',function(data) { $('#input').val(data); }, 'text');
});
// re:form-ers
$('#reformforjson').click(function() {
$('#reformed').reform($('#input').val(), {'editor':'edit'});
});
$('#reformforschemadataentry').click(function() {
$('#reformed').reform($('#input').val(), {'editor':'schema'});
});
$('#reformfordataentry').click(function() {
$('#reformed').reform($('#input').val(), {'editor':'data'});
});
$('#jsonthis').click(function() {
$('#output').val($.rejson('#reformed'));
});
// clean up the JSON code
$('#prettythis').click(function() {
$('#input').val(JSON.stringify($.parseJSON($('#input').val()), null, '\t'));
});
// synchronized scrolling of before & after
$('#input').scroll(function() {
$('#output')
.scrollTop($('#input').scrollTop());
});
$('#output').scroll(function() {
$('#input')
.scrollTop($('#output').scrollTop());
});
});
</script>
</body>
</html>