-
Notifications
You must be signed in to change notification settings - Fork 0
/
ccm.metadata_generator.js
1199 lines (1139 loc) · 52.9 KB
/
ccm.metadata_generator.js
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
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @overview ccm metadata generator to create metadata for components and configurations
* @author Leon Eck <[email protected]> 2018
* @license The MIT License (MIT)
*/
{
var component = {
/**
* unique component name
* @type {string}
*/
name: 'metadata_generator',
/**
* recommended used framework version
* @type {string}
*/
ccm: 'js/ccm-18.0.5.js',
/**
* default instance configuration
* @type {{}}
*/
config: {
html: {
"main": {
"id": "main",
"class": "container bootfont",
"inner": [
{
"inner": `
<div class="row">
<div class="col-md-8">
<h1>Metadata Generator</h1>
<p><em>ccm</em> Metadata Version <span class="label label-primary">ccm-meta 1.0.0</span></p>
<p class="lead removeOnEmbed">Activate fields with their checkboxes. All changes will be visible live in the <a href="javascript: document.body.scrollIntoView(false);">Result</a> panel at the bottom of the page.</p>
</div>
<div class="col-md-4">
<div class="panel panel-default top-buffer">
<div class="panel-body" style="display: flex; justify-content: space-between;">
<button class="btn btn-default" id="activateAllFields">Activate all fields</button>
<button class="btn btn-default" id="deactivateAllFields">Deactivate all fields</button>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="form-group">
<label for="inputTitle">Title</label> <span class="example-text">Example: Hello World</span>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" id="includeTitle" class="metaFieldCheckbox">
</span>
<input type="text" class="form-control" id="inputTitle">
</div>
<p class="help-block">Title of the resource.</p>
</div>
<div class="form-group">
<label for="inputVersion">Version</label> <span class="example-text">Example: 1.0.0</span>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" id="includeVersion" class="metaFieldCheckbox">
</span>
<input type="text" class="form-control" id="inputVersion">
</div>
<p class="help-block">Version number of the resource. Please use <a href="https://semver.org/" target="_blank">Semantic Versioning</a></p>
</div>
<div class="form-group">
<label for="inputCreator">Creator</label> <span class="example-text">Example: John Doe</span>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" id="includeCreator" class="metaFieldCheckbox">
</span>
<input type="text" class="form-control" id="inputCreator">
</div>
<p class="help-block">An entity primarily responsible for making the resource. Multiple creators can be separated by commas(,).</p>
</div>
<div class="form-group">
<label for="inputSubject">Subject</label> <span class="example-text">Example: Programming</span>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" id="includeSubject" class="metaFieldCheckbox">
</span>
<input type="text" class="form-control" id="inputSubject">
</div>
<p class="help-block">Topic of the resource.</p>
</div>
<div class="form-group">
<label for="inputDescription">Description</label> <span class="example-text">Example: This resource is about...</span>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" id="includeDescription" class="metaFieldCheckbox">
</span>
<textarea class="form-control" rows="3" id="inputDescription"></textarea>
</div>
<p class="help-block">Description of the resource.</p>
</div>
<div class="form-group">
<label for="inputPublisher">Publisher</label> <span class="example-text">Example: John Doe</span>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" id="includePublisher" class="metaFieldCheckbox">
</span>
<input type="text" class="form-control" id="inputPublisher">
</div>
<p class="help-block">An entity responsible for making the resource available. Multiple publishers can be separated by commas(,).</p>
</div>
<div class="form-group">
<label for="inputContributor">Contributor</label> <span class="example-text">Example: John Doe</span>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" id="includeContributor" class="metaFieldCheckbox">
</span>
<input type="text" class="form-control" id="inputContributor">
</div>
<p class="help-block">An entity responsible for making contributions to the resource. Multiple contributors can be separated by commas(,).</p>
</div>
<div class="form-group">
<label for="inputDate">Date <button type="button" class="btn btn-default btn-circle tooltip-toggle" data-balloon-length="large" data-balloon="If your browser provides a datepicker please use it. Otherwise stick to the format YYYY-MM-DD" data-balloon-pos="right">
<span class="info-icon">ℹ</span>
</button></label> <span class="example-text">Example: ${new Date().toISOString().split('T')[0]}</span>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" id="includeDate" class="metaFieldCheckbox">
</span>
<input type="date" class="form-control" id="inputDate" value="${new Date().toISOString().split('T')[0]}">
</div>
<p class="help-block">The date the resource was published. Format: YYYY-MM-DD</p>
</div>
<div class="form-group">
<label for="inputFormat">Format <button type="button" class="btn btn-default btn-circle tooltip-toggle" data-balloon-length="large" data-balloon="If the metadata is applied to a component, choose application/javascript. If it's applied to a configuration choose application/json." data-balloon-pos="right">
<span class="info-icon">ℹ</span>
</button></label>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" id="includeFormat" class="metaFieldCheckbox">
</span>
<select class="form-control" id="inputFormat">
<option value="application/javascript" selected>application/javascript</option>
<option value="application/json">application/json</option>
</select>
</div>
<p class="help-block">The file format of the resource.</p>
</div>
<div class="form-group">
<label for="inputIdentifier">Identifier <button type="button" class="btn btn-default btn-circle tooltip-toggle" data-balloon-length="large" data-balloon="If you already have a unique identifier for the resource, use that one. Otherwise please generate one." data-balloon-pos="right">
<span class="info-icon">ℹ</span>
</button></label> <span class="example-text">Example: da3581d3-7a46-4b87-882c-935c371c3078</span>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" id="includeIdentifier" class="metaFieldCheckbox">
</span>
<input type="text" class="form-control" id="inputIdentifier">
<span class="input-group-btn">
<button type="button" id="buttonGenerateIdentifier" class="btn btn-default">Generate</button>
</span>
</div>
<p class="help-block">An unambiguous reference to the resource within a given context.</p>
</div>
<div class="form-group">
<label for="inputPath-component">Path-Component <button type="button" class="btn btn-default btn-circle tooltip-toggle" data-balloon-length="large" data-balloon="If the metadata is applied to a configuration, you could specify a URL to the component file that reads the configuration here." data-balloon-pos="right">
<span class="info-icon">ℹ</span>
</button></label> <span class="example-text">Example: https://example.com/ccm.hello_world.js</span>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" id="includePath-component" class="metaFieldCheckbox">
</span>
<input type="url" class="form-control" id="inputPath-component">
</div>
<p class="help-block">URL where the component can be found.</p>
</div>
<div class="panel panel-default">
<div class="panel-body">
<div class="form-group">
<label for="inputPath-config">Path-Config <button type="button" class="btn btn-default btn-circle tooltip-toggle" data-balloon-length="large" data-balloon="If the metadata is applied to a component, you could specify a URL to a configuration file here." data-balloon-pos="right">
<span class="info-icon">ℹ</span>
</button></label> <span class="example-text">Example: https://example.com/configs.js</span>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" id="includePath-config" class="metaFieldCheckbox">
</span>
<input type="url" class="form-control" id="inputPath-config">
</div>
<p class="help-block">URL where the configuration can be found.</p>
</div>
<div class="form-group">
<label for="inputConfig-key">Config-Key</label> <span class="example-text">Example: demo</span>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" id="includeConfig-key" class="metaFieldCheckbox">
</span>
<input class="form-control" id="inputConfig-key">
</div>
<p class="help-block">A key that defines where the data is found inside the resource that is mentioned in the <samp>path-config</samp> field.</p>
</div>
</div>
</div>
<div class="form-group">
<label for="inputSource">Source</label> <span class="example-text">Example: https://example.com/ccm.source.js</span>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" id="includeSource" class="metaFieldCheckbox">
</span>
<input type="url" class="form-control" id="inputSource">
</div>
<p class="help-block">URL to a related resource from which this resource is derived.</p>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<div class="checkbox no-margin">
<label>
<input type="checkbox" id="includeLanguage" value="includeLanguage" class="metaFieldCheckbox">
<h3 class="panel-title">
Language
</h3>
</label>
<button type="button" class="btn btn-default btn-circle tooltip-toggle" data-balloon-length="medium" data-balloon="Select all languages that the resource supports." data-balloon-pos="right">
<span class="info-icon">ℹ</span>
</button>
</div>
</div>
<div class="panel-body">
<select id="inputLanguage" multiple></select>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<div class="checkbox no-margin">
<label>
<input type="checkbox" id="includeLicenses" value="includeLicenses" class="metaFieldCheckbox">
<h3 class="panel-title">
License
</h3>
</label>
<button type="button" class="btn btn-default btn-circle tooltip-toggle" data-balloon-length="medium" data-balloon="Licenses are split between software and content." data-balloon-pos="right">
<span class="info-icon">ℹ</span>
</button>
</div>
</div>
<div class="panel-body">
<div class="panel panel-default">
<div class="panel-heading">
<div class="checkbox no-margin">
<label>
<input type="checkbox" id="includeSoftwareLicense" value="includeSoftwareLicense" class="metaFieldCheckbox">
<h3 class="panel-title">
Software
</h3>
</label>
</div>
</div>
<div class="panel-body">
<label class="control-label">Choose a software license</label>
<form class="form-inline" role="form">
<div class="form-group">
<div class="radio">
<label class="radio-inline control-label">
<input type="radio" name="software_license_choose" id="software_license_choose_6" value="MIT"> MIT License (MIT) <span class="label label-success">Recommended</span>
</label>
</div>
</div>
<div class="form-group">
<div class="radio">
<label class="radio-inline control-label">
<input type="radio" name="software_license_choose" id="software_license_choose_1" value="AGPL"> GNU Affero General Public License (AGPL)
</label>
</div>
</div>
<div class="form-group">
<div class="radio">
<label class="radio-inline control-label">
<input type="radio" name="software_license_choose" id="software_license_choose_2" value="GPL"> GNU General Public License (GPL)
</label>
</div>
</div>
<div class="form-group">
<div class="radio">
<label class="radio-inline control-label">
<input type="radio" name="software_license_choose" id="software_license_choose_3" value="LGPL"> GNU Lesser General Public License (LGPL)
</label>
</div>
</div>
<div class="form-group">
<div class="radio">
<label class="radio-inline control-label">
<input type="radio" name="software_license_choose" id="software_license_choose_4" value="MPL"> Mozilla Public License (MPL)
</label>
</div>
</div>
<div class="form-group">
<div class="radio">
<label class="radio-inline control-label">
<input type="radio" name="software_license_choose" id="software_license_choose_5" value="Apache"> Apache License (Apache)
</label>
</div>
</div>
<div class="form-group">
<div class="radio">
<label class="radio-inline control-label">
<input type="radio" name="software_license_choose" id="software_license_choose_7" value="Unlicense"> The Unlicense (Unlicense)
</label>
</div>
</div>
<div class="form-group">
<div class="radio">
<label class="radio-inline control-label">
<input type="radio" name="software_license_choose" id="software_license_choose_8" value="other">
Other:
</label>
</div>
</div>
<div class="form-group">
<input placeholder="Other license" type="text" class="form-control" id="other_software_license">
</div>
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<div class="checkbox no-margin">
<label>
<input type="checkbox" id="includeContentLicense" value="includeContentLicense" class="metaFieldCheckbox">
<h3 class="panel-title">
Content
</h3>
</label>
</div>
</div>
<div class="panel-body">
<label class="control-label">Choose a content license</label>
<form class="form-inline" role="form">
<div class="form-group">
<div class="radio">
<label class="radio-inline control-label">
<input type="radio" name="content_license_choose" id="content_license_choose_1" value="CC-BY-4.0"> Creative Commons Attribution 4.0 International (CC-BY-4.0) <span class="label label-success">Recommended</span>
</label>
</div>
</div>
<div class="form-group">
<div class="radio">
<label class="radio-inline control-label">
<input type="radio" name="content_license_choose" id="content_license_choose_2" value="CC-BY-SA-4.0"> Creative Commons Attribution Share Alike 4.0 International (CC-BY-SA-4.0)
</label>
</div>
</div>
<div class="form-group">
<div class="radio">
<label class="radio-inline control-label">
<input type="radio" name="content_license_choose" id="content_license_choose_3" value="CC-BY-ND-4.0"> Creative Commons Attribution No Derivatives 4.0 International (CC-BY-ND-4.0)
</label>
</div>
</div>
<div class="form-group">
<div class="radio">
<label class="radio-inline control-label">
<input type="radio" name="content_license_choose" id="content_license_choose_4" value="CC-BY-NC-4.0"> Creative Commons Attribution Non Commercial 4.0 International (CC-BY-NC-4.0)
</label>
</div>
</div>
<div class="form-group">
<div class="radio">
<label class="radio-inline control-label">
<input type="radio" name="content_license_choose" id="content_license_choose_5" value="CC-BY-NC-SA-4.0"> Creative Commons Attribution Non Commercial Share Alike 4.0 International (CC-BY-NC-SA-4.0)
</label>
</div>
</div>
<div class="form-group">
<div class="radio">
<label class="radio-inline control-label">
<input type="radio" name="content_license_choose" id="content_license_choose_6" value="CC-BY-NC-ND-4.0"> Creative Commons Attribution Non Commercial No Derivatives 4.0 International (CC-BY-NC-ND-4.0)
</label>
</div>
</div>
<div class="form-group">
<div class="radio">
<label class="radio-inline control-label">
<input type="radio" name="content_license_choose" id="content_license_choose_7" value="other">
Other:
</label>
</div>
</div>
<div class="form-group">
<input placeholder="Other license" type="text" class="form-control" id="other_content_license">
</div>
</form>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<div class="checkbox no-margin">
<label>
<input type="checkbox" id="includeTags" value="includeTags" class="metaFieldCheckbox">
<h3 class="panel-title">
Tags
</h3>
</label>
<button type="button" class="btn btn-default btn-circle tooltip-toggle" data-balloon-length="medium" data-balloon="Add tags that describe the resource." data-balloon-pos="right">
<span class="info-icon">ℹ</span>
</button>
</div>
</div>
<div class="panel-body">
<select id="inputTags" multiple></select>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<div class="checkbox no-margin">
<label>
<input type="checkbox" id="includeCategory" value="includeCategory" class="metaFieldCheckbox">
<h3 class="panel-title">
Category
</h3>
</label>
<button type="button" class="btn btn-default btn-circle tooltip-toggle" data-balloon-length="medium" data-balloon="Specify a category that best suits the resource." data-balloon-pos="right">
<span class="info-icon">ℹ</span>
</button>
</div>
</div>
<div class="panel-body">
<select id="inputCategory"></select>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<div class="checkbox no-margin">
<label>
<input type="checkbox" id="includeBloomTaxonomy" value="includeBloomTaxonomy" class="metaFieldCheckbox">
<h3 class="panel-title">
Bloom’s Taxonomy
</h3>
</label>
</div>
</div>
<div class="panel-body">
<select id="inputBloomTaxonomy"></select>
<p class="help-block no-margin">
The revised form of Bloom’s Taxonomy is used. You can find out more about it <a href="https://cft.vanderbilt.edu/guides-sub-pages/blooms-taxonomy/" target="_blank">here</a>, <a href="https://tips.uark.edu/using-blooms-taxonomy/" target="_blank">here</a> and <a href="http://sciencesite.16mb.com/Bloom's%20Taxonomy%20Original%20and%20Revised%20by%20Mary%20Forehand.pdf" target="_blank">here</a>.
</p>
</div>
</div>
</div>
</div>
<div class="row removeOnEmbed">
<div class="col-xs-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
Result
</h3>
</div>
<div class="panel-body">
<form class="form-inline" style="margin-bottom: 15px;">
<button class="btn btn-default" id="buttonCopyResultToClipboard">Copy result to clipboard</button>
<button class="btn btn-default pull-right" onclick="event.preventDefault(); document.body.scrollIntoView(true);">Go to top</button>
</form>
<pre><samp id="resultDisplay">{}</samp></pre>
</div>
</div>
</div>
</div>
<div class="row top-buffer">
<blockquote>
<p class="small">Part of the metadata is derived from <a href="http://www.dublincore.org">dublincore.org</a></p>
</blockquote>
</div>
`
}
]
}
},
css: [ 'ccm.load', [ 'css/bootstrap.min.css', 'css/balloon.min.css', 'css/selectize.default.min.css', 'css/default.css' ] ],
js: [ 'ccm.load', [ 'js/jquery.min.js', 'js/bootstrap.min.js', 'js/selectize.min.js' ] ],
no_bootstrap_container: false, // Set to true if embedded on a site that already has a bootstrap container div
embedded: false, // Set to true when this component is embedded in another website and this site handles the result. This will hide the results panel
categories: [ 'Anthropology', 'Art', 'Astronomy', 'Biology', 'Chemistry', 'Classic culture', 'Computer Science', 'Craft', 'Design', 'Economy', 'Emotional education', 'Engineering', 'English', 'Environment', 'Experimental sciences', 'French', 'General Studies', 'Geography', 'Geology', 'German', 'Health', 'History', 'Italian', 'Language', 'Latin', 'Laws', 'Literature', 'Mathematics', 'Music', 'Others', 'Pedagogy', 'Philosophy', 'Physical education', 'Physics', 'Politics', 'Psychology', 'Religion', 'Russian', 'Social sciences', 'Spanish', 'Sport', 'Teaching Tools', 'Technical Drawing', 'Technology', 'Values education', 'Vocational education' ], // Categories the user can choose from
},
/**
* for creating instances of this component
* @constructor
*/
Instance: function() {
/**
* own reference for inner functions
* @type {Instance}
*/
const self = this;
/**
* Stores which part of the metadata are active
* @type {{}}
*/
let metadataActive = {
"title": false,
"version": false,
"creator": false,
"subject": false,
"description": false,
"publisher": false,
"contributor": false,
"date": false,
"format": false,
"identifier": false,
"path-component": false,
"path-config": false,
"config-key": false,
"source": false,
"language": false,
"license": {
"self": false,
"software": false,
"content": false
},
"tags": false,
"category": false,
"bloomTaxonomy": false
};
/**
* Stores the metadata from currently selected options, even the disabled ones
* @type {{}}
*/
let metadataStore = {
"metaFormat": "ccm-meta",
"metaVersion": "1.0.0",
"title": "",
"version": "",
"creator": "",
"subject": "",
"description": "",
"publisher": "",
"contributor": "",
"date": new Date().toISOString().split('T')[0],
"format": "application/javascript",
"identifier": "",
"path-component": "",
"path-config": "",
"config-key": "",
"source": "",
"language": "",
"license": {
"software": "",
"content": ""
},
"tags": "",
"category": "",
"bloomTaxonomy": ""
};
/**
* Contains only the activated parts of the metadata
* @type {{}}
*/
let resultingMetadata = {};
const languages = {
"ab": "Abkhazian",
"aa": "Afar",
"af": "Afrikaans",
"ak": "Akan",
"sq": "Albanian",
"am": "Amharic",
"ar": "Arabic",
"an": "Aragonese",
"hy": "Armenian",
"as": "Assamese",
"av": "Avaric",
"ae": "Avestan",
"ay": "Aymara",
"az": "Azerbaijani",
"bm": "Bambara",
"ba": "Bashkir",
"eu": "Basque",
"be": "Belarusian",
"bn": "Bengali (Bangla)",
"bh": "Bihari",
"bi": "Bislama",
"bs": "Bosnian",
"br": "Breton",
"bg": "Bulgarian",
"my": "Burmese",
"ca": "Catalan",
"ch": "Chamorro",
"ce": "Chechen",
"ny": "Chichewa, Chewa, Nyanja",
"zh": "Chinese",
"cv": "Chuvash",
"kw": "Cornish",
"co": "Corsican",
"cr": "Cree",
"hr": "Croatian",
"cs": "Czech",
"da": "Danish",
"dv": "Divehi, Dhivehi, Maldivian",
"nl": "Dutch",
"dz": "Dzongkha",
"en": "English",
"eo": "Esperanto",
"et": "Estonian",
"ee": "Ewe",
"fo": "Faroese",
"fj": "Fijian",
"fi": "Finnish",
"fr": "French",
"ff": "Fula, Fulah, Pulaar, Pular",
"gl": "Galician",
"gd": "Gaelic (Scottish)",
"gv": "Gaelic (Manx)",
"ka": "Georgian",
"de": "German",
"el": "Greek",
"kl": "Greenlandic",
"gn": "Guarani",
"gu": "Gujarati",
"ht": "Haitian Creole",
"ha": "Hausa",
"he": "Hebrew",
"hz": "Herero",
"hi": "Hindi",
"ho": "Hiri Motu",
"hu": "Hungarian",
"is": "Icelandic",
"io": "Ido",
"ig": "Igbo",
"id": "Indonesian",
"ia": "Interlingua",
"ie": "Interlingue",
"iu": "Inuktitut",
"ik": "Inupiak",
"ga": "Irish",
"it": "Italian",
"ja": "Japanese",
"jv": "Javanese",
"kn": "Kannada",
"kr": "Kanuri",
"ks": "Kashmiri",
"kk": "Kazakh",
"km": "Khmer",
"ki": "Kikuyu",
"rw": "Kinyarwanda (Rwanda)",
"rn": "Kirundi",
"ky": "Kyrgyz",
"kv": "Komi",
"kg": "Kongo",
"ko": "Korean",
"ku": "Kurdish",
"kj": "Kwanyama",
"lo": "Lao",
"la": "Latin",
"lv": "Latvian (Lettish)",
"li": "Limburgish (Limburger)",
"ln": "Lingala",
"lt": "Lithuanian",
"lu": "Luga-Katanga",
"lg": "Luganda, Ganda",
"lb": "Luxembourgish",
"mk": "Macedonian",
"mg": "Malagasy",
"ms": "Malay",
"ml": "Malayalam",
"mt": "Maltese",
"mi": "Maori",
"mr": "Marathi",
"mh": "Marshallese",
"mo": "Moldavian",
"mn": "Mongolian",
"na": "Nauru",
"nv": "Navajo",
"ng": "Ndonga",
"nd": "Northern Ndebele",
"ne": "Nepali",
"no": "Norwegian",
"nb": "Norwegian bokmål",
"nn": "Norwegian nynorsk",
"ii": "Nuosu",
"oc": "Occitan",
"oj": "Ojibwe",
"cu": "Old Church Slavonic, Old Bulgarian",
"or": "Oriya",
"om": "Oromo (Afaan Oromo)",
"os": "Ossetian",
"pi": "Pāli",
"ps": "Pashto, Pushto",
"fa": "Persian (Farsi)",
"pl": "Polish",
"pt": "Portuguese",
"pa": "Punjabi (Eastern)",
"qu": "Quechua",
"rm": "Romansh",
"ro": "Romanian",
"ru": "Russian",
"se": "Sami",
"sm": "Samoan",
"sg": "Sango",
"sa": "Sanskrit",
"sr": "Serbian",
"sh": "Serbo-Croatian",
"st": "Sesotho",
"tn": "Setswana",
"sn": "Shona",
"sd": "Sindhi",
"si": "Sinhalese",
"ss": "Siswati",
"sk": "Slovak",
"sl": "Slovenian",
"so": "Somali",
"nr": "Southern Ndebele",
"es": "Spanish",
"su": "Sundanese",
"sw": "Swahili (Kiswahili)",
"sv": "Swedish",
"tl": "Tagalog",
"ty": "Tahitian",
"tg": "Tajik",
"ta": "Tamil",
"tt": "Tatar",
"te": "Telugu",
"th": "Thai",
"bo": "Tibetan",
"ti": "Tigrinya",
"to": "Tonga",
"ts": "Tsonga",
"tr": "Turkish",
"tk": "Turkmen",
"tw": "Twi",
"ug": "Uyghur",
"uk": "Ukrainian",
"ur": "Urdu",
"uz": "Uzbek",
"ve": "Venda",
"vi": "Vietnamese",
"vo": "Volapük",
"wa": "Wallon",
"cy": "Welsh",
"wo": "Wolof",
"fy": "Western Frisian",
"xh": "Xhosa",
"yi": "Yiddish",
"yo": "Yoruba",
"za": "Zhuang, Chuang",
"zu": "Zulu"
};
/**
* starts the instance
*/
this.start = async () => {
/**
* Remove the bootstrap container class if config value no_bootstrap_container is true
*/
if (self.no_bootstrap_container) {
this.html.main.class = '';
}
const mainElement = this.ccm.helper.html(this.html.main, {
});
this.element.appendChild(mainElement);
/**
* Remove elements that should not be available when the component is embedded in another website
*/
if (self.embedded) {
mainElement.querySelectorAll('.removeOnEmbed').forEach(element => {
element.parentNode.removeChild(element);
});
}
/**
* Make example text selectable with one click
*/
mainElement.querySelectorAll('.example-text').forEach(element => {
element.addEventListener('click', function (event) {
event.preventDefault();
copyToClipboard(this.innerHTML.replace('Example: ', ''));
})
});
/**
* Initialize the language input
*/
let languageOptions = [];
Object.keys(languages).forEach(key => {
languageOptions.push({
value: key,
label: languages[key]
});
});
const languageSelector = $(mainElement.querySelector('#inputLanguage')).selectize({
delimiter: ',',
persist: false,
create: false,
plugins: ['remove_button'],
maxItems: null,
placeholder: 'Select languages...',
valueField: 'value',
labelField: 'label',
searchField: 'label',
options: languageOptions
})[0].selectize;
/**
* Initialize the tag input
*/
let tagOptions = [];
const tagSelector = $(mainElement.querySelector('#inputTags')).selectize({
delimiter: ',',
persist: false,
create: true,
plugins: ['remove_button'],
maxItems: null,
placeholder: 'Add tags...',
valueField: 'value',
labelField: 'value',
searchField: 'value',
options: tagOptions
})[0].selectize;
/**
* Initialize the category input
*/
let categoryOptions = [];
self.categories.forEach(category => {
categoryOptions.push({
value: category
});
});
const categorySelector = $(mainElement.querySelector('#inputCategory')).selectize({
persist: false,
create: false,
maxItems: 1,
placeholder: 'Select a category that suits the resource',
valueField: 'value',
labelField: 'value',
searchField: 'value',
options: categoryOptions
})[0].selectize;
/**
* Initialize the bloom taxonomy input
*/
let bloomTaxonomyOptions = [
{
value: 'Remember'
},
{
value: 'Understand'
},
{
value: 'Apply'
},
{
value: 'Analyze'
},
{
value: 'Evaluate'
},
{
value: 'Create'
}
];
const bloomTaxonomySelector = $(mainElement.querySelector('#inputBloomTaxonomy')).selectize({
persist: false,
create: false,
maxItems: 1,
placeholder: 'Select the highest level that applies to the resource',
valueField: 'value',
labelField: 'value',
searchField: 'value',
options: bloomTaxonomyOptions
})[0].selectize;
generateResult();
mainElement.querySelector('#activateAllFields').addEventListener('click', function() {
mainElement.querySelectorAll('.metaFieldCheckbox').forEach(checkbox => {
checkbox.checked = true;
const event = document.createEvent('HTMLEvents');
event.initEvent('change', false, true);
checkbox.dispatchEvent(event);
});
generateResult();
});
mainElement.querySelector('#deactivateAllFields').addEventListener('click', function() {
mainElement.querySelectorAll('.metaFieldCheckbox').forEach(checkbox => {
checkbox.checked = false;
const event = document.createEvent('HTMLEvents');
event.initEvent('change', false, true);
checkbox.dispatchEvent(event);
});
generateResult();
});
if (!self.embedded) {
mainElement.querySelector('#buttonCopyResultToClipboard').addEventListener('click', function (event) {
event.preventDefault();
copyToClipboard(generateResult());
});
}
/**
* Adds event listeners for checkbox and input of a field
* @param key Key in lowercase
*/
function createEventListenersForField(key) {
mainElement.querySelector('#include' + capitalizeFirstLetter(key.toLowerCase())).addEventListener('change', function() {
metadataActive[key] = this.checked;
generateResult();
});
mainElement.querySelector('#input' + capitalizeFirstLetter(key.toLowerCase())).addEventListener('input', function() {
metadataStore[key] = this.value;
generateResult();
});
}
createEventListenersForField('title');
createEventListenersForField('version');
createEventListenersForField('creator');
createEventListenersForField('subject');
createEventListenersForField('description');
createEventListenersForField('publisher');
createEventListenersForField('contributor');
createEventListenersForField('date');
createEventListenersForField('format');
createEventListenersForField('identifier');
createEventListenersForField('path-component');
createEventListenersForField('path-config');
createEventListenersForField('config-key');
createEventListenersForField('source');
mainElement.querySelector('#buttonGenerateIdentifier').addEventListener('click', function() {
const inputIdentifier = mainElement.querySelector('#inputIdentifier');
inputIdentifier.value = uuidv4();
const event = document.createEvent('HTMLEvents');
event.initEvent('input', false, true);
inputIdentifier.dispatchEvent(event);
generateResult();
});
mainElement.querySelector('#includeLanguage').addEventListener('change', function() {
metadataActive.language = this.checked;
generateResult();
});
languageSelector.on('change', () => {
metadataStore.language = languageSelector.getValue().join(', ');
generateResult();
});
mainElement.querySelector('#includeLicenses').addEventListener('change', function() {
metadataActive.license.self = this.checked;
generateResult();
});
mainElement.querySelector('#includeSoftwareLicense').addEventListener('change', function() {
metadataActive.license.software = this.checked;
generateResult();
});
mainElement.querySelector('#includeContentLicense').addEventListener('change', function() {
metadataActive.license.content = this.checked;
generateResult();
});
Array.from(mainElement.querySelectorAll('input[name=software_license_choose]')).forEach(radio => {
radio.addEventListener('change', function () {
switch (this.value) {
case 'AGPL':
metadataStore.license.software = 'AGPL-3.0-only';
break;
case 'GPL':
metadataStore.license.software = 'GPL-3.0-only';
break;
case 'LGPL':
metadataStore.license.software = 'LGPL-3.0-only';
break;
case 'MPL':
metadataStore.license.software = 'MPL-2.0';
break;
case 'Apache':
metadataStore.license.software = 'Apache-2.0';
break;
case 'MIT':
metadataStore.license.software = 'MIT';
break;
case 'Unlicense':