-
Notifications
You must be signed in to change notification settings - Fork 9
/
stable.html
4888 lines (3985 loc) · 253 KB
/
stable.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
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
<!DOCTYPE html><html lang="en">
<head>
<meta http-equiv="Content-Type" charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
<meta name="description"
content="DataPLAN can generate a data management plan for Horizon 2020, Horizon Europe, DFG, BMBF and BBSRC in minutes. The DMPs generated by DataPLAN include relevant metadata standards and endpoint repositories. This tool aims to be a time saving and easy-to-use tool to create data management documents.">
<meta name="keywords" content="DataPLAN, Horizon Europe, dfg, FAIR, data management plan, DMP, free, open-source">
<!-- disable cache across browsers for testing purpose -->
<meta http-equiv="Expires" content="0" />
<title>DataPLAN | Easily Generate a Data Management Plan </title>
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<!-- loading css styleSheets -->
<link href="css/bootstrap.min2106.css" rel="stylesheet" />
<link href="css/bs5-intro-tour2106.css" rel="stylesheet" />
<script src="DMPDocs/BBSRC-dmp-2024-11-14.js" type="text/javascript" charset="utf-8"></script>
<script src="DMPDocs/msca-dmp-2024-11-14.js" type="text/javascript" charset="utf-8"></script>
<script src="DMPDocs/bmbf-dmp-2024-11-14.js" type="text/javascript" charset="utf-8"></script>
<script src="DMPDocs/bmel-dmp-2024-11-14.js" type="text/javascript" charset="utf-8"></script>
<script src="DMPDocs/vw-dmp-2024-11-14.js" type="text/javascript" charset="utf-8"></script>
<script src="DMPDocs/dfg-dmp-2024-11-14.js" type="text/javascript" charset="utf-8"></script>
<script src="DMPDocs/horizon_europe-2024-11-14.js" type="text/javascript" charset="utf-8"></script>
<script src="DMPDocs/Horizon2020_DMP-2024-11-14.js" type="text/javascript" charset="utf-8"></script>
<script src="DMPDocs/practical-guide-2024-11-14.js" type="text/javascript" charset="utf-8"></script>
<!-- loading javascript scripts -->
<script src="js/split.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/bootstrap.bundle.min2106.js" type="text/javascript" charset="utf-8"> </script>
<script async src="js/FileSaver.js" type="text/javascript" charset="utf-8"></script>
<script src="js/d3.min.js" type="text/javascript" charset="utf-8"> </script>
<script src="js/bs5-intro-tour2106.js" type="text/javascript" charset="utf-8"></script>
<link href="css/custom24-10-20.css" rel="stylesheet" />
<link href="favicon.png" rel="icon">
<!-- 100% privacy-first analytics -->
<script async defer src="https://scripts.simpleanalyticscdn.com/latest.js"></script>
<noscript><img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt=""
referrerpolicy="no-referrer-when-downgrade" /></noscript>
<script>
</script>
</head>
<script>
/********** Section variables and data structures ***********/
/**
* @name is_firefox
* @global
* @static
* @description to log if the browser is Firefox
**/
var is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;// check if the browser is firefox. For firefox, an argument in window.find() function is different
/**
* @name is_ie
* @global
* @static
* @description to log if the browser is IE
**/
const dmpStrings = {
"Horizon2020_DMP" : Horizon2020_DMP.Horizon2020_DMP,
"horizon_europe" : horizon_europe.horizon_europe,
"dfg-dmp" : dfg_dmp["dfg-dmp"],
"bmbf-dmp" : bmbf_dmp["bmbf-dmp"],
"BBSRC-dmp": BBSRC_dmp["BBSRC-dmp"],
"bmel-dmp": bmel_dmp["bmel-dmp"],
"vw-dmp": vw_dmp["vw-dmp"],
"msca-dmp": msca_dmp["msca-dmp"],
"practical-guide": practical_guide["practical-guide"],
"user-defined": window.localStorage.getItem("fulltext_user"),
}
const dmpFunders = {
"Horizon2020_DMP" : "Horizon 2020",
"horizon_europe" : "Horizon Europe",
"dfg-dmp" : "DFG (Deutschforschungsgemeinschaft)",
"bmbf-dmp" : "BMBF (Bundes Ministerium für Bildung und Forschung)",
"msca-dmp" : "Marie Skłodowska-Curie Actions",
"BBSRC-dmp": "BBSRC",
"bmel-dmp": "BMEL",
"vw-dmp": "Volkswagen Foundation",
"practical-guide": "Practical Guide",
"user-defined": "Userdefined",
}
var is_ie = navigator.userAgent.toLowerCase().indexOf('MSIE ') > -1;// check if the browser is firefox. For firefox, an argument
if (is_ie > 0) // If Internet Explorer, return version number
{
alert(parseInt(ua.substring(msie + 5, ua.indexOf(".", msie))) + ", this browser is not supported");
}
else // If another browser, return 0
{
//verbose console.log("browser is supported");
}
var debug;
var doc_name = 'Horizon2020_DMP'; // default document to use at the first page load
var user_info = window.localStorage.getItem("user_info"); // store user information in local storage
var wordcloud = window.localStorage.getItem("wordcloud") || "true";
var scroll_y = window.localStorage.getItem("scroll_y");
//console.log("scroll_y read from cache is " + scroll_y);
var cached_a = window.localStorage.getItem("saved_a"); // try to get the saved answers from local storage
var cached_template = window.localStorage.getItem("template"); // try to get the saved templates from local storage
var datepicker_list = []; // initialize a list to store DMP update reminder
var toast_list;
var cookie_modal;
var old_percentage;
var scroll_marker;
var punctualReplaced = false;
var dmpEle;
var convertedEle;
var classicMode = true;
var initialed = false; // set the initialed status to false
const JSONString = '{"dmp":{"title":"DMP of Example Project","contact":{"contact_id":{"identifier":"http://orcid.org/0000-0000-0000-0000","type":"orcid"},"mbox":"DMP of email","name":"DMP of Example User"},"created":"2024-06-19T16:45:09.7","dmp_id":{"identifier":"https://doi.org/10.0000/00.0.1234","type":"doi"},"dataset":[{"dataset_id":{"identifier":"https://doi.org/10.0000/00.0.5678","type":"doi"},"title":"Placeholder dataset","personal_data":"unknown","sensitive_data":"unknown"}],"ethical_issues_exist":"unknown","language":"eng","modified":"2024-07-09T10:53:50.4","submission":"2024-07-09T10:53:50.4","version":"1.0"},"replace":{"$_PROJECTNAME":"Example Project","$_STUDYOBJECT":"Example Topic","$_PROJECTAIM":"Example Aim","$_DMPVERSION":"1.0","$_USERNAME":"Example User","$_EMAIL":"email","$_DATAOFFICER":"Example data officer name","$_DATAUTILITY":"Industry, politicians and students can also use the data for different purposes.","$_UPDATEMONTH":"Example Month","$_PREVIOUSPROJECTS":"Previous Project Name","$_PROPRIETARY":"Proprietary Software","$_RAWDATA":"???","$_DERIVEDDATA":"???","$_FUNDINGPROGRAMME":"action number or funding programme name","$_CREATIONDATE":"xxxx-xx-xx","$_MODIFICATIONDATE":"xxxx-xx-xx","$_OTHERSTANDARDINPUT":"other standards","$_OTHEREP":"Other repositories","$_PARTNERS":"partner name", "$_ADDPROJECTCOORDINATOR": "project coordinator" },"checkbox":{"checkbox_1":{"checked":["check_dataplant"],"unchecked":[ "check_acronym","check_protect","check_update","check_previousprojects","check_industry","check_proprietary","check_partners","check_eu"]},"checkbox_2":{"checked":[],"unchecked":["check_transcriptomic", "check_genetic","check_genomic","check_cloned-dna","check_rnaseq","check_metabolomic","check_proteomic","check_phenotypic","check_targeted","check_image","check_models","check_code","check_excel"]},"checkbox_3":{"checked":[],"unchecked":["check_miappe","check_minseqe","check_otherstandards","check_dublincore","check_marc21", "check_darwincore", "check_bioschemas", "check_schemaorg" ,"check_early","check_ipissue","check_vvisualization","check_mixs","check_migseu","check_migsorg","check_mims","check_mimarksspecimen","check_mimarkssurvey","check_misag","check_mimag","check_miame","check_mmiamet","check_rembi","check_miape","check_mimix","check_beforepublication","check_endofproject","check_embargo","check_request","check_nfdi","check_french","check_eosc"]},"checkbox_5":{"checked":[],"unchecked":["check_genbank","check_sra","check_geo","check_ena","check_arrayexpress","check_metabolights","check_pride","check_bioimage","check_idr","check_edal","check_metaworkbench","check_intact","check_pdb","check_chebi","check_otherep"]}},"update":{"timeline":[],"storage":[{"answer":[],"name":[]},{"answer":[],"name":[]},{"answer":[],"name":[]},{"answer":[],"name":[]},{"answer":[],"name":[]},{"answer":[],"name":[]}]}}';
const templateJSON = '{"replace":{"$_PROJECTNAME":"Example Project","$_STUDYOBJECT":"Example Topic","$_PROJECTAIM":"Example Aim","$_USERNAME":"Example User","$_EMAIL":"email","$_DATAOFFICER":"Example data officer name","$_RAWDATA":"???","$_DERIVEDDATA":"???","$_FUNDINGPROGRAMME":"action number or funding programme name","$_CREATIONDATE":"xxxx-xx-xx","$_MODIFICATIONDATE":"xxxx-xx-xx"}}';
let temp_a = JSON.parse(templateJSON); // template answers used to compare with saved answers
if (cached_a !== null) { // if there is an answer saved in local storage
saved_a = JSON.parse(cached_a); // load the cached answers to webpage
try {
saved_a["update"];
saved_a["update"]["timeline"];
saved_a["dmp"];
saved_a["update"]["storage"]["0"]["answer"]["$_PROJECTNAME"]
} // If some answers are missing, re-initialize the answers.
catch (e) {
saved_a["update"] = {
"timeline": [
], "storage": [
{ "answer": { "replace": saved_a["replace"], "checkbox": saved_a["checkbox"] }, "name": [], },
{ "answer": [], "name": [], },
{ "answer": [], "name": [], },
{ "answer": [], "name": [], },
{ "answer": [], "name": [], },
{ "answer": [], "name": [], },
]
};
saved_a["dmp"] = {
"title": "Minimal DMP",
"created": "2018-07-23T10:10:23.6",
"ethical_issues_exist": "no",
"language": "eng",
"modified": "2019-02-06T15:30:42.1",
"contact": {
"mbox": "[email protected]",
"name": "Charlie Chaplin",
"affiliation":"",
},
"project":{
"title":"project name",
"description":"description",
"start":"starting date",
"funding":{
"funder_id":"funder_id",
"status":"status"
}
},
"dataset": [{
"title":"titile",
"type":"",
"personal_data": "no",
"sensitive_data": "no",
"distribution":{
"host":{
"description":"description"
}
}
}
],
"submission": {
"time": "2022-07-06T15:30:42.1",
"funding": "Horizon Europe ",
},
};
}
} else { // if there is no saved answer, initiate a new saved answer
var saved_a = JSON.parse(JSONString)
}
/*============== tutorial ==============*/
// a tutorial to help users get familiar with the DataPLAN tool.
var steps = [{
title: "DataPLAN ",
content: `
<div class="row">
<div class="col mt-1">
<p> Welcome to the DataPLAN tool! This tool is designed to help you quickly generate five Data Management Plans (DMPs) in just two minutes. This work has been featured in the journal <a href="https://doi.org/10.3390/data8110159" target="_blank" > Data</a>. </p>
</div>
<div class="col " >
<a href="https://www.mdpi.com/2306-5729/8/11/159" target="_blank" ><img src="https://nfdi4plants.github.io/dataplan/images/cover.webp" class="img-fluid" alt="issueCover" ></a>
</div>
</div>
`
//
}, {
id: "navbar-interface",
content: "<p>The questionnaire consists of five easy-to-navigate sections.</p>"
}, {
id: "intro-tour-input",
content: "<p>All five sections are conveniently organized on a single page for a seamless experience.</p>"
}, {
id: "form_projectname",
content: "<p>Please enter your project name in the highlighted input box. For example, you can type: 'An awesome project.' Once you've entered the name, click anywhere else or press the tab key to proceed. Your answers will be saved automatically.</p>"
}, {
id: "split-0",
content: "<p>The document content has now been updated with your input.</p>"
}, {
id: "save_button",
content: "<p>You can save your answers as a JSON file or copy the generated document from the left-hand side.</p>"
}, {
id: "upload_button",
content: "<p> If you've saved your progress, you can upload the 'JSON' file to continue where you left off. </p>"
}, {
id: "change_template",
content: `<p>You can choose from a variety of templates, including those for Horizon 2020, Horizon Europe, DFG, BMBF, and more. <a href="#" onclick=' document.querySelector("#change_template").click();document.querySelector(".tour-exit").click();'>Click here to browse all available templates</a>.</p>`
}
];
var maxWidth = 1100;
var tour = new Tour(steps); // initialize the guided tour
var upload_json1, upload_json2, current_input_answer, uploaded_input_answer, current_origin, uploaded_origin, uploaded_input_all;
const prefix = '$_';
/********** functions ***********/
/**
* @function addCheckboxOpt( missing, otherMissing )
* @description Update the previous saved answers to make it compatible to the newest version of software.
* @global
*/
/**
* @function updateSavedAnswers
* @description Update the previous saved answers to make it compatible to the newest version of software.
* @global
*/
function updateSavedAnswers() {
try {
delete saved_a["replace"]["$_VISUALIZATION"]; (saved_a["checkbox"]["checkbox_3"]["unchecked"].includes("check_vvisualization") || saved_a["checkbox"]["checkbox_3"]["checked"].includes("check_vvisualization")) ? {} : saved_a["checkbox"]["checkbox_3"]["unchecked"].push("check_vvisualization")
}
catch (e) { };
// check if the newly added answers are there, to be backward compatible
try {
Object.keys(saved_a["replace"]).includes("$_DATAUTILITY") ? {} : saved_a["replace"]["$_DATAUTILITY"] = "Industry, politicians and students can also use the data for different purposes.";
}
catch (e) { };
try {
(!Object.keys(saved_a["replace"]).includes("$_OTHERSTANDARDINPUT") || saved_a["replace"]["$_OTHERSTANDARDINPUT"].includes("Other standards are also adhered to") )? saved_a["replace"]["$_OTHERSTANDARDINPUT"] = "other standards" : {} ;
}
catch (e) { };
try {
((!Object.values(saved_a["checkbox"]["checkbox_3"]["checked"]).includes("check_otherstandards")) && (!Object.values(saved_a["checkbox"]["checkbox_3"]["unchecked"]).includes("check_otherstandards"))) ? saved_a["checkbox"]["checkbox_3"]["unchecked"].push("check_otherstandards") : {};
}
catch (e) { };
try {
((!Object.values(saved_a["checkbox"]["checkbox_5"]["checked"]).includes("check_otherep")) && (!Object.values(saved_a["checkbox"]["checkbox_5"]["unchecked"]).includes("check_otherep"))) ? saved_a["checkbox"]["checkbox_5"]["unchecked"].push("check_otherep") : {};
}
catch (e) { console.log("other ep error"); };
try {
((!Object.values(saved_a["checkbox"]["checkbox_5"]["checked"]).includes("check_metabolights")) && (!Object.values(saved_a["checkbox"]["checkbox_5"]["unchecked"]).includes("check_metabolights"))) ? saved_a["checkbox"]["checkbox_5"]["unchecked"].push("check_metabolights") : {};
}
catch (e) { console.log("metabolights error"); };
try {
(!Object.keys(saved_a["checkbox"]).includes("checkbox_5")) ? saved_a["checkbox"]["checkbox_5"] = { "checked": ["check_geo", "check_genbank", "check_proteomexchange", "check_Zenodo", "check_dataDyrad"], "unchecked": ["check_ena", "check_arrayexpress", "check_pride",] } : {};
}
catch (e) { };
try {
((!Object.values(saved_a["checkbox"]["checkbox_3"]["checked"]).includes("check_beforepublication")) && (!Object.values(saved_a["checkbox"]["checkbox_3"]["unchecked"]).includes("check_beforepublication"))) ? saved_a["checkbox"]["checkbox_3"]["unchecked"].push("check_beforepublication", "check_endofproject", "check_embargo", "check_request", "check_nfdi", "check_french", "check_eosc") : {};
}
catch (e) { };
try {
((!Object.values(saved_a["checkbox"]["checkbox_5"]["checked"]).includes("check_metaworkbench")) && (!Object.values(saved_a["checkbox"]["checkbox_5"]["unchecked"]).includes("check_metaworkbench"))) ? saved_a["checkbox"]["checkbox_5"]["unchecked"].push("check_edal", "check_intact", "check_sra", "check_bioimage", "check_idr", "check_metaworkbench", "check_pdb", "check_chebi", "check_otherep") : {};
}
catch (e) { };
try {
Object.keys(saved_a["replace"]).includes("$_OTHEREP") ? {} : saved_a["replace"]["$_OTHEREP"] = "Other repositories";
}
catch (e) { };
try {
saved_a = JSON.parse(JSON.stringify(saved_a).replaceAll("check_dublin_core", "check_dublincore").replaceAll("check_marc_21", "check_marc21"));
}
catch (e) { };
try {
((!Object.values(saved_a["checkbox"]["checkbox_3"]["checked"]).includes("check_mixs")) && (!Object.values(saved_a["checkbox"]["checkbox_3"]["unchecked"]).includes("check_mixs"))) ? saved_a["checkbox"]["checkbox_3"]["unchecked"].push("check_mixs", "check_migseu", "check_migsorg", "check_mims", "check_mimarksspecimen", "check_mimarkssurvey", "check_misag", "check_mimag", "check_miame", "check_rembi", "check_miape", "check_mimix") : {};
}
catch (e) { };
try {
((!Object.values(saved_a["checkbox"]["checkbox_2"]["checked"]).includes("check_transcriptomic")) && (!Object.values(saved_a["checkbox"]["checkbox_2"]["unchecked"]).includes("check_transcriptomic"))) ? saved_a["checkbox"]["checkbox_2"]["unchecked"].push("check_transcriptomic") : {};
}
catch (e) { };
try {
((!Object.values(saved_a["checkbox"]["checkbox_3"]["checked"]).includes("check_mmiamet")) && (!Object.values(saved_a["checkbox"]["checkbox_3"]["unchecked"]).includes("check_mmiamet"))) ? saved_a["checkbox"]["checkbox_3"]["unchecked"].push("check_mmiamet") : {};
}
catch (e) { };
try {
((!Object.values(saved_a["checkbox"]["checkbox_1"]["checked"]).includes("check_acronym")) && (!Object.values(saved_a["checkbox"]["checkbox_1"]["unchecked"]).includes("check_acronym"))) ? saved_a["checkbox"]["checkbox_1"]["unchecked"].push("check_acronym") : {};
}
catch (e) { };
try {
((!Object.values(saved_a["checkbox"]["checkbox_1"]["checked"]).includes("check_projectcoordinator")) && (!Object.values(saved_a["checkbox"]["checkbox_1"]["unchecked"]).includes("check_projectcoordinator"))) ? saved_a["checkbox"]["checkbox_1"]["unchecked"].push("check_projectcoordinator") : {};
}
catch (e) { };
try {
((!Object.values(saved_a["checkbox"]["checkbox_3"]["checked"]).includes("check_darwincore")) && (!Object.values(saved_a["checkbox"]["checkbox_3"]["unchecked"]).includes("check_darwincore"))) ? saved_a["checkbox"]["checkbox_3"]["unchecked"].push("check_darwincore", "check_bioschemas", "check_schemaorg") : {};
}
catch (e) { };
try {
Object.keys(saved_a["replace"]).includes("$_FUNDINGPROGRAMME") ? {} : saved_a["replace"]["$_FUNDINGPROGRAMME"] = "action number or funding programme name";
}
catch (e) { };
try {
Object.keys(saved_a["replace"]).includes("$_ADDPROJECTCOORDINATOR") ? {} : saved_a["replace"]["$_ADDPROJECTCOORDINATOR"] = "Project Coordinator";
}
catch (e) { };
try {
Object.keys(saved_a["replace"]).includes("$_ADDACRONYM") ? {} : saved_a["replace"]["$_ADDACRONYM"] = "Add the acronym here";
}
catch (e) { };
try {
if (Object.keys(saved_a["replace"]).includes("$_PROJECT")) {
{Object.defineProperty(saved_a["replace"], "$_PROJECTNAME",
Object.getOwnPropertyDescriptor(saved_a["replace"], "$_PROJECT")); delete saved_a["replace"]["$_PROJECT"]}
} ;
}
catch (e) { };
try {
if (Object.keys(saved_a["replace"]).includes("$_dataofficer")) {
{Object.defineProperty(saved_a["replace"], "$_DATAOFFICER",
Object.getOwnPropertyDescriptor(saved_a["replace"], "$_dataofficer")); delete saved_a["replace"]["$_dataofficer"]}
} ;
}
catch (e) { };
try {
if (Object.keys(saved_a["replace"]).includes("$_proprietary")) {
{Object.defineProperty(saved_a["replace"], "$_PROPRIETARY",
Object.getOwnPropertyDescriptor(saved_a["replace"], "$_proprietary")); delete saved_a["replace"]["$_proprietary"]}
} ;
}
catch (e) { };
try {
Object.keys(saved_a["replace"]).includes("$_CREATIONDATE") ? {} : saved_a["replace"]["$_CREATIONDATE"] = "xxxx-xx-xx";
}
catch (e) { };
try {
Object.keys(saved_a["replace"]).includes("$_MODIFICATIONDATE") ? {} : saved_a["replace"]["$_MODIFICATIONDATE"] = "xxxx-xx-xx";
}
catch (e) { };
try {
Object.keys(saved_a["replace"]).includes("$_PARTNERS") ? {} : saved_a["replace"]["$_PARTNERS"] = "partner name";
}
catch (e) { };
}
/**
* @function load_dmp
* @description General function for replace place holders in the document text.
* @param {reload_answers} a callback function that reloads all the answers.
* @param {string} the name of the template used for replacement.
* @global
*/
function load_dmp(callback = reload_answers, name = cached_template) {
punctualReplaced = false;
const date = new Date(); // record the time
initialed ? scroll_y = document.getElementById("split-0").scrollTop + "" : {};
const options = { year: 'numeric', month: 'long', day: 'numeric' };
Object.keys(saved_a["replace"]).includes("$_DMPVERSION") ? {} : saved_a["replace"]["$_DMPVERSION"] = "1.0";
//document.getElementById("today_date").innerHTML = "<h3>"+date.toLocaleDateString('en-US', options)+"</h3>";
let frame = document.getElementById("doc3");
if (convertedEle ==undefined){
callback(name);
}else if (doc_name == "user-defined"){
callback(name);
}
else if (doc_name != name){
callback(name);
}
else{
frame.innerHTML = convertedEle;
allCheckbox(), htmlFind_replace();
}
doc_name = name; // overwrite global variable doc_name
initialed = true;
syn_load_cache();
document.getElementById("editTemplate").href = "https://github.com/nfdi4plants/dataplan/blob/main/DMPDocs/"+doc_name+"-2024-11-14.js";
// update dmp meta data
saved_a["dmp"]["title"] = "DMP of " + saved_a["replace"]["$_PROJECTNAME"];
saved_a["dmp"]["contact"]["name"] = saved_a["replace"]["$_USERNAME"];
saved_a["dmp"]["contact"]["mbox"] = saved_a["replace"]["$_EMAIL"];
saved_a["dmp"]["created"] == "2018-07-23T10:10:23.6" ? saved_a["dmp"]["created"] = saved_a["replace"]["$_CREATIONDATE"] : {};
saved_a["dmp"]["modified"] = saved_a["replace"]["$_MODIFICATIONDATE"];
saved_a["dmp"]["submission"] = date.toISOString().slice(0, -3);
saved_a["dmp"]["version"] = saved_a["replace"]["$_DMPVERSION"];
saved_a["dmp"]["project"] ? {}:saved_a["dmp"]["project"] = {};
saved_a["dmp"]["project"]["title"] = saved_a["replace"]["$_PROJECTNAME"];
saved_a["dmp"]["project"]["contact"] = saved_a["replace"]["$_ADDPROJECTCOORDINATOR"];
saved_a["dmp"]["project"]["funding"] ? {}:saved_a["dmp"]["project"]["funding"] = {};
saved_a["dmp"]["project"]["funding"]["funder_id"] = dmpFunders[window.doc_name];
saved_a["update"]["storage"][0]["answer"]["replace"] = saved_a["replace"];
saved_a["update"]["storage"][0]["answer"]["checkbox"] = saved_a["checkbox"];
runWordCloud();
setTimeout(() => {
classicMode ? punctual(): {};
document.getElementById("split-0").scrollTop = scroll_y,
console.log("the window is scrolled to: " + scroll_y);
}, "150");
}
/**
* @function enter2tab
* @description press enter is equal to press tab
*
* @global
*/
function deb(log){
if (debug){
console.log(log)
}
}
function enter2tab() { // let enter function like tab
if (window.event && window.event.keyCode == 13) {
window.event.keyCode = 9;
}
}
////verbose console.log("is firefox ?"+is_firefox); // check if the firefox check works
/**
* @function consent
* @description show cookie consent page
*
* @global
*/
function consent() {
window.localStorage.setItem("cookie_consent", "yes");
if (user_info == null) {
setTimeout(function () {
window.innerWidth>maxWidth? tour.show() : {};
}, 500);
}
}
/**
* @function save_json
* @description save answers to JSON
*
* @global
*/
function save_json() {
aJSONString = JSON.stringify(saved_a);
const blob = new Blob([aJSONString], {
type: "application/json"
});
saveAs(blob, "DataPLAN_DMP");
}
/*============== tutorial initialization ends ==============*/
// event listener for text input (no need to press submit button anymore)
// compare updated answers and the original answers
/**
* @function compare_answers
* @description compare the previous answers and new answers
* @param old_a old answers
* @param new_a new answers
* @global
*/
function compare_answers(old_a, new_a) {
let unreplaced_keys = [];
let unsubmitted_checkbox = [];
let total_keywords = 0,
changed_keywords = 0,
total_checkboxes = 0,
changed_checkboxes = 0;
const old_replace = Object.entries(old_a["replace"]);
for (const [key, value] of old_replace) {
total_keywords++;
if ((new_a["replace"][key] != value) && (new_a["replace"][key] != "") && (new_a["replace"][key] != undefined)) {
changed_keywords++;
//verbose console.log(new_a["replace"][key]);
} else {
unreplaced_keys.push(key);
}
}
const old_checkbox = Object.entries(old_a["checkbox"]);
for (const [key, value] of old_checkbox) {
total_checkboxes++;
if (JSON.stringify(new_a["checkbox"][key]) != JSON.stringify(value)) {
//verbose console.log(new_a["checkbox"][key]);
changed_checkboxes++;
} else {
unsubmitted_checkbox.push(key);
}
}
const unchecked_options = new_a["checkbox"]["checkbox_1"]["unchecked"];
const uncheck_update = unchecked_options.includes("check_update");
if (uncheck_update) {
unreplaced_keys = unreplaced_keys.filter(item => item !== "$_UPDATEMONTH");
new_a["replace"]["$_UPDATEMONTH"] = "";
}
const check_previousprojects = unchecked_options.includes("check_previousprojects");
if (check_previousprojects) {
unreplaced_keys = unreplaced_keys.filter(item => item !== "$_PREVIOUSPROJECTS");
new_a["replace"]["$_PREVIOUSPROJECTS"] = "";
}
const check_proprietary = unchecked_options.includes("check_proprietary");
if (check_proprietary) {
unreplaced_keys = unreplaced_keys.filter(item => item !== "$_PROPRIETARY");
new_a["replace"]["$_PROPRIETARY"] = ""
}
let no_need_to_answer = uncheck_update + check_previousprojects + check_proprietary;
total_keywords = total_keywords - no_need_to_answer;
//verbose console.log("total_keys: " + total_keywords + "; changed_keywords: " + changed_keywords + "\n ; total_box " + total_checkboxes + ", changed_checkbox: " + changed_checkboxes + ", unreplaced_keys " + unreplaced_keys);
return [total_keywords, total_checkboxes, changed_keywords, changed_checkboxes, unreplaced_keys, unsubmitted_checkbox];
}
function compare_replace(old_a, new_a) {
let locala = JSON.parse(JSON.stringify(old_a["replace"]));
let unreplaced_keys = [];
let replaced_keys = [];
let total_keywords = 0,
changed_keywords = 0;
document.getElementById("check_update").checked? locala["$_UPDATEMONTH"]="Example Month" : {} ;
document.getElementById("check_previousprojects").checked? locala["$_PREVIOUSPROJECTS"]="Previous Project Name" : {} ;
document.getElementById("check_proprietary").checked? locala["$_PROPRIETARY"]="Proprietary Software" : {} ;
document.getElementById("check_partners").checked? locala["$_PARTNERS"]="partner name" : {} ;
document.getElementById("check_otherep").checked? locala["$_OTHEREP"]="" : {} ;
document.getElementById("check_acronym").checked? locala["$_ADDACRONYM"]="Add the acronym here" : {};
document.getElementById("check_projectcoordinator").checked? locala["$_ADDPROJECTCOORDINATOR"]="Project Coordinator" : {};
for (const [key, value] of Object.entries(locala)) {
total_keywords++;
if ((new_a["replace"][key] != value) && (new_a["replace"][key] != "") && (new_a["replace"][key] != undefined)) {
changed_keywords++;
replaced_keys.push(key);
//verbose console.log(new_a["replace"][key]);
} else {
unreplaced_keys.push(key);
}
}
//unreplaced_keys = unreplaced_keys.filter(item => item !== "$_PROPRIETARY").filter(item => item !== "$_PREVIOUSPROJECTS").filter(item => item !== "$_UPDATEMONTH").filter(item => item !== "$_DATAUTILITY");
return [total_keywords, 0, changed_keywords, 0, unreplaced_keys, [], replaced_keys];
}
/**
* @function onchange_replace
* @description old replace based on buttons
* @param child the element it was in
* @global
*/
function onchange_replace(child) {
const before = child.name.toUpperCase();
const after = child.value;
saved_a["replace"][before] = after;
trim_saved_a(saved_a);
window.localStorage.setItem("saved_a", JSON.stringify(saved_a));
eleName = before.split("_")[1]+"-to-";
document.getElementsByName(eleName).forEach(e=>{e.innerText=after});
let unfinished = compare_replace(temp_a, saved_a);
let p_bar = document.getElementById("p-bar");
let percentage = (unfinished[2] + unfinished[3]) / (unfinished[0] + unfinished[1]) * 100;
if (percentage === 100 && old_percentage != 100) {
toast_list[6].show();
}
old_percentage = percentage;
p_bar.style.setProperty("width", Math.ceil(percentage) + "%");
p_bar.innerHTML = Math.ceil(percentage) + "%";
p_bar.setAttribute("aria-valuenow", Math.ceil(percentage));
}
function htmlFind_replace(){
for (const [key, value] of Object.entries( saved_a["replace"])){
eleName = key.split("_")[1]+"-to-";
document.getElementsByName(eleName).forEach(e=>{e.innerText=value});
let unfinished = compare_replace(temp_a, saved_a);
let p_bar = document.getElementById("p-bar");
let percentage = (unfinished[2] + unfinished[3]) / (unfinished[0] + unfinished[1]) * 100;
if (percentage === 100 && old_percentage != 100) {
toast_list[6].show();
}
old_percentage = percentage;
p_bar.style.setProperty("width", Math.ceil(percentage) + "%");
p_bar.innerHTML = Math.ceil(percentage) + "%";
p_bar.setAttribute("aria-valuenow", Math.ceil(percentage));
//console.log(key+" " + value)
}
}
function onchange_replace1(child) {
const before = child.name;
const after = child.value;
saved_a["replace"][before] = after;
load_dmp(reload_answers, doc_name);
}
function updateWC(status){
window.wordcloud = (status).toString();
localStorage.setItem("wordcloud", status);
load_dmp(reload_answers, doc_name);
}
function runWordCloud(){
if (window.wordcloud =="true"){
parseText();
console.log("word cloud")
}else{
try {
document.querySelector("#doc3").querySelector("#vis").remove();
} catch (error) {
}
}
}
/**
* @function trim_saved_a
* @description function to remove the "$_" of the text to avoid replace errors
* @param saved_a the element it was in
* @global
*/
// trim the "$_" to avoid infinite loops
function trim_saved_a(saved_a) {
const replace = Object.entries(saved_a["replace"]);
for (const [key, value] of replace) {
saved_a["replace"][key] = value.replace("$_", "")
}
}
// reload all the answers and save the answers to local storage
/**
* @function reload_answers
* @description function to reload all answers and refresh the document
* @global
*/
function reload_answers(name) {
window.localStorage.setItem("template", name);
dmpEle.innerHTML = dmpStrings[name];
//let content = dmpEle.querySelector("#"+name);
//content.classList.add("content-page");
let frame = document.getElementById("doc3");
frame.innerHTML = dmpEle.innerHTML;
const selection = window.getSelection();
selection.removeAllRanges();
trim_saved_a(saved_a);
window.localStorage.setItem("saved_a", JSON.stringify(saved_a));
const replace_input = Object.entries(saved_a["replace"]);
for (const [key, value] of replace_input) {
if (key !== "$_VISUALIZATION") {
let element = document.getElementsByName(key)[0];
//console.log(key + " "+value);
try {
element.value = value;
} catch (error) {
console.error(error);
element.value = "Error, can not parse the value, please first export the JSON and then import"
}
}
}
const checkbox_input = Object.entries(saved_a["checkbox"]);
for (const [key, value] of checkbox_input) {
let checkboxes = value;
try {
const checked = Object.entries(checkboxes["checked"]);
for (const [key, value] of checked) {
let element = document.getElementById(value.toLowerCase());
try {
element.checked = true;
} catch (error) {
console.error(error);
element.checked = false;
}
};
} catch (e) {
//verbose console.log("checked is null");
}
try {
const unchecked = Object.entries(checkboxes["unchecked"]);
for (const [key, value] of unchecked) {
//console.log("value = "+ value)
let element = document.getElementById(value.toLowerCase());
try {
element.checked = false;
} catch (error) {
console.error(error);
}
};
} catch (e) {
console.error(e)
//verbose console.log("unchecked is null");
}
}
checkboxConversion();
for (let answers in saved_a["replace"]) {
let singleOption = {};
singleOption[answers] = saved_a["replace"][answers];
//verbose console.log(singleOption);
const before = "$_" + answers.split("_")[1].toUpperCase() ;
find_replace(before, singleOption[answers]);
}
//verbose console.log("answer reload is finished");
issue_warning(name);
let unfinished = compare_replace(temp_a, saved_a);
let p_bar = document.getElementById("p-bar");
let percentage = (unfinished[2] + unfinished[3]) / (unfinished[0] + unfinished[1]) * 100;
if (percentage === 100 && old_percentage != 100) {
toast_list[6].show();
}
old_percentage = percentage;
p_bar.style.setProperty("width", Math.ceil(percentage) + "%");
p_bar.innerHTML = Math.ceil(percentage) + "%";
p_bar.setAttribute("aria-valuenow", Math.ceil(percentage));
let checkboxes = document.querySelectorAll(".form-check-input");
checkboxes.forEach(e => {
const classList = Array.from(e.classList);
const class_name = classList.filter((word)=> word.includes("checkbox_"))
if(class_name.length>0){
e.setAttribute("onfocusin", 'checkboxOnfocusin(this)');
e.setAttribute("onfocusout", 'checkboxOnfocusout(this)');
e.setAttribute("onmouseover", 'this.focus()');
e.setAttribute("onclick", ' sc1(this)');
e.setAttribute("name", e.id);
e.setAttribute("onchange", "get_option(this)");
}
}
);
checkboxSelection(),
allCheckbox();
convertedEle = document.getElementById("doc3").innerHTML;
// e.setAttribute("onchange", "const col1 = new bootstrap.Collapse('."+id+"Repo', {toggle: false});if(this.checked == true){col1.show();}else{col1.hide();}");
}
function checkboxOnfocusin(ele){
const elem1 = document.querySelectorAll("."+ele.id);
elem1.forEach(e =>{ e.classList.add("border-highlight");
if(e.querySelector("li")!=null){e.querySelector("li").classList.add("border-highlight")} });
set_scrollbar_marker( scroll_marker,elem1 )
}
function checkboxOnfocusout(ele){
const elem2 = document.querySelectorAll("."+ele.id);
elem2.forEach(e => {e.classList.remove("border-highlight");
if(e.querySelector("li")!=null){e.querySelector("li").classList.remove("border-highlight")}});
let remove = Array.from(document.getElementsByName("scroll-bar-span"));
remove.forEach(e => {e.remove()})
}
function checkboxSelection(){
let c2Checked = [];
let c2Unchecked = [];
document.querySelectorAll(".checkbox_2").forEach((e) => {
if (e.checked) {
c2Checked.push(e);
} else {
c2Unchecked.push(e);
}
});
c2Unchecked.forEach(
(e) => {
const id = e.getAttribute("id");
try {
let repolist = document.querySelectorAll('.' + id + 'repo');
repolist.forEach(item => {
const col1 = new bootstrap.Collapse("#" + item.id, { toggle: false });
col1.hide();
});
} catch (e) {
// console.log(e)
};
}
);
c2Checked.forEach(
(e) => {
const id = e.getAttribute("id");
try {
let repolist = document.querySelectorAll('.' + id + 'repo');
repolist.forEach(item => {
const col1 = new bootstrap.Collapse("#" + item.id, { toggle: false });
col1.show();
});
} catch (e) {
//console.log(e)
};
}
);
}
/**
* @function upload_image
* @description function to upload an image
* @global
*/
function upload_image() {
try { document.getElementById('vis').children[0].remove(); } catch (e) { }
document.getElementById('vis').innerHTML = '<img id="front_page" src="" width="100%" height="100%" viewBox="0 0 600 600 alt="Image preview..." >';
let front_page = document.getElementById('front_page');
let image = document.getElementById('image_upload').files[0];
let reader = new FileReader();
reader.addEventListener("load", function () {
front_page.src = reader.result;
}, false);
if (image) {
reader.readAsDataURL(image);
}
}
/**
* @function get_option
* @description checkbox submission function,
* @global
*/
function get_option(this_element) {
const classList = Array.from(this_element.classList);
const class_name = classList.filter((word)=> word.includes("checkbox_"))
console.log("class name for question is " + class_name);
const checked = document.querySelectorAll(`.${class_name}:checked`);
const unchecked = document.querySelectorAll(`.${class_name}:not(:checked)`);
const checked_list = [];
checked.forEach(element => checked_list.push(element.id));
const unchecked_list = [];
unchecked.forEach(element => unchecked_list.push(element.id));
console.log("uncheck and checked \n" + checked_list + "\n"+ unchecked_list)
saved_a["checkbox"][class_name] = {
"checked": checked_list,
"unchecked": unchecked_list
};
let singleOption = {};
singleOption[class_name] = {
"checked": checked_list,
"unchecked": unchecked_list
};
//verbose console.log("+++++++++++++++++" + checked_list);
load_dmp(reload_answers, doc_name);
}
function sc1(ele){
checkboxOnfocusout(ele); setTimeout(()=> {
scroll_y = document.getElementById("split-0").scrollTop;
punctualReplaced || classicMode ? load_dmp(reload_answers, doc_name) :singleCheckbox(ele.id);}, "0");
setTimeout(()=> { checkboxOnfocusin(ele)}, "500")
}
function allCheckbox(){
let allchecked = [];
setTimeout(e=>{
//document.querySelectorAll(".checkboxConverted").forEach(e=>{e.classList.add("d-none")});
for (const [index, boxes] of Object.entries(saved_a["checkbox"])){
allchecked.push(...boxes["checked"]);
}
for (const check of allchecked){
singleCheckbox(check.toLowerCase());
}
let allunchecked = [];
for (const [index, boxes] of Object.entries(saved_a["checkbox"])){
allunchecked.push(...boxes["unchecked"]);
}
allunchecked= allunchecked.map(v => v.toLowerCase());
for (const uncheck of allunchecked){
//singleCheckbox(check.toLowerCase());
const checkboxContent = document.querySelectorAll("."+uncheck);
checkboxContent.forEach(
e=>{
const operator = e.dataset.operator.split("|");
const found = operator.slice(0,-1).every(e=> allunchecked.includes(e));
if (operator.length >= 2){
if(found){
e.classList.add("d-none");
}else{
e.classList.remove("d-none");