forked from JJediny/json-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
951 lines (901 loc) · 48.7 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>FederalProjectSchema</title>
<!-- placeholders for the theme switcher -->
<link rel='stylesheet' id='theme_stylesheet'>
<link rel='stylesheet' id='icon_stylesheet'>
<style>[class*="foundicon-"] {font-family: GeneralFoundicons;font-style: normal;}</style>
<script src='js/jquery.js' type="text/javascript"></script>
<!--<script src='dist/datasourceeditor.js' type="text/javascript"></script>-->
<script src='dist/jsoneditor.js' type="text/javascript"></script>
<link rel="stylesheet" href="//cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<script src="//cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
<!--<script src="dist/json2yaml.js"></script>-->
<script>
/**
* LZString compression library
* Used to create direct links to the demo.
* NOT REQUIRED for JSON Editor.
* https://github.com/pieroxy/lz-string
*/
var LZString={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_f:String.fromCharCode,compressToBase64:function(e){if(e==null)return"";var t="";var n,r,i,s,o,u,a;var f=0;e=LZString.compress(e);while(f<e.length*2){if(f%2==0){n=e.charCodeAt(f/2)>>8;r=e.charCodeAt(f/2)&255;if(f/2+1<e.length)i=e.charCodeAt(f/2+1)>>8;else i=NaN}else{n=e.charCodeAt((f-1)/2)&255;if((f+1)/2<e.length){r=e.charCodeAt((f+1)/2)>>8;i=e.charCodeAt((f+1)/2)&255}else r=i=NaN}f+=3;s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+LZString._keyStr.charAt(s)+LZString._keyStr.charAt(o)+LZString._keyStr.charAt(u)+LZString._keyStr.charAt(a)}return t},decompressFromBase64:function(e){if(e==null)return"";var t="",n=0,r,i,s,o,u,a,f,l,c=0,h=LZString._f;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(c<e.length){u=LZString._keyStr.indexOf(e.charAt(c++));a=LZString._keyStr.indexOf(e.charAt(c++));f=LZString._keyStr.indexOf(e.charAt(c++));l=LZString._keyStr.indexOf(e.charAt(c++));i=u<<2|a>>4;s=(a&15)<<4|f>>2;o=(f&3)<<6|l;if(n%2==0){r=i<<8;if(f!=64){t+=h(r|s)}if(l!=64){r=o<<8}}else{t=t+h(r|i);if(f!=64){r=s<<8}if(l!=64){t+=h(r|o)}}n+=3}return LZString.decompress(t)},compressToUTF16:function(e){if(e==null)return"";var t="",n,r,i,s=0,o=LZString._f;e=LZString.compress(e);for(n=0;n<e.length;n++){r=e.charCodeAt(n);switch(s++){case 0:t+=o((r>>1)+32);i=(r&1)<<14;break;case 1:t+=o(i+(r>>2)+32);i=(r&3)<<13;break;case 2:t+=o(i+(r>>3)+32);i=(r&7)<<12;break;case 3:t+=o(i+(r>>4)+32);i=(r&15)<<11;break;case 4:t+=o(i+(r>>5)+32);i=(r&31)<<10;break;case 5:t+=o(i+(r>>6)+32);i=(r&63)<<9;break;case 6:t+=o(i+(r>>7)+32);i=(r&127)<<8;break;case 7:t+=o(i+(r>>8)+32);i=(r&255)<<7;break;case 8:t+=o(i+(r>>9)+32);i=(r&511)<<6;break;case 9:t+=o(i+(r>>10)+32);i=(r&1023)<<5;break;case 10:t+=o(i+(r>>11)+32);i=(r&2047)<<4;break;case 11:t+=o(i+(r>>12)+32);i=(r&4095)<<3;break;case 12:t+=o(i+(r>>13)+32);i=(r&8191)<<2;break;case 13:t+=o(i+(r>>14)+32);i=(r&16383)<<1;break;case 14:t+=o(i+(r>>15)+32,(r&32767)+32);s=0;break}}return t+o(i+32)},decompressFromUTF16:function(e){if(e==null)return"";var t="",n,r,i=0,s=0,o=LZString._f;while(s<e.length){r=e.charCodeAt(s)-32;switch(i++){case 0:n=r<<1;break;case 1:t+=o(n|r>>14);n=(r&16383)<<2;break;case 2:t+=o(n|r>>13);n=(r&8191)<<3;break;case 3:t+=o(n|r>>12);n=(r&4095)<<4;break;case 4:t+=o(n|r>>11);n=(r&2047)<<5;break;case 5:t+=o(n|r>>10);n=(r&1023)<<6;break;case 6:t+=o(n|r>>9);n=(r&511)<<7;break;case 7:t+=o(n|r>>8);n=(r&255)<<8;break;case 8:t+=o(n|r>>7);n=(r&127)<<9;break;case 9:t+=o(n|r>>6);n=(r&63)<<10;break;case 10:t+=o(n|r>>5);n=(r&31)<<11;break;case 11:t+=o(n|r>>4);n=(r&15)<<12;break;case 12:t+=o(n|r>>3);n=(r&7)<<13;break;case 13:t+=o(n|r>>2);n=(r&3)<<14;break;case 14:t+=o(n|r>>1);n=(r&1)<<15;break;case 15:t+=o(n|r);i=0;break}s++}return LZString.decompress(t)},compressToUint8Array:function(e){var t=LZString.compress(e);var n=new Uint8Array(t.length*2);for(var r=0,i=t.length;r<i;r++){var s=t.charCodeAt(r);n[r*2]=s>>>8;n[r*2+1]=s%256}return n},decompressFromUint8Array:function(e){if(e===null||e===undefined){return LZString.decompress(e)}else{var t=new Array(e.length/2);for(var n=0,r=t.length;n<r;n++){t[n]=e[n*2]*256+e[n*2+1]}return LZString.decompress(String.fromCharCode.apply(null,t))}},compressToEncodedURIComponent:function(e){return LZString.compressToBase64(e).replace(/=/g,"$").replace(/\//g,"-")},decompressFromEncodedURIComponent:function(e){if(e)e=e.replace(/$/g,"=").replace(/-/g,"/");return LZString.decompressFromBase64(e)},compress:function(e){if(e==null)return"";var t,n,r={},i={},s="",o="",u="",a=2,f=3,l=2,c="",h=0,p=0,d,v=LZString._f;for(d=0;d<e.length;d+=1){s=e.charAt(d);if(!Object.prototype.hasOwnProperty.call(r,s)){r[s]=f++;i[s]=true}o=u+s;if(Object.prototype.hasOwnProperty.call(r,o)){u=o}else{if(Object.prototype.hasOwnProperty.call(i,u)){if(u.charCodeAt(0)<256){for(t=0;t<l;t++){h=h<<1;if(p==15){p=0;c+=v(h);h=0}else{p++}}n=u.charCodeAt(0);for(t=0;t<8;t++){h=h<<1|n&1;if(p==15){p=0;c+=v(h);h=0}else{p++}n=n>>1}}else{n=1;for(t=0;t<l;t++){h=h<<1|n;if(p==15){p=0;c+=v(h);h=0}else{p++}n=0}n=u.charCodeAt(0);for(t=0;t<16;t++){h=h<<1|n&1;if(p==15){p=0;c+=v(h);h=0}else{p++}n=n>>1}}a--;if(a==0){a=Math.pow(2,l);l++}delete i[u]}else{n=r[u];for(t=0;t<l;t++){h=h<<1|n&1;if(p==15){p=0;c+=v(h);h=0}else{p++}n=n>>1}}a--;if(a==0){a=Math.pow(2,l);l++}r[o]=f++;u=String(s)}}if(u!==""){if(Object.prototype.hasOwnProperty.call(i,u)){if(u.charCodeAt(0)<256){for(t=0;t<l;t++){h=h<<1;if(p==15){p=0;c+=v(h);h=0}else{p++}}n=u.charCodeAt(0);for(t=0;t<8;t++){h=h<<1|n&1;if(p==15){p=0;c+=v(h);h=0}else{p++}n=n>>1}}else{n=1;for(t=0;t<l;t++){h=h<<1|n;if(p==15){p=0;c+=v(h);h=0}else{p++}n=0}n=u.charCodeAt(0);for(t=0;t<16;t++){h=h<<1|n&1;if(p==15){p=0;c+=v(h);h=0}else{p++}n=n>>1}}a--;if(a==0){a=Math.pow(2,l);l++}delete i[u]}else{n=r[u];for(t=0;t<l;t++){h=h<<1|n&1;if(p==15){p=0;c+=v(h);h=0}else{p++}n=n>>1}}a--;if(a==0){a=Math.pow(2,l);l++}}n=2;for(t=0;t<l;t++){h=h<<1|n&1;if(p==15){p=0;c+=v(h);h=0}else{p++}n=n>>1}while(true){h=h<<1;if(p==15){c+=v(h);break}else p++}return c},decompress:function(e){if(e==null)return"";if(e=="")return null;var t=[],n,r=4,i=4,s=3,o="",u="",a,f,l,c,h,p,d,v=LZString._f,m={string:e,val:e.charCodeAt(0),position:32768,index:1};for(a=0;a<3;a+=1){t[a]=a}l=0;h=Math.pow(2,2);p=1;while(p!=h){c=m.val&m.position;m.position>>=1;if(m.position==0){m.position=32768;m.val=m.string.charCodeAt(m.index++)}l|=(c>0?1:0)*p;p<<=1}switch(n=l){case 0:l=0;h=Math.pow(2,8);p=1;while(p!=h){c=m.val&m.position;m.position>>=1;if(m.position==0){m.position=32768;m.val=m.string.charCodeAt(m.index++)}l|=(c>0?1:0)*p;p<<=1}d=v(l);break;case 1:l=0;h=Math.pow(2,16);p=1;while(p!=h){c=m.val&m.position;m.position>>=1;if(m.position==0){m.position=32768;m.val=m.string.charCodeAt(m.index++)}l|=(c>0?1:0)*p;p<<=1}d=v(l);break;case 2:return""}t[3]=d;f=u=d;while(true){if(m.index>m.string.length){return""}l=0;h=Math.pow(2,s);p=1;while(p!=h){c=m.val&m.position;m.position>>=1;if(m.position==0){m.position=32768;m.val=m.string.charCodeAt(m.index++)}l|=(c>0?1:0)*p;p<<=1}switch(d=l){case 0:l=0;h=Math.pow(2,8);p=1;while(p!=h){c=m.val&m.position;m.position>>=1;if(m.position==0){m.position=32768;m.val=m.string.charCodeAt(m.index++)}l|=(c>0?1:0)*p;p<<=1}t[i++]=v(l);d=i-1;r--;break;case 1:l=0;h=Math.pow(2,16);p=1;while(p!=h){c=m.val&m.position;m.position>>=1;if(m.position==0){m.position=32768;m.val=m.string.charCodeAt(m.index++)}l|=(c>0?1:0)*p;p<<=1}t[i++]=v(l);d=i-1;r--;break;case 2:return u}if(r==0){r=Math.pow(2,s);s++}if(t[d]){o=t[d]}else{if(d===i){o=f+f.charAt(0)}else{return null}}u+=o;t[i++]=f+o.charAt(0);r--;f=o;if(r==0){r=Math.pow(2,s);s++}}}};if(typeof module!=="undefined"&&module!=null){module.exports=LZString}
</script>
<script async defer src="//hypothes.is/embed.js"></script>
</head>
<body>
<div class='container'>
<div class='row'>
<div class='span8 col-md-8 columns eight large-8'>
<h3><a href="https://github.com/JJediny/FederalProjectSchema/blob/master/project-template.md">DRAFT FederalProjectSchema</a></h3>
<p>The form generated directly from the DRAFT FederalProjectSchema <a href="https://github.com/JJediny/json-editor">with json-editor</a></p>
<img src="jsoneditor.png" alt="json-editor">
<div id='editor'></div>
<h2>Markdown Editor</h2>
<p>The information generated from the form <b>above</b> (i.e json), can be converted into Yet Another Markup Language (.yaml or .yml). YAML is very human-readble yet can handle hierarchies/nested data within a single/flat file. YAML is commonly used by most static site generators to manage a "page's" metadata or structured content like keywords/categories/layouts/etc. or can inject this information directly into reusable html templates this is how a static site appears to be interactive. The JSON editor is used to manage/enforce data validation (ex. picking from list of pre-registered options) much like a traditional Content Management System (CMS) but without any dedicated server and database needed. The markdown (.md) created using the editor <b>below</b> can be combined (with the <b>above</b> JSON/YAML) to create a single .md file ready to be added to any Static Site.</p>
<textarea id="demo" style="display: none;"># Intro</textarea>
<script>
new SimpleMDE({
element: document.getElementById("demo"),
spellChecker: true,
autosave: {
enabled: true,
unique_id: "demo",
},
});
</script>
</div>
<div class='span4 col-md-4 columns four large-4'>
<h3>JSON Output</h3>
<p>You can also make changes to the JSON here and set the value in the editor by clicking <button class='btn btn-primary' id='setvalue'>Update Form</button></p>
<textarea id='output' style='width: 100%; height: 900px; font-family: monospace;' class='form-control'></textarea>
<h3>YAML Output (TBD)</h3>
<h3>Schema</h3>
<p>You can change the schema and see how the generated form looks. After you make changes, click <button class='btn btn-primary' id='setschema'>Update Schema</button></p>
<textarea id='schema' style='width: 100%; height: 450px; font-family: monospace;' class='form-control'></textarea>
</div>
<h2>Options</h2>
<div id='options_holder'>
<div>
<a href='#' id='direct_link'>Direct Link</a> (preserves schema, value, and options)
</div>
<form class="form-horizontal">
<div class="form-group">
<label for="sourceurl" class="col-sm-1 control-label">
Load from:
</label>
<div class="col-sm-5">
<ul id="schemas-jsons">
<h3>Datasets and Projects</h3>
<li><a href="#">data.json</a></li>
<li><a href="#">project.json</a></li>
</ul>
</div>
<div class="col-sm-5">
<ul id="hardcoded-jsons">
<h3>Project Open Data Posts</h3>
<li><a href="#">impact.md</a></li>
<li><a href="#">solution.md</a></li>
<li><a href="#">resource.md</a></li>
<li><a href="#">data.md</a></li>
</ul>
</div>
<div class="form-group">
<label for="sourceurl" class="col-sm-1 control-label">
URL:
</label>
<div class="col-sm-10 form-inline">
<input type="text" id="sourceurl" class="form-control">
<button type="submit" id="loadjson" class="btn btn-primary">Load</button>
</div>
</div>
<div class="form-group">
<div class="col-sm-1 col-sm-offset-10">
<button type="button" id="savejson" class="btn btn-danger">Save to Gist</button>
</div>
</div>
</form>
<div id="loading" class="centre-block" style="display: none">
<div class="row">
<div class="large-4" id="loadingmsg">
<h2>Loading JSON</h2> Large files take aaaaaaages.
</div>
</div>
</div>
</formset>
<div>
<label>CSS Framework</label>
<select id='theme_switcher' class='form-control'>
<option value='html'>None</option>
<option value='jqueryui'>jQuery UI</option>
<option value='bootstrap2'>Bootstrap 2</option>
<option value='bootstrap3'>Bootstrap 3</option>
<option value='bootstrap3paper'>Bootstrap 3 Paper</option>
<option value='foundation3'>Foundation 3</option>
<option value='foundation4'>Foundation 4</option>
<option value='foundation5'>Foundation 5</option>
</select>
</div>
<div>
<label>Icon Library</label>
<select id='icon_switcher' class='form-control'>
<option value=''>None</option>
<option value='jqueryui'>jQuery UI</option>
<option value='bootstrap2'>Bootstrap 2 Glyphicons</option>
<option value='bootstrap3'>Bootstrap 3 Glyphicons</option>
<option value='foundation2'>Foundicons 2</option>
<option value='foundation3'>Foundicons 3</option>
<option value='fontawesome3'>FontAwesome 3</option>
<option value='fontawesome4'>FontAwesome 4</option>
</select>
</div>
<div>
<label>Object Layout</label>
<select id='object_layout' class='form-control'>
<option value='normal'>normal</option>
<option value='grid'>grid</option>
</select>
</div>
<div>
<label>Show Errors</label>
<select id='show_errors' class='form-control'>
<option value='interaction'>On Interaction</option>
<option value='change'>On Field Change</option>
<option value='always'>Always</option>
<option value='never'>Never</option>
</select>
</div>
<div>
<label>Boolean options</label>
<select multiple size=9 id='boolean_options' style='width: 100%;' class='form-control'>
<option value='required_by_default'>Object properties required by default</option>
<option value='no_additional_properties'>No additional object properties</option>
<option value='ajax'>Allow loading schemas via Ajax</option>
<option value='disable_edit_json'>Disable "Edit JSON" buttons</option>
<option value='disable_collapse'>Disable collapse buttons</option>
<option value='disable_properties'>Disable properties buttons</option>
<option value='disable_array_add'>Disable array add buttons</option>
<option value='disable_array_reorder'>Disable array move buttons</option>
<option value='disable_array_delete'>Disable array delete buttons</option>
</select>
</div>
</div>
<h2>Validation</h2>
<p>This will update whenever the form changes to show validation errors if there are any.</p>
<textarea id='validate' style='width: 100%; height: 100px; font-family: monospace;' readonly disabled class='form-control'></textarea>
</div>
<div class='row'>
<div class='span8 col-md-8 columns eight large-8'>
</div>
<div class='span4 col-md-4 columns four large-4'>
</div>
</div>
</div>
<script>
(function() {
var schema;
if(window.location.href.match('[?&]schema=([^&]+)')) {
try {
schema = JSON.parse(LZString.decompressFromBase64(window.location.href.match('[?&]schema=([^&]+)')[1]));
}
catch(e) {
console.log('invalid starting schema');
}
}
// Default starting schema
if(!schema) {
schema = {
title: "FederalProjectSchema",
type: "object",
properties: {
title: {
title: "Title",
description: "Title or Name of the Project",
type: "string",
minLength: 10,
propertyOrder: 1
},
description: {
title: "Description",
description: "Phase or Stage of a Project",
type: "string",
description: "Abstract or Summary of the Project",
minLength: 10,
propertyOrder: 2
},
status: {
title: "Status",
description: "Phase or Stage of a Project",
type: "string",
enum: ["options","provided","through","describedBy"],
propertyOrder: 3
},
categories: {
title: "Categories",
description: "validate agaisnt a list of options",
type: "string",
enum: ["options","provided","through","describedBy"],
propertyOrder: 4
},
keywords: {
type: "array",
format: "table",
title: "Keywords",
description: "",
uniqueItems: true,
propertyOrder: 5,
items: {
type: "object",
title: "Keywords",
properties: {
keyword: {
type: "string",
title: "Keyword",
description: ""
}
}
}
},
accessLevel: {
title: "Access Level",
description: "Access Level",
type: "string",
enum: ["public", "restricted", "non-public"],
propertyOrder: 7
},
publisher: {
title: "Publisher",
description: "Organization hosting the Project",
type: "string",
minLength: 4,
propertyOrder: 8
},
publishedURL: {
title: "Publisher URL",
description: "Link to the project website or page from the source Publisher",
type: "string",
minLength: 4,
propertyOrder: 9
},
contacts: {
type: "array",
format: "tabs",
title: "Contacts",
description: "Project Team and Contributors",
uniqueItems: true,
propertyOrder: 10,
items: {
type: "object",
title: "Contact",
headerTemplate: "{{ self.email }}",
properties: {
contactType: {
type: "string",
title: "Contact Type",
enum: ["options","provided","through","describedBy"]
},
contactRole: {
type: "string",
title: "Role",
enum: ["options","provided","through","describedBy"]
},
name: {
type: "string",
title: "Full Name"
},
email: {
type: "string",
title: "Email",
description: "Use [email protected] for contact or @email.gov for organization"
},
office: {
type: "string",
title: "Office"
},
description: {
type: "string",
title: "Description"
}
}
}
},
spatial: {
type: "array",
format: "table",
title: "Spatial",
uniqueItems: true,
propertyOrder: 11,
items: {
type: "object",
title: "Spatial",
properties: {
name: {
type: "string",
title: "Name"
},
geojson: {
type: "string",
title: "Geojson",
description: "Copy/Paste or URL",
format: "geojson",
links: [
{
href: "http://geojson.io",
mediaType: "text/html"
}
]
},
latitude: {
type: "string",
title: "Latitude",
description: "WGS-84 - Only use if Geojson is unavailable"
},
longitude: {
type: "string",
title: "Longitude",
description: "WGS-84 - Only use if Geojson is unavailable"
},
address: {
type: "string",
title: "Address",
description: "Only use if Geojson is unavailable"
},
city: {
type: "string",
title: "City",
description: "Only use if Geojson is unavailable"
},
state: {
type: "string",
title: "State",
description: "Only use if Geojson is unavailable"
}
}
}
},
temporal: {
type: "array",
format: "tabs",
title: "Temporal",
description: "Duration of specific Activities",
uniqueItems: true,
propertyOrder: 12,
items: {
type: "object",
title: "Activity",
headerTemplate: "{{ self.name }},{{ self.milestoneType }}",
properties: {
activityType: {
type: "string",
title: "Activity Type",
descripton: "Discrete Process/Step/Requirement/Phase of a project",
enum: ["options","provided","through","describedBy"]
},
name: {
type: "string",
title: "Name"
},
description: {
type: "string",
title: "Description"
},
contactId: {
type: "string",
title: "Point of Contact",
description: "[email protected] for person @email.gov for org"
},
isPublic: {
type: "boolean",
title: "Public",
format: "checkbox",
default: "true",
description: "Is the activity publically viewable"
},
tasks: {
type: "array",
format: "tabs",
title: "Tasks",
description: "Tasks within a Milestone",
uniqueItems: true,
items: {
type: "object",
title: "Tasks",
headerTemplate: "{{ self.name }}",
properties: {
milestoneType: {
type: "string",
title: "Task Type",
enum: ["options","provided","through","describedBy"]
},
name: {
type: "string",
title: "Name"
},
description: {
type: "string",
title: "Description"
},
to: {
type: "string",
title: "Date from",
format: "date",
description: "YYYY-MM-DD"
},
from: {
type: "string",
title: "Date to",
format: "date",
description: "YYYY-MM-DD"
},
estimated: {
type: "string",
title: "Estimated Date",
format: "date",
description: "YYYY-MM-DD"
},
modified: {
type: "string",
title: "Date Modified",
format: "date",
descriptionv: "YYYY-MM-DDT12:00:00.000Z"
},
ontact: {
type: "string",
title: "Point of Contact",
description: "[email protected] for person @email.gov for org"
},
isPublic: {
type: "boolean",
title: "Public",
format: "checkbox",
default: "true",
description: "Is the task publically viewable",
},
isWanted: {
type: "boolean",
title: "is Wanted",
format: "checkbox",
default: "false",
description: "Is this task needed/wanted"
},
isPause: {
type: "boolean",
title: "Pause",
format: "checkbox",
default: "false",
description: "Is the task out of your control/responsibility"
}
}
}
}
}
}
},
media: {
type: "array",
format: "table",
title: "Media",
description: "Project Websites, Social Media, Feeds, Images",
uniqueItems: true,
propertyOrder: 13,
items: {
type: "object",
title: "Media",
headerTemplate: "{{ self.name }}",
properties: {
name: {
type: "string",
title: "Name"
},
url: {
type: "string",
title: "URL",
description: "Link to Site or File"
},
mediaType: {
type: "string",
title: "Media Type",
description: "File or Format",
enum: ["options","provided","through","describedBy"],
default: ""
},
attribution: {
type: "string",
title: "Attribution",
description: "Attribution Credits Rights"
}
}
}
},
resources: {
type: "array",
format: "tabs",
title: "Resources",
description: "Optional for Resources, Funds, Materials, Services for the Project",
uniqueItems: true,
propertyOrder: 14,
items: {
type: "object",
title: "Resources",
headerTemplate: "{{ self.name }}",
properties: {
resourceType: {
type: "string",
title: "Resource Type",
description: "List of Resources Categories",
enum: ["options","provided","through","describedBy"],
default: ""
},
name: {
type: "string",
title: "Name"
},
description: {
type: "string",
title: "Description"
},
contact: {
type: "string",
title: "Email",
type: "string",
description: "Use [email protected] or @email.gov for organization"
},
isPublic: {
type: "boolean",
title: "Public",
format: "checkbox",
default: "true",
description: "Is the milestone publically viewable",
},
isWanted: {
type: "boolean",
title: "is Wanted",
format: "checkbox",
description: "Is the Resource needed/wanted not yet acquired"
}
}
}
},
outcomes: {
type: "array",
format: "tabs",
title: "Outcomes",
description: "Optional for Outcomes/Impacts of the Project desired or realized",
uniqueItems: true,
propertyOrder: 14,
items: {
type: "object",
title: "Outcomes",
headerTemplate: "{{ self.name }}",
properties: {
resourceType: {
type: "string",
title: "Outcome Type",
description: "List of Resources Categories",
enum: ["options","provided","through","describedBy"],
default: ""
},
name: {
type: "string",
title: "Name",
description: ""
},
description: {
type: "string",
title: "Description"
},
isPublic: {
type: "boolean",
title: "Public",
format: "checkbox",
default: "true",
description: "Is the milestone publically viewable",
},
isWanted: {
type: "boolean",
title: "Wanted/Proposed",
format: "checkbox",
default: "false",
description: "Is the Outcome needed/wanted not yet realized"
}
}
}
},
federalData: {
type: "array",
format: "table",
title: "Federal Data",
description: "Federal Data created or used by the project on Data.gov",
uniqueItems: true,
propertyOrder: 15,
items: {
type: "object",
title: "Federal Data",
properties: {
uri: {
type: "string",
title: "URI to Data.gov",
description: "Permenant Link to Dataset on Data.gov"
},
created: {
type: "boolean",
title: "Created",
format: "checkbox",
default: "false",
description: "Was data created from the Project"
}
}
}
},
data: {
type: "array",
format: "table",
title: "Data",
description: "Non-Federal Data created or used by the project",
uniqueItems: true,
propertyOrder: 16,
items: {
type: "object",
title: "Data",
properties: {
name: {
type: "string",
title: "Name"
},
description: {
type: "string",
title: "Description"
},
url: {
type: "string",
title: "URL"
},
license: {
type: "string",
title: "License",
enum: ["Public Domain CC0","Creative Commons Share-alike","Other (use Attribution)"],
default: "Public Domain CC0"
},
attribution: {
type: "string",
title: "Attribution",
description: "Attribution Credits Rights"
},
created: {
type: "boolean",
title: "Created",
format: "checkbox",
default: "true",
description: "Was the Data Created or Produced from the Project"
}
}
}
},
isPartof: {
type: "array",
format: "table",
title: "Related Projects",
description: "isPartof implies current project is a smaller/subset to a larger project or effort uses UUID",
uniqueItems: true,
propertyOrder: 17,
items: {
type: "object",
title: "Parent Project UUID",
properties: {
parentUUID: {
type: "string",
title: "Parent UUID",
description: "isPartof implies current project is a smaller/subset to a larger project or effort use Parent UUID or URI"
}
}
}
},
conformsTo: {
title: "Federal Project Schema",
description: "Human readable documentation on schema does not yet exist - only provided as an example",
type: "string",
propertyOrder: 18,
default: "/projects/schema.json"
},
describedBy: {
title: "describedBy Schema",
description: "Extended from Federal Project Schema but provides values for dropdowns and/or can extended to add additional fields",
type: "string",
propertyOrder: 19,
default: "/projects/schema/crowdsourcing.json"
},
UUID: {
title: "UUID",
description: "UUID are Globally Unique ID used to ensure stablity in referencing and identification of Projects",
type: "string",
format: "uuid",
propertyOrder: 20
},
extended: {
type: "array",
format: "table",
title: "Extended",
description: "Custom Fields must be defined in describedBy Schema",
uniqueItems: true,
propertyOrder: 21,
items: {
type: "object",
title: "Extended",
properties: {
resourceContact: {
type: "string",
title: "Resource Contact",
description: "Use [email protected] or @email.gov for organization",
},
portionOf: {
type: "string",
title: "Portion of",
description: "Amount $ Percentage % or Portion of Total",
},
ofTotal: {
type: "string",
title: "of Total",
description: "Amount $ Percentage % of Total"
}
}
}
}
}
}
}
// Divs/textareas on the page
var $schema = document.getElementById('schema');
var $output = document.getElementById('output');
var $editor = document.getElementById('editor');
var $validate = document.getElementById('validate');
// Buttons
var $set_schema_button = document.getElementById('setschema');
var $set_value_button = document.getElementById('setvalue');
var jsoneditor;
// Global options to set on load
JSONEditor.defaults.options.disable_collapse = 'true';
var updateDirectLink = function() {
var url = window.location.href.replace(/\?.*/,'');
url += '?schema='+LZString.compressToBase64(JSON.stringify(schema));
url += '&value='+LZString.compressToBase64(JSON.stringify(jsoneditor.getValue()));
for(var i in JSONEditor.defaults.options) {
if(!JSONEditor.defaults.options.hasOwnProperty(i)) continue;
if(JSONEditor.defaults.options[i]===false) continue;
else if(JSONEditor.defaults.options[i]===true) {
url += '&'+i;
}
else {
url += '&'+i+'='+JSONEditor.defaults.options[i];
}
}
document.getElementById('direct_link').href = url;
};
var reload = function(keep_value) {
var startval = (jsoneditor && keep_value)? jsoneditor.getValue() : window.startval;
window.startval = undefined;
if(jsoneditor) jsoneditor.destroy();
jsoneditor = new JSONEditor($editor,{
schema: schema,
ajax: true,
keep_oneof_values: false,
startval: startval
});
window.jsoneditor = jsoneditor;
// When the value of the editor changes, update the JSON output and validation message
jsoneditor.on('change',function() {
var json = jsoneditor.getValue();
$output.value = JSON.stringify(json,null,2);
var validation_errors = jsoneditor.validate();
// Show validation errors if there are any
if(validation_errors.length) {
$validate.value = JSON.stringify(validation_errors,null,2);
}
else {
$validate.value = 'valid';
}
updateDirectLink();
});
};
// Start the schema and output textareas with initial values
$schema.value = JSON.stringify(schema,null,2);
$output.value = '';
// When the 'update form' button is clicked, set the editor's value
$set_value_button.addEventListener('click',function() {
jsoneditor.setValue(JSON.parse($output.value));
});
// Update the schema when the button is clicked
$set_schema_button.addEventListener('click',function() {
try {
schema = JSON.parse($schema.value);
}
catch(e) {
alert('Invalid Schema: '+e.message);
return;
}
reload();
});
// Set the theme by loading the right stylesheets
var setTheme = function(theme,no_reload) {
theme = theme || '';
var mapping = {
html: '',
bootstrap2: '//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css',
bootstrap3: '//bootswatch.com/paper/bootstrap.min.css',
foundation3: '//cdnjs.cloudflare.com/ajax/libs/foundation/3.2.5/stylesheets/foundation.css',
foundation4: '//cdn.jsdelivr.net/foundation/4.3.2/css/foundation.min.css',
foundation5: '//cdn.jsdelivr.net/foundation/5.0.2/css/foundation.min.css',
jqueryui: '//code.jquery.com/ui/1.10.3/themes/south-street/jquery-ui.css'
};
if(typeof mapping[theme] === 'undefined') {
theme = 'bootstrap3';
document.getElementById('theme_switcher').value = theme;
}
JSONEditor.defaults.options.theme = 'bootstrap3';
document.getElementById('theme_stylesheet').href = mapping[theme];
document.getElementById('theme_switcher').value = JSONEditor.defaults.options.theme;
if(!no_reload) reload(true);
};
// Set the icontheme
// Set the theme by loading the right stylesheets
var setIconlib = function(iconlib,no_reload) {
iconlib = iconlib || '';
var mapping = {
foundation2: '//cdnjs.cloudflare.com/ajax/libs/foundicons/2.0/stylesheets/general_foundicons.css',
foundation3: '//cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.css',
fontawesome3: '//cdnjs.cloudflare.com/ajax/libs/font-awesome/3.2.1/css/font-awesome.css',
fontawesome4: '//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.0.3/css/font-awesome.css'
};
JSONEditor.defaults.options.iconlib = 'bootstrap3';
document.getElementById('icon_stylesheet').href = mapping[iconlib] || '';
document.getElementById('icon_switcher').value = JSONEditor.defaults.options.iconlib;
if(!no_reload) reload(true);
};
var refreshBooleanOptions = function(no_reload) {
var boolean_options = document.getElementById('boolean_options').children;
for(var i=0; i<boolean_options.length; i++) {
JSONEditor.defaults.options[boolean_options[i].value] = boolean_options[i].selected;
}
if(!no_reload) reload(true);
};
// Change listeners for options
document.getElementById('theme_switcher').addEventListener('change',function() {
setTheme(this.value);
});
document.getElementById('icon_switcher').addEventListener('change',function() {
setIconlib(this.value);
});
document.getElementById('object_layout').addEventListener('change',function() {
JSONEditor.defaults.options.object_layout = this.value;
reload(true);
});
document.getElementById('show_errors').addEventListener('change',function() {
JSONEditor.defaults.options.show_errors = this.value;
reload(true);
});
document.getElementById('boolean_options').addEventListener('change',function() {
refreshBooleanOptions();
});
// Get starting value from url
if(window.location.href.match('[?&]value=([^&]+)')) {
window.startval = JSON.parse(LZString.decompressFromBase64(window.location.href.match('[?&]value=([^&]+)')[1]));
}
// Set options from direct link
setTheme((window.location.href.match(/[?&]theme=([^&]+)/)||[])[1] || 'bootstrap3', true);
setIconlib((window.location.href.match(/[?&]iconlib=([^&]*)/)||[null,'bootstrap3'])[1], true);
document.getElementById('object_layout').value = (window.location.href.match(/[?&]object_layout=([^&]+)/)||[])[1] || 'normal';
JSONEditor.defaults.options.object_layout = document.getElementById('object_layout').value;
document.getElementById('show_errors').value = (window.location.href.match(/[?&]show_errors=([^&]+)/)||[])[1] || 'interaction';
JSONEditor.defaults.options.show_errors = document.getElementById('show_errors').value;
var boolean_options = document.getElementById('boolean_options').children;
for(var i=0; i<boolean_options.length; i++) {
if(window.location.href.match(new RegExp('[?&]'+boolean_options[i].getAttribute('value')+'([&=]|$)'))) {
boolean_options[i].selected = true;
}
}
refreshBooleanOptions(true);
reload();
})();
</script>
</body>
</html>