-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdialogs.js
More file actions
1921 lines (1783 loc) · 112 KB
/
dialogs.js
File metadata and controls
1921 lines (1783 loc) · 112 KB
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
var WaitingForServer_FLAG = false; // useful for the 'GetMaxIdentifier' server request, so that it is not issued consecutively
/**
* This class contains source code for all the dialogs of the application
* Each static class displays a different dialog.
*/
class Dialog {
/**
* Displays a dialog window containing data about a certain item.
* @param {String} UUID the unique id of an item. The data of this item will be displayed in the dialog. If UUID is empty then a new item will be created.
* @param {String} alterHistory: if true then the item's UUID is added to the Browsing History. This is necessary only when this dialog is displayed while browsing and not updating.
*/
static showItemDataDialog( UUID, alterHistory=false ) {
var ItemData = getDataBy_UUID( UUID );
if( typeof ItemData == "undefined" ) {
alert("Could not find item " + UUID);
return;
}
// inform the map that the user has focused on this item and locus, so that they are colored differently
if (ItemData.hasOwnProperty("Location")) {
map.set_Focused_itemUUID( UUID );
map.drawWorld();
} else if (ItemData.hasOwnProperty("RelationBelongsToUUID")) {
var parentItem = getDataBy_UUID( ItemData["RelationBelongsToUUID"] );
if( parentItem != null && typeof parentItem != 'undefined') {
map.set_Focused_itemUUID( parentItem["IdentifierUUID"] );
map.drawWorld();
}
}
// reset state
ITEM_DATA_HAS_BEEN_CHANGED = false;
// figure out item's color
var bgcolor = getItemColor( ItemData["Type"], ItemData["Category"] );
// manage history
if( alterHistory ) theHistory.Add( UUID );
// display dialog window
var DialogTitle = "";
if( typeof ItemData["Identifier"] != 'undefined' && ItemData["Identifier"].length > 0 ) DialogTitle += "[" + ItemData["Identifier"] + "] ";
DialogTitle += ItemData["Type"] + " - " + ItemData["Title"];
var dialog_obj = $( "#itemInfoDialog" ).dialog(
{ height: 600,
width: 820,
title: DialogTitle,
buttons: [
{ text: 'History Prev', id: 'iteminfodialogPrevBtn', class: 'dialogPrevBtn',
click: function() {
var go_on = true;
if( ITEM_DATA_HAS_BEEN_CHANGED ) go_on = confirm("There are unsaved changes.\nAre you sure you want to leave this dialog?");
if( go_on ) {
Dialog.showItemDataDialog(theHistory.Back());
}
}
},
{ text: 'History Next', id: 'iteminfodialogNextBtn', class: 'dialogNextBtn',
click: function() {
var go_on = true;
if( ITEM_DATA_HAS_BEEN_CHANGED ) go_on = confirm("There are unsaved changes.\nAre you sure you want to leave this dialog?");
if( go_on ) {
Dialog.showItemDataDialog(theHistory.Forward());
}
}
},
{ text: 'List Up', id: 'iteminfodialogUpBtn', class: 'dialogUpBtn',
click: function() {
var go_on = true;
if( ITEM_DATA_HAS_BEEN_CHANGED ) go_on = confirm("There are unsaved changes.\nAre you sure you want to leave this dialog?");
if( go_on ) {
var UUID_to_go = getPrevListElementUUID(UUID);
Dialog.showItemDataDialog( UUID_to_go );
Scroll_ItemsList(UUID_to_go);
}
}
},
{ text: 'List Down', id: 'iteminfodialogDownBtn', class: 'dialogDownBtn',
click: function() {
var go_on = true;
if( ITEM_DATA_HAS_BEEN_CHANGED ) go_on = confirm("There are unsaved changes.\nAre you sure you want to leave this dialog?");
if( go_on ) {
var UUID_to_go = getNextListElementUUID(UUID);
Dialog.showItemDataDialog( UUID_to_go );
Scroll_ItemsList(UUID_to_go);
}
}
},
{ text: 'Save', id: 'iteminfodialogSaveBtn', class: 'dialogSaveBtn',
click: function() {
// check that field types are correct
var DialogFields = document.getElementsByClassName("dialog_itemfield");
for (let i=0; i<DialogFields.length; i++) {
var html_id = DialogFields[i].id;
var fieldName = html_id.substring( html_id.indexOf("_")+1 );
var fieldDataType = getFieldDataType( fieldName );
var fieldValue = document.getElementById( ItemData["IdentifierUUID"]+"_"+fieldName+"_text" );
if (fieldValue != null) {
fieldValue = document.getElementById( ItemData["IdentifierUUID"]+"_"+fieldName+"_text" ).value;
} else {
fieldValue = "";
}
if( fieldValue.length>0 && fieldDataType.toLowerCase().localeCompare("integer")==0 && Utils.ContainsInteger(fieldValue)==false ) {
alert("Cannot save changes.\nField '" + fieldName + "' is restricted to an integer value." );
return; // <<<<<<<<
}
if( fieldValue.length>0 && fieldDataType.toLowerCase().localeCompare("float")==0 && Utils.ContainsFloat(fieldValue)==false ) {
alert("Cannot save changes.\nField '" + fieldName + "' is restricted to a numeric value." );
return; // <<<<<<<<
}
}
// ensure that the Identifier is unique
if( document.getElementById( ItemData["IdentifierUUID"]+"_"+"Identifier"+"_text" ) != null ) { // the Identifier field has been edited
var new_Identifier = document.getElementById( ItemData["IdentifierUUID"]+"_"+"Identifier"+"_text" ).value;
if( ItemData["Identifier"] != new_Identifier && DoesThisIdentifierExists( new_Identifier ) ) { // the new identifier is different than the previous one
alert("Cannot save changes.\nThe identifier '" + new_Identifier + "' already exists. Please choose a unique one." );
return; // <<<<<<<<
}
}
// compose altered data fields in json format
var AlteredData = JSON.parse(JSON.stringify( ItemData )); // clone
var DialogFields = document.getElementsByClassName("dialog_itemfield");
for (let i=0; i<DialogFields.length; i++) {
var html_id = DialogFields[i].id;
var fieldName = html_id.substring( html_id.indexOf("_")+1 );
var fieldValue = document.getElementById( ItemData["IdentifierUUID"]+"_"+fieldName+"_text" );
if (fieldValue != null) {
fieldValue = document.getElementById( ItemData["IdentifierUUID"]+"_"+fieldName+"_text" ).value;
AlteredData[fieldName] = fieldValue;
}
}
// ************ Save it ************
SaveItem(AlteredData);
// >>>> in case the altered item is a Locus then some fields of its child-items must be updated. The server does the same alterations on his side, as well.
if( AlteredData.hasOwnProperty("Type") && AlteredData["Type"].localeCompare("Locus")==0 && AlteredData.hasOwnProperty("RelationIncludesUUID") ) {
var ChildrenUUIDs = AlteredData["RelationIncludesUUID"][0].trim().split('\n');
for (let i=0; i<ChildrenUUIDs.length; i++) {
var child_data = getDataBy_UUID( ChildrenUUIDs[i].trim() );
if( typeof child_data != 'undefined' ) {
child_data["Square"] = AlteredData["Square"];
//if( child_data.hasOwnProperty("Category") && AlteredData.hasOwnProperty("CoverageEarliest") && child_data["Category"].localeCompare("Coin")!=0 ) child_data["CoverageEarliest"] = AlteredData["CoverageEarliest"];
//if( child_data.hasOwnProperty("Category") && AlteredData.hasOwnProperty("CoverageLatest") && child_data["Category"].localeCompare("Coin")!=0 ) child_data["CoverageLatest"] = AlteredData["CoverageLatest"];
if( child_data.hasOwnProperty("Type") && AlteredData.hasOwnProperty("Title") && child_data["Type"].localeCompare("Partition")==0 ) child_data["Title"] = AlteredData["Title"];
}
}
}
}
}
],
open: function(event, ui) { $( this ).siblings( ".ui-dialog-titlebar" ).find( "button" ).focus(); },
beforeClose: function() {
var go_on = true;
if( ITEM_DATA_HAS_BEEN_CHANGED ) {
go_on = confirm("There are unsaved changes.\nAre you sure you want to leave this dialog?");
}
if( go_on == false ) {
return false;
} else {
map.set_Focused_itemUUID( "" );
map.drawWorld();
}
}
}
);
dialog_obj.prev(".ui-dialog-titlebar").css("background", bgcolor);
//// scroll to the top
$("#itemInfoDialog").scrollTop("0");
//
//$("#itemInfoDialog").draggable({containment : 'window' }); //
$(".ui-dialog").draggable({ scroll: false });
$(".ui-dialog").draggable({ containment: [-750,0,document.body.clientWidth-60, document.body.clientHeight-60] });
// Check for Access Permissions
var AccessGranted = false;
if( TheAccessLevels.toLowerCase().indexOf(",all,") >= 0 ) AccessGranted = true;
if( TheAccessLevels.indexOf(","+ItemData["Type"]+",") >= 0 ) AccessGranted = true;
if( TheAccessLevels.indexOf(","+ItemData["Category"]+",") >= 0 ) AccessGranted = true;
if( AccessGranted == false ) {
$('#iteminfodialogSaveBtn').attr("disabled", true);
$('#iteminfodialogSaveBtn').attr("title", "You do not have access to save changes");
$('#iteminfodialogSaveBtn').css("background-color", "lightgray");
$('#iteminfodialogSaveBtn').css("color", "gray");
$('#iteminfodialogSaveBtn').css("border-color", "gray");
$('#iteminfodialogSaveBtn').css("cursor", "default");
}
///// fill dialog contents with data
var s = "";
// -------- construct html and css for the item images if any --------
// figure out the related image names
var ImageNames = [];
let IncludedUUIDs = (""+ItemData["RelationIncludesUUID"]).split("\n");
if( typeof IncludedUUIDs != 'undefined' ) {
for( let i=0; i<IncludedUUIDs.length; i++ ) {
if( typeof IncludedUUIDs[i] != 'undefined' ) {
var relatedItemData = getDataBy_UUID( IncludedUUIDs[i] );
if( typeof relatedItemData != 'undefined' ) {
if( relatedItemData["Type"].localeCompare("Image") == 0 ) {
ImageNames.push( IncludedUUIDs[i] );
}
}
}
}
}
// construct html
// ---------------- images row - begin -----------
s += "<div class='dialog_images_row'>";
if( ImageNames.length > 0 ) {
for( let i=0; i<ImageNames.length; i++ ) {
ImageNames[i] = ImageNames[i].trim();
if( ImageNames[i].length > 0 && ImageNames[i].localeCompare("undefined") != 0 ) {
var image_json_data = getDataBy_UUID( ImageNames[i] );
s += "<div style='position:relative';>";
s += "<a href='#' onclick='";
s += "if (window.event.altKey) { AlterData(\"" + ItemData['IdentifierUUID'] + "\",\"ThumbnailImageUUID\",\"" + ImageNames[i] +"\"); Dialog.showItemDataDialog(\"" + ItemData['IdentifierUUID'] + "\");}";
if( TheUsername.localeCompare("Dimitrissssssssss") == 0 ) {
s += "else { window.open(\"image_viewer_with_tools.html" + "?img_uuid=" + ImageNames[i] + "\", \"_blank\").focus();}'";
} else {
if( image_json_data != null && typeof image_json_data["FormatImageAnnotations"] != "undefined" && image_json_data["FormatImageAnnotations"].length > 0 ) {
s += "else { window.open(\"image_viewer.html" + "?img_uuid=" + ImageNames[i] + "&item_uuid=" + ItemData['IdentifierUUID'] + "\", \"_blank\").focus();}'";
} else {
s += "else { window.open(\"Data/images/" + ImageNames[i] + ".jpg\", \"_blank\").focus();}'";
}
}
s += ">";
s += "<img src='Data/images/thumbnails/" + ImageNames[i]+".jpg" + "' title='" + ImageNames[i] + " Alt+click (and Save) to set as default" + "' height='160px' class='dialog_item_image'";
if( ImageNames[i].localeCompare( ItemData["ThumbnailImageUUID"] ) == 0 ) {
s += " style='border:6px dashed lightseagreen'";
} else {
s += " style='border:6px dashed white'";
}
// display X button on image only if user has editing rights
if( AccessGranted ) {
s += " onmouseover='document.getElementById(\"" + "DEL_"+ImageNames[i] + "\").style.visibility=\"visible\";'"; //s += " onmouseout ='setTimeout(function() { document.getElementById(\"" + "DEL_"+ImageNames[i] + "\").style.visibility=\"hidden\";}, 200);'";
}
s += ">";
s += "</a>";
// add a deletion button
if( TheAccessLevels.length > 0 ) {
s += "<button id='" + "DEL_"+ImageNames[i] + "' style='visibility:hidden; position:absolute; left:0px; top:0px; background-color:lightseagreen; color:white; border-radius:10px;'";
s += " onclick='DeletePhoto(\"" + ItemData['IdentifierUUID'] + "\", \"" + ImageNames[i] + "\");'";
s += "><b>X</b></button>";
}
s += "</div>";
}
}
}
// add image of a Plan if available
if( ItemData["Type"].localeCompare("Plan")==0 ) {
s += "<a href='plans/" + ItemData["FormatImage"] + "' target='_blank'>";
s += "<img src='plans/" + ItemData["FormatImage"] + "' title='" + ItemData["FormatImage"] + "' height='150px' class='dialog_item_image'>";
s += "</a>";
}
// add image of an Image if available
if( ItemData["Type"].localeCompare("Image")==0 ) {
s += "<a href='#' onclick='";
s += "if (window.event.altKey) { AlterData(\"" + ItemData['IdentifierUUID'] + "\",\"ThumbnailImageUUID\",\"" + ItemData['IdentifierUUID'] +"\"); Dialog.showItemDataDialog(\"" + ItemData['IdentifierUUID'] + "\");}";
if( typeof ItemData["FormatImageAnnotations"] != "undefined" && ItemData["FormatImageAnnotations"].length > 0 ) {
s += "else { window.open(\"image_viewer.html" + "?id=" + ItemData["IdentifierUUID"] + "\", \"_blank\").focus();}'";
} else {
s += "else { window.open(\"Data/images/" + ItemData["FormatImage"] + "\", \"_blank\").focus();}'";
}
s += ">";
s += "<img src='Data/images/thumbnails/" + ItemData["FormatImage"] + "' title='" + ItemData["FormatImage"] + "' height='150px' class='dialog_item_image'>";
s += "</a>";
}
// add a button so that the user can upload photos
var upload_photo_visibility = "visible";
if( AccessGranted == false ) upload_photo_visibility = "hidden"; // display add-new-image-button only if user has editing rights
s += "<input id='photo_upload' type='file' accept='image/png, image/jpeg, image/gif' name='photo_upload' style='visibility:hidden;' onchange='uploadPhoto(\"" + ItemData["IdentifierUUID"] + "\")' >";
s += "<button id='add_new_image_button' style='visibility:" + upload_photo_visibility + ";' title='Add new photograph' onclick='getElementById(\"photo_upload\").click();'> + </button>";
//
s += "</div>";
// ---------------- images row - end -----------
// ................ Display a 'Selected' checkbox ................
var is_selected_checked = "";
if( ItemData["Selected"] ) {
s += "<div style='grid-column:1; color:gold;' id='"+ItemData["IdentifierUUID"]+"_"+"SelectedLabel" + "'><b>" + "Selected" + "</b></div>";
is_selected_checked = "checked";
} else {
s += "<div style='grid-column:1;' id='"+ItemData["IdentifierUUID"]+"_"+"SelectedLabel" + "'><b>" + "Selected" + "</b></div>";
}
s += "<div style='grid-column:2; ' >";
s += "<input type='checkbox' " + is_selected_checked + " style='accent-color:gold;' id='" + ItemData["IdentifierUUID"]+"_"+"SelectedCheckbox" + "' onclick=\"Dialog.alterSelectedState('"+ItemData["IdentifierUUID"]+"');\">";
s += "</div>";
// ~~~~~~~~~~~~~~~~ Display the data contained in the item's fields ~~~~~~~~~~~~~~~~
// check which fields should be displayed
var TheVisibleFields = [];
if( typeof ItemData["Category"] != "undefined" && ItemData["Category"].length>0 && VisibleItemFields.indexOf(ItemData["Category"])>=0 ) {
TheVisibleFields = VisibleItemFields[ ItemData["Category"] ];
} else if( ItemData["Type"].length>0 && VisibleItemFields.indexOf(ItemData["Type"])>=0 ) {
TheVisibleFields = VisibleItemFields[ ItemData["Type"] ];
} else {
TheVisibleFields = VisibleItemFields[ "" ];
}
// Privilleged users shall be able to see and edit the more sensitive fields
if( TheAccessLevels.toLowerCase().includes(",all,") ) {
if( TheVisibleFields.includes("Trench") == false ) TheVisibleFields.splice(2, 0, "Trench");
if( TheVisibleFields.includes("Type") == false ) TheVisibleFields.splice(3, 0, "Type");
if( TheVisibleFields.includes("Category") == false ) TheVisibleFields.splice(4, 0, "Category");
if( TheVisibleFields.includes("Subcategory") == false ) TheVisibleFields.splice(5, 0, "Subcategory");
}
// certain fields must be visible only to registered users
if( TheAccessLevels.length == 0 ) {
var field_removed = true;
while( field_removed ) {
field_removed = false;
for( var i=0; i<ItemFields_VisibleOnlyToRegisteredUsers.length; i++ ) {
var idx_to_remove = TheVisibleFields.indexOf( ItemFields_VisibleOnlyToRegisteredUsers[i] );
if( idx_to_remove >= 0 ) {
TheVisibleFields.splice(idx_to_remove, 1);
field_removed = true;
break;
}
}
}
}
// Hide empty fields from the Guest users
if(TheUsername.length==0 || TheUsername.toLowerCase().localeCompare("guest")==0) {
var field_removed = true;
while( field_removed ) {
field_removed = false;
for( var i=0; i<TheVisibleFields.length; i++ ) {
var field_name = TheVisibleFields[ i ];
if( ItemData.hasOwnProperty(field_name)==false || ItemData[ field_name ].toString().trim().length == 0 ) {
var idx_to_remove = TheVisibleFields.indexOf( TheVisibleFields[i] );
if( idx_to_remove >= 0 ) {
TheVisibleFields.splice(idx_to_remove, 1);
field_removed = true;
break;
}
}
}
}
}
// display the fields in the correct order
var extra_classes = "";
for( var field_idx=0; field_idx<TheVisibleFields.length; field_idx++ ) {
var field_name = TheVisibleFields[ field_idx ];
var itemfielddata = "";
// fill the information inside the current field of the current item
if( typeof ItemData[field_name] != "undefined" ) {
itemfielddata = ItemData[field_name].toString();
}
var enhanced_itemfielddata; // itemfielddata with extra information and formating
var relatedUUIDs = [];
// Enhance field text: substitute item UUIDs with links to these items
if( field_name.startsWith("Relation") ) {
relatedUUIDs = itemfielddata.split("\n");
enhanced_itemfielddata = "";
for(let j=0; j<relatedUUIDs.length; j++) {
var an_item_data = getDataBy_UUID( relatedUUIDs[j] );
if( typeof an_item_data == "undefined" ) { // the related item was not found
enhanced_itemfielddata += relatedUUIDs[j] + "<br>";
} else {
var tmp_str = an_item_data["Type"] + " " + an_item_data["Identifier"] + " - " + an_item_data["Title"];
enhanced_itemfielddata += "<a href='javascript:Dialog.showItemDataDialog(\"" + relatedUUIDs[j] + "\",true);'>" + tmp_str + "</a>" + "<br>";
}
}
} else {
enhanced_itemfielddata = itemfielddata.replaceAll("\n","<br>");
}
// Enhance field text: substitute reference-titles with reference-links
if( field_name.localeCompare("Description")==0 || field_name.localeCompare("Additional bibliography")==0 || field_name.localeCompare("Bibliography")==0) {
for( let ref_idx=0; ref_idx<ReferenceLinks.length; ref_idx++ ) {
var a_text = ReferenceLinks[ref_idx]["text"];
var an_anchor = '<a target="_blank" href="' + ReferenceLinks[ref_idx]["link"] + '">' + a_text + "</a>";
enhanced_itemfielddata = enhanced_itemfielddata.replaceAll( a_text, an_anchor );
}
}
// Auto-fill some fields when they are empty
if( field_name.localeCompare("Photographer")==0 ) {
extra_classes += " LicenseInfo";
if(enhanced_itemfielddata.trim().length == 0) enhanced_itemfielddata = General_Photographer;
} else if( field_name.localeCompare("Data Owner")==0 ) {
extra_classes += " LicenseInfo";
if(enhanced_itemfielddata.trim().length == 0) enhanced_itemfielddata = General_DataOwner;
} else if( field_name.localeCompare("Data License")==0 ) {
extra_classes += " LicenseInfo";
if(enhanced_itemfielddata.trim().length == 0) enhanced_itemfielddata = General_DataLicense;
}
// calculate textbox height according to number of letters (70 letters = 1 line)
var num_of_textbox_lines = (itemfielddata.match(/\n/g) || []).length + 1;
if( itemfielddata.length >= 70 && num_of_textbox_lines < 2 ) num_of_textbox_lines = Math.floor(itemfielddata.length/70) + 1; // compensate for large text without new lines
if( num_of_textbox_lines > 8 ) num_of_textbox_lines = 8; // limit maximum textbox size
//// construct html and css for the item fields
s += "<div class='"+extra_classes+"' style='grid-column:1;' title='"+Utils.getFieldDescription(field_name)+"'><b>" + Utils.NameToAlias(field_name) + "</b></div>";
s += "<div style='grid-column:2;'>";
s += "<div class='dialog_itemfield"+extra_classes+"' id='" + ItemData["IdentifierUUID"] + "_" + field_name + "' onclick=\"UpdateGUI_forFieldAlteration('" + ItemData['IdentifierUUID'] + "', '" + field_name + "');\"";
if( num_of_textbox_lines > 1 ) s += " style='min-height:" + (num_of_textbox_lines*18) + "px;' ";
s += ">";
s += enhanced_itemfielddata;
s += "</div>";
s += "</div>";
}
//// construct html for the automatically calculated Area of the item
/*
if( typeof ItemData["Location"] != "undefined" && ItemData["Location"].length >= 3 ) {
s += "<div class='ItemArea_inDialog' style='grid-column:1;'><b>" + "Area (m<sup>2</sup>)" + "</b></div>";
s += "<div class='ItemArea_inDialog' style='grid-column:2;'>" + "<div class='dialog_itemfield'>" + (+Area.CalcArea_of_Polygon(ItemData["Location"]).toFixed(2)) + "</div>" + "</div>";
}
*/
//// construct html for the citation link
var citation_anchor = "";
citation_anchor += ServerURL+"app_main.html" + "?id="+UUID;
//citation_anchor += "</a>";
s += "<div class='CitationLink_inDialog' style='grid-column:1;'><b>" + "Citation Link" + "</b></div>";
s += "<div class='CitationLink_inDialog' style='grid-column:2;'>" + "<div class='dialog_itemfield CitationLink_field'>" + citation_anchor + "</div>" + "</div>";
//// construct html and css for the parent locus of this item
var parentData = getDataBy_UUID( ItemData["RelationBelongsToUUID"] );
if( typeof parentData != 'undefined' ) {
var DisplayTheField = true;
var VAL = "";
var sub_heading = "Locus information";
if( ItemData["Type"].localeCompare("Locus") == 0) sub_heading = "Feature information";
s += "<div class='parentData_inDialog' style='grid-column:1;'><b>" + "" + "</b></div>";
s += "<div class='parentData_inDialog' style='grid-column:1;'><b>" + "<a class href='javascript:Dialog.showItemDataDialog(\""+parentData["IdentifierUUID"]+"\",true)'> <h2><u>" + sub_heading + "</u></h2></a>" + "</b></div>";
//
s += "<div class='parentData_inDialog' style='grid-column:1;'><b>" + "Identifier" + "</b></div>";
s += "<div class='parentData_inDialog' style='grid-column:2;'>" + "<div class='dialog_itemfield'>" + parentData["Identifier"] + "</div>" + "</div>";
//
s += "<div class='parentData_inDialog' style='grid-column:1;'><b>" + "Title" + "</b></div>";
s += "<div class='parentData_inDialog' style='grid-column:2;'>" + "<div class='dialog_itemfield'>" + parentData["Title"] + "</div>" + "</div>";
//
s += "<div class='parentData_inDialog' style='grid-column:1;'><b>" + "Source" + "</b></div>";
s += "<div class='parentData_inDialog' style='grid-column:2;'>" + "<div class='dialog_itemfield'>" + parentData["Source"] + "</div>" + "</div>";
//
if( typeof parentData["Square"] == "undefined" ) VAL = ""; else VAL = parentData["Square"];
DisplayTheField = true;
if(TheUsername.length==0 || TheUsername.toLowerCase().localeCompare("guest")==0) { // Hide empty fields from the Guest users
if( VAL.length == 0 ) DisplayTheField = false;
}
if( DisplayTheField ) {
s += "<div class='parentData_inDialog' style='grid-column:1;'><b>" + "Square" + "</b></div>";
s += "<div class='parentData_inDialog' style='grid-column:2;'>" + "<div class='dialog_itemfield'>" + VAL + "</div>" + "</div>";
}
//
if( typeof parentData["CoverageTemporal"] == "undefined" ) VAL = ""; else VAL = parentData["CoverageTemporal"];
DisplayTheField = true;
if(TheUsername.length==0 || TheUsername.toLowerCase().localeCompare("guest")==0) { // Hide empty fields from the Guest users
if( VAL.length == 0 ) DisplayTheField = false;
}
if( DisplayTheField ) {
s += "<div class='parentData_inDialog' style='grid-column:1;'><b>" + "CoverageTemporal" + "</b></div>";
s += "<div class='parentData_inDialog' style='grid-column:2;'>" + "<div class='dialog_itemfield'>" + VAL + "</div>" + "</div>";
}
//
if( typeof parentData["CoverageEarliest"] == "undefined" ) VAL = ""; else VAL = parentData["CoverageEarliest"];
DisplayTheField = true;
if(TheUsername.length==0 || TheUsername.toLowerCase().localeCompare("guest")==0) { // Hide empty fields from the Guest users
if( VAL.length == 0 ) DisplayTheField = false;
}
if( DisplayTheField ) {
s += "<div class='parentData_inDialog' style='grid-column:1;'><b>" + "CoverageEarliest" + "</b></div>";
s += "<div class='parentData_inDialog' style='grid-column:2;'>" + "<div class='dialog_itemfield'>" + VAL + "</div>" + "</div>";
}
//
if( typeof parentData["CoverageLatest"] == "undefined" ) VAL = ""; else VAL = parentData["CoverageLatest"];
DisplayTheField = true;
if(TheUsername.length==0 || TheUsername.toLowerCase().localeCompare("guest")==0) { // Hide empty fields from the Guest users
if( VAL.length == 0 ) DisplayTheField = false;
}
if( DisplayTheField ) {
s += "<div class='parentData_inDialog' style='grid-column:1;'><b>" + "CoverageLatest" + "</b></div>";
s += "<div class='parentData_inDialog' style='grid-column:2;'>" + "<div class='dialog_itemfield'>" + VAL + "</div>" + "</div>";
}
//
if( typeof parentData["RelationIsAboveUUID"] == "undefined" ) {
VAL = "";
} else {
var UUIDs = parentData["RelationIsAboveUUID"][0].split("\n");
for(let idx=0; idx<UUIDs.length; idx++) {
var Item_above = getDataBy_UUID( UUIDs[idx] );
if( Item_above != null ) {
var info_of_Item_above = Item_above["Identifier"] + " - " + Item_above["Title"];
if(idx > 0) VAL += "<br>";
VAL = "<a href='javascript:Dialog.showItemDataDialog(\"" + parentData["RelationIsAboveUUID"][0] + "\",true)'>" + info_of_Item_above + "</a>";
}
}
}
DisplayTheField = true;
if(TheUsername.length==0 || TheUsername.toLowerCase().localeCompare("guest")==0) { // Hide empty fields from the Guest users
if( VAL.length == 0 ) DisplayTheField = false;
}
if( DisplayTheField ) {
s += "<div class='parentData_inDialog' style='grid-column:1;'><b>" + "is above of" + "</b></div>";
s += "<div class='parentData_inDialog' style='grid-column:2;'>" + "<div class='dialog_itemfield'>" + VAL + "</div>" + "</div>";
}
//
if( typeof parentData["RelationIsBelowUUID"] == "undefined" ) {
VAL = "";
} else {
var UUIDs = parentData["RelationIsBelowUUID"][0].split("\n");
for(let idx=0; idx<UUIDs.length; idx++) {
var Item_below = getDataBy_UUID( UUIDs[idx] );
if( Item_below != null ) {
var info_of_Item_below = Item_below["Identifier"] + " - " + Item_below["Title"];
if(idx > 0) VAL += "<br>";
VAL = "<a href='javascript:Dialog.showItemDataDialog(\"" + parentData["RelationIsBelowUUID"][0] + "\",true)'>" + info_of_Item_below + "</a>";
}
}
}
DisplayTheField = true;
if(TheUsername.length==0 || TheUsername.toLowerCase().localeCompare("guest")==0) { // Hide empty fields from the Guest users
if( VAL.length == 0 ) DisplayTheField = false;
}
if( DisplayTheField ) {
s += "<div class='parentData_inDialog' style='grid-column:1;'><b>" + "is below of" + "</b></div>";
s += "<div class='parentData_inDialog' style='grid-column:2;'>" + "<div class='dialog_itemfield'>" + VAL + "</div>" + "</div>";
}
}
// Action Buttons - Set Coordinates
if( TheAccessLevels.toLowerCase().includes(",all,") ) {
var SetCoordinatesBtn_HoverText = "Set New Coordinates";
try {
if( ItemData["Location"] != null && ItemData["Location"].length > 0 ) {
SetCoordinatesBtn_HoverText += "\n\n";
for (let i=0; i<ItemData["Location"].length; i++) {
SetCoordinatesBtn_HoverText += ItemData["Location"][i]["X"] + " " + ItemData["Location"][i]["Y"] + " " + ItemData["Location"][i]["Z"] + "\n";
}
}
} catch(ex) { }
s += "<div id='ItemInfoDialog_ActionButtons_Label' class='visible-to-admin-only' style='grid-column:1;'><b>Action Buttons</b></div>";
s += "<div id='ItemInfoDialog_ActionButtons' style='grid-column:2;'>";
s += " <input type='image' class='action_btn' id='SetCoordinates_Btn' title='"+SetCoordinatesBtn_HoverText+"' src='images/system/location.png' onclick='document.getElementById(\"target_button\").style.display=\"inline\"; map.ManualCoordinatesMode=true; map.ItemUUID_forManualCoordinates=\""+ItemData["IdentifierUUID"]+"\"; map.ItemIdentifier_forManualCoordinates=\""+ItemData["Identifier"]+"\"; map.drawWorld(); $(\"#itemInfoDialog\").dialog(\"close\"); map.get_canvas().focus();'>";
s += " <input type='image' class='action_btn' id='EditRelations_Btn' title='"+"Edit the BelongsTo & Includes relations of this item with other items"+"' src='images/system/linkage.png' onclick='Dialog.Display_ItemRelations_Dialog(\""+ItemData["IdentifierUUID"]+"\");'>";
if( TheAccessLevels.toLowerCase().includes(",admin,") ) {
s += "<input type='image' class='action_btn' id='showJSON_Btn' title='"+"Display the JSON data of this item"+"' src='images/system/json.png' onclick='Dialog.Display_ItemJSON_Dialog(\""+ItemData["IdentifierUUID"]+"\");'>";
}
s += "</div>";
}
//// display
document.getElementById("itemInfoDialog").innerHTML = s;
}
/**
* Toggles the Selected field of an item, and updates the GUI
* @arg IdentifierUUID (String) the unique id of an item
*/
static alterSelectedState( IdentifierUUID ) {
var ItemData = getDataBy_UUID( IdentifierUUID );
if ( document.getElementById(IdentifierUUID+"_"+"SelectedCheckbox").checked ) {
document.getElementById(IdentifierUUID+"_"+"SelectedLabel").style.color = "gold";
ItemData["Selected"] = true;
num_of_selected_items++;
map.HighlightItempOnMap( IdentifierUUID );
updateInfoBar();
map.drawWorld();
updateSelectedItemsOnList();
Scroll_ItemsList( IdentifierUUID );
} else {
document.getElementById(IdentifierUUID+"_"+"SelectedLabel").style.color = "black";
ItemData["Selected"] = false;
num_of_selected_items--;
updateInfoBar();
map.drawWorld();
updateSelectedItemsOnList();
}
}
/**
* Displays a dialog which allows the user to add a new item.
* Only the most important fields are proposed to the user. Photos and more information can be added after the creation of the new item.
* The field values are combo-boxes (datalists) proposing the already available values.
* The 'Identifier' field automatically proposes the next larger number while the user is typing.
* The dialog makes sure that the typed Identifier is unique.
*/
static show_NewItem_Dialog() {
var DialogTitle = "";
DialogTitle = "New item";
var dialog_obj = $( "#itemInfoDialog" ).dialog(
{ height: 360,
width: 600,
title: DialogTitle,
buttons: [
{ text: 'Close', id: 'itemInfoDialogCloseBtn', class: 'dialogCloseBtn',
click: function () {
$("#itemInfoDialog").dialog('close');
}
},
{ text: 'Save', id: 'iteminfodialogSaveBtn', class: 'dialogSaveBtn',
click: function () {
document.getElementById("masterContainer").style.cursor = "wait";
// ensure that the Identifier is unique at the client side
var new_Identifier = document.getElementById("NEW_Identifier").value;
if( DoesThisIdentifierExists( new_Identifier ) ) {
alert("Cannot save changes:\nThe identifier '" + new_Identifier + "' already exists.\nPlease choose a unique one." );
return; // <<<<<<<<
}
// ensure that the parent item exists
var parent_identifier = document.getElementById("NEW_RelationBelongsTo").value.trim();
if( parent_identifier.length > 0 ) {
var parent_item = getDataBy_Identifier( parent_identifier );
if( parent_item == null || typeof parent_item == "undefined" ) {
alert( "Cannot save changes:\nThe parent item '" + document.getElementById("NEW_RelationBelongsTo").value + "' does not exist." );
return; // <<<<<<<<
}
}
// ensure that the Identifier is unique at the server side
$.ajax({
url: phpURL,
type: "POST",
data: { Command: "IdentifierExistsInDB", Arg1: new_Identifier }
}).done(function( msg ) {
if( msg.trim().toLowerCase().localeCompare("true") == 0 ) {
alert( "Cannot save changes:\nAn item with Identifier '" + new_Identifier + "' already exists in the database." );
} else {
// construct a new UUID
var newUUID = constructNewUUID(); // this function resides at data.js
// construct new json item
var jsonData = {};
jsonData["IdentifierUUID"] = newUUID;
jsonData["Identifier"] = document.getElementById("NEW_Identifier").value;
jsonData["Trench"] = document.getElementById("NEW_Trench").value;
jsonData["Type"] = document.getElementById("NEW_Type").value;
jsonData["Category"] = document.getElementById("NEW_Category").value;
// construct belongs-to relation by saving the relation to the parent item
// BE AWARE: saving for the parent item is taken care by the server when the new item is saved
var parent_identifier = document.getElementById("NEW_RelationBelongsTo").value.trim();
var parent_UUID;
for (let i = 0; i < ExcData.length; i++) { // Identifier may not be unique, so make sure that it is also a Locus
if ( ExcData[i]["Identifier"].localeCompare(parent_identifier)==0 && ExcData[i]["Type"].localeCompare("Locus")==0 ) {
parent_UUID = ExcData[i]["IdentifierUUID"];
break;
}
}
var parent_item = getDataBy_UUID( parent_UUID );
if( parent_item != null && typeof parent_item != "undefined" ) {
jsonData[ "RelationBelongsToUUID" ] = [ parent_item["IdentifierUUID"] ];
if( parent_item.hasOwnProperty("RelationIncludesUUID")==false || typeof parent_item["RelationIncludesUUID"] == "undefined") {
parent_item["RelationIncludesUUID"] = [ newUUID ];
} else if( parent_item["RelationIncludesUUID"].includes( newUUID ) == false ) {
parent_item["RelationIncludesUUID"][0] += "\n"+newUUID;
}
if( parent_item["Type"].localeCompare("Locus")==0 ) { // some fields take automatically their value from the parent item when the parent item is a Locus
jsonData["Square"] = parent_item["Square"];
//if( jsonData["Category"].localeCompare("Coin")!=0 ) jsonData["CoverageEarliest"] = parent_item["CoverageEarliest"];
//if( jsonData["Category"].localeCompare("Coin")!=0 ) jsonData["CoverageLatest"] = parent_item["CoverageLatest"];
if( jsonData["Type"].localeCompare("Partition")==0 ) jsonData["Title"] = parent_item["Title"];
}
}
// ********** Save changes to server **********
SaveItem(jsonData);
}
document.getElementById("masterContainer").style.cursor = "pointer";
});
}
}
],
open: function(event, ui) { $( this ).siblings( ".ui-dialog-titlebar" ).find( "button" ).focus(); }
}
);
dialog_obj.prev(".ui-dialog-titlebar").css("background", "black");
dialog_obj.prev(".ui-dialog-titlebar").css("color", "white");
//// scroll to the top
$("#itemInfoDialog").scrollTop("0");
///// fill dialog contents with data
var s = "";
// ---------------- images row - begin ---------
s += "<div style='grid-column: 1 / 3; color:darkblue;'> <i>Photos and more information can be added after the creation of the new item.</i> </div>";
// ---------------- images row - end -----------
// ~~~~~~~~~~~~~~~~~ Display the new item's basic fields ~~~~~~~~~~~~~~~~~
//////// FIELD: Identifier
s += "<div style='grid-column:1;' title='The unique inventory number for the object. The application proposes the next number once the letter that corresponds to the type of find is entered: A=architecture, B=bronze, C=coin, G=glass, I=inscription, IL=iron and lead, J=jewelry, L=lamp, O=organic, P=pottery, ST=stone, T=terracotta. There is no space between the letter and the number. Caps matter.'><b>" + "Identifier" + "</b></div>";
s += "<div style='grid-column:2;'>";
s += "<input type='text' class='dialog_itemfield' id='" + "NEW_Identifier" + "'>";
s += "</div>";
//////// FIELD: Trench
s += "<div style='grid-column:1;' title='A trench is a collection of items. This feild has to be filled, so that the item can be searched.'><b>" + "Trench" + "</b></div>";
s += "<div style='grid-column:2;'>";
s += "<input type='text' id='" + "NEW_Trench" + "' class='dialog_itemfield' name='" + "NEW_Trench" + "' list='" + "Trench_list" + "'/>";
s += "<datalist id='" + "Trench_list" + "'>";
for( let i=0; i<list_of_all_Trenches.length; i++ ) s += "<option value='" + list_of_all_Trenches[i] + "'>" + list_of_all_Trenches[i] + "</option>";
s += "</datalist>";
s += "</div>";
//////// FIELD: Type
s += "<div style='grid-column:1;' title='The type of the object. Start typing or double click to display the existing types.'><b>" + "Type" + "</b></div>";
s += "<div style='grid-column:2;'>";
s += "<input type='text' id='" + "NEW_Type" + "' class='dialog_itemfield' name='" + "NEW_Type" + "' list='" + "Type_list" + "'/>";
s += "<datalist id='" + "Type_list" + "'>";
for( let i=0; i<list_of_all_Types.length; i++ ) s += "<option value='" + list_of_all_Types[i] + "'>" + list_of_all_Types[i] + "</option>";
s += "</datalist>";
s += "</div>";
//////// FIELD: Category
s += "<div style='grid-column:1;' title='A Category describes an item more specifically than its Type'><b>" + "Category" + "</b></div>";
s += "<div style='grid-column:2;'>";
s += "<input type='text' id='" + "NEW_Category" + "' class='dialog_itemfield' name='" + "NEW_Category" + "' list='" + "Category_list" + "'/>";
s += "<datalist id='" + "Category_list" + "'>";
for( let i=0; i<list_of_all_Categories.length; i++ ) s += "<option value='" + list_of_all_Categories[i] + "'>" + list_of_all_Categories[i] + "</option>";
s += "</datalist>";
s += "</div>";
//////// FIELD: RelationBelongsTo
s += "<div style='grid-column:1;' title='The locus in which the object was found. Start typing or double click to display the existing loci.'><b>" + "RelationBelongsTo" + "</b></div>";
s += "<div style='grid-column:2;'>";
s += "<input type='text' id='" + "NEW_RelationBelongsTo" + "' class='dialog_itemfield' name='" + "NEW_RelationBelongsTo" + "' list='" + "Loci_list" + "'/>";
s += "<datalist id='" + "Loci_list" + "'>";
for( let i=0; i<list_of_all_Loci.length; i++ ) s += "<option value='" + list_of_all_Loci[i] + "'>" + list_of_all_Loci[i] + "</option>";
s += "</datalist>";
s += "</div>";
////
document.getElementById("itemInfoDialog").innerHTML = s;
document.getElementById("NEW_Identifier").focus();
// add event listener at the NEW_Identifier field, to propose the next larger number
document.getElementById("NEW_Identifier").addEventListener('keyup',this.IdentifierTextbox_ChangeHandler,false);
}
/*
* Handles the 'Identifier' text-box at the NewItem_Dialog.
* The app automatically proposes:
* - the next larger number while the user is typing.
* - the item Category based on the 1st letter of the Identifier
*/
static IdentifierTextbox_ChangeHandler(e) {
var UserTyped_box = document.getElementById("NEW_Identifier");
var UserTyped_txt = UserTyped_box.value;
if( UserTyped_txt.length == 0 || e.key == "Backspace" || e.key == "Delete") return; // backspace and delete
// calculate the max number among all items starting from the typed characters
var max = -1;
var n = -1;
for (let i = 0; i < ExcData.length; i++) {
if (ExcData[i].hasOwnProperty("Identifier")) {
if( ExcData[i]["Identifier"].startsWith( UserTyped_txt ) ) {
var tmp = ExcData[i]["Identifier"].substr(UserTyped_txt.length);
if( Utils.ContainsInteger( tmp ) ) {
n = parseInt( tmp );
if (n > max) { max = n; }
}
}
}
}
// propose the max number to the user
if( max >= 0 && Utils.ContainsInteger(UserTyped_txt.charAt(UserTyped_txt.length-1))==false ) {
var auto_text = (max+1).toString();
UserTyped_box.value = UserTyped_box.value + auto_text;
UserTyped_box.focus();
UserTyped_box.setSelectionRange(UserTyped_box.value.length-auto_text.length, UserTyped_box.value.length);
}
// ----------- Propose an item Category based on the 1st letter of the Identifier
var first_letter = UserTyped_txt.charAt(0).toUpperCase();
var second_letter = UserTyped_txt.charAt(1).toUpperCase();
var category_txt = "";
if ( first_letter === 'A' ) {
category_txt = "Architecture";
} else if ( first_letter === 'B') {
category_txt = "Bronze";
} else if ( first_letter === 'C' ) {
category_txt = "Coin";
} else if ( first_letter === 'G' ) {
category_txt = "Glass";
} else if ( first_letter === 'I' ) {
if ( second_letter === 'L' ) {
category_txt = "Iron and Lead";
} else {
category_txt = "Inscription";
}
} else if ( first_letter === 'J' ) {
category_txt = "Jewelery";
} else if ( first_letter === 'L' ) {
category_txt = "Lamp";
} else if ( first_letter === 'O' ) {
category_txt = "Organic";
} else if ( first_letter === 'P' ) {
category_txt = "Pottery";
} else if ( first_letter === 'S' ) {
category_txt = "Stove";
} else if ( first_letter === 'T' ) {
category_txt = "Terracotta";
}
if( category_txt.length > 0 ) {
document.getElementById("NEW_Category").value = category_txt;
}
}
/**
* Displays a dialog with information about the Permissions of usage of the data presented in the app.
*/
static Display_Permissions_Dialog() {
var dialog_obj = $( "#MessageDialog" ).dialog(
{ height: 600, width: 460, title: "Permissions",
buttons: [ { text: 'Close', id: 'aboutdialogCloseBtn', class: 'dialogCloseBtn',
click: function () { $("#MessageDialog").dialog('close'); }
} ],
open: function(event, ui) { $( this ).siblings( ".ui-dialog-titlebar" ).find( "button" ).focus(); }
}
);
dialog_obj.prev(".ui-dialog-titlebar").css("background", "teal");
dialog_obj.prev(".ui-dialog-titlebar").css("color", "white");
// create dialog content
var s = "";
if( ExcavationPreferences.hasOwnProperty("Permissions_html") && ExcavationPreferences["Permissions_html"].length>0) {
s = ExcavationPreferences["Permissions_html"];
} else {
s += "<h2>Permissions</h2>";
s += "<p>For permission to use the images in this database, contact the <a href='https://archaeologicalmuseums.gr/en/museum/5df34af3deca5e2d79e8c147/archaeological-museum-of-komotini'>Komotini Archaeological Museum</a>:</p>";
s += "<p>";
s += "Address: 4 A. Symeonidi Str., Komotini 69132<br>";
s += "Telephone: (+30) 2531022411<br>";
s += "E-mail: <a href='mailto:nta@princeton.edu'>efarod@culture.gr</a>";
s += "</p>";
s += "<p>Artifact photography: ©Ephorate of Antiquities of Rhodope, Ministry of Culture of the Hellenic Republic<br><br>Illustrations: Christina Kolb</p>";
}
document.getElementById("MessageDialogContent").innerHTML = s;
document.getElementById("MessageDialog").style.backgroundColor = "honeydew";
}
/**
* Displays a dialog after the user clicks on the export-data menu. It lets the user choose the export format.
*/
static ShowExportPreferencesDialog() {
var dialog_obj = $( "#MessageDialog" ).dialog(
{ height: 380, width: 340, title: "Export Data",
buttons: [ { text: 'Cancel', id: 'aboutdialogCloseBtn', class: 'dialogCloseBtn',
click: function () { $("#MessageDialog").dialog('close'); }
} ],
open: function(event, ui) { $( this ).siblings( ".ui-dialog-titlebar" ).find( "button" ).focus(); }
}
);
dialog_obj.prev(".ui-dialog-titlebar").css("background", "teal");
dialog_obj.prev(".ui-dialog-titlebar").css("color", "white");
// create dialog content
var s = "";
if( num_of_selected_items == 0 ) {
s += "<h2>Export data of all items</h2>";
} else {
s += "<h3>Export data of " + num_of_selected_items + " selected items</h3>";
}
s += "<p>Choose the format of the exported file:</p>";
s += "<p><button id='export_csv_button' class='exportFormatBtn' onclick='$(\"#MessageDialog\").dialog(\"close\");ExportData_CSV();'>Tab delimeted CSV</button></p>";
s += "<p><button id='export_msword_button' class='exportFormatBtn' onclick='$(\"#MessageDialog\").dialog(\"close\");ExportData_MSWORD();'>MS-Word</button></p>";
document.getElementById("MessageDialogContent").innerHTML = s;
document.getElementById("MessageDialog").style.backgroundColor = "lightseagreen";
}
/**
* Displays a dialog with information about the application and the people involved in the project.
*/
static DisplayAboutDialog() {
var dialog_obj = $( "#MessageDialog" ).dialog(
{ height: 600, width: 460, title: "About",
buttons: [ { text: 'Close', id: 'aboutdialogCloseBtn', class: 'dialogCloseBtn',
click: function () { $("#MessageDialog").dialog('close'); }
} ],
open: function(event, ui) { $( this ).siblings( ".ui-dialog-titlebar" ).find( "button" ).focus(); }
}
);
dialog_obj.prev(".ui-dialog-titlebar").css("background", "teal");
dialog_obj.prev(".ui-dialog-titlebar").css("color", "white");
// create dialog content
var s = "";
s += "<h2>WebDig</h2>";
s += "<p>WebDig is an online web application which facilitates the processing and publication of archaelogical excavation data.";
s += "The software can list and sort the archaeological finds, their loci, and associated information.";
s += "<p>The data is the result of the on-site work of the archaeologists with the help of the <a href='https://idig.tips/'>iDig application</a> for iPads and of the after-excavation processing.</p>";
s += "<h3>Contributors</h3>";
s += "<p><a href='mailto:nta@princeton.edu'><b>Nathan T. Arrington</b></a><br>"; // ---------------
s += "Associate Professor of Classical Archaeology<br>";
s += "Princeton University<br>Department of Art and Archaeology<br>Green Hall 2N9<br>Princeton, NJ 08544<br>phone: (609) 258-1322<br>fax: (609) 258-0103<p>";
s += "<p><a href='mailto:mtasaklaki@yahoo.gr'><b>Marina Tasaklaki</b></a><br>"; // ---------------
s += "Archaeologist, Numismatist<br>Ephorate of Antiquities of Rhodope, Greece";
s += "<p><a href='mailto:b.dimitris@gmail.com'><b>Dimitris Baloukidis</b></a><br>Software Developer</p>";
s += "<br><h3>Software Libraries used</h3>";
s += "<p>";
s += "<a href='https://jquery.com/'>jQuery library</a><br>";
s += "<a href='https://github.com/nodeca/pako'>Pako compression library</a><br>";
s += "<a href='http://www-cs-students.stanford.edu/~tjw/jsbn/'>Jsbn encryption library</a><br>";
//s += "<a href='https://github.com/dolanmiu/docx'>Docx word document generation library</a><br>";
//s += "<a href='https://github.com/eligrey/FileSaver.js/'>FileSaver document saving library</a><br>";
s += "<a href='https://plotly.com/javascript/'>Plotly graphing library</a><br>";
s += "<a href='https://github.com/PHPOffice/PHPWord'>PHPWord MS-Word document generation library</a><br>";
s += "<a href='https://github.com/codeshackio/multi-select-dropdown-js'>multiselect-dropdown</a><br>";
s += "</p>";
s += "<br><h3>License</h3>";
s += "<p>To be defined.</p>";
if( ExcavationPreferences.hasOwnProperty("About_html") && ExcavationPreferences["About_html"].length>0) {
s += "<br>" + ExcavationPreferences["About_html"];
}
document.getElementById("MessageDialogContent").innerHTML = s;
document.getElementById("MessageDialog").style.backgroundColor = "honeydew";
}
/**
* Displays a how-to dialog
*/
static Display_HowToOverview_Dialog() {
var dialog_obj = $( "#MessageDialog" ).dialog(
{ height: 555, width: 620, title: "Overview",
buttons: [ { text: 'Close', id: 'howtodialogCloseBtn', class: 'dialogCloseBtn', click: function () { $("#MessageDialog").dialog('close'); } } ],
open: function(event, ui) { $( this ).siblings( ".ui-dialog-titlebar" ).find( "button" ).focus(); }
}
);
dialog_obj.prev(".ui-dialog-titlebar").css("background", "brown"); dialog_obj.prev(".ui-dialog-titlebar").css("color", "white");
var s = "";
s += "<h3>Overview</h3>";
s += "<p>WebDig is an on-line web application that presents the data from the Molyvoti, Thrace, Archaeological Project (MTAP), a co-operation between the Ephorate of Antiquities of Rhodopi and Princeton University / the American School of Classical Studies at Athens. The application aims to disseminate information about the project; to share findings; and to allow scholars, students, and the broader public to engage in contextualized archaeological research. Excavation and survey took place 2013–15, 2019, and 2022–23. The project directors are Nathan Arrington (Princeton University), Domna Terzopoulou (Ephorate of Antiquities of Alexandroupolis), and Marina Tasaklaki (Ephorate of Antiquities of Rhodopi). Further information about the project, the research, and the publications can be found at <a href='https://scholar.princeton.edu/mtap'>https://scholar.princeton.edu/mtap</a>.</p>";
s += "<h4>General</h4>";
s += "<p>The areas of the archaeological site are organized into 'trenches.' On opening the application, the House of Hermes appears. To select a different area, select a different 'trench' at top left. A list of all archaeological finds within the trench can be found at the left side. To search across trenches, select multiple trenches. Clicking on a listed item displays a box which offers more information about the item. Above the list, there is a quick search tool next to magnifying glass, where users can type information or use a drop-down menu to browse. The three-dots menu at the bottom left offers several ways to interact with items, including an advanced search tool. The bar at the top of the screen offers various tools to interact with the map, as well as the user-specific options and the help menu.</p>";
s += "<h4>Map</h4>";
s += "<p>The items listed at the left are affected by the search terms. Clicking on an item provides more information on it. In addition, an item can be selected by Ctrl+click (PC) or Cmnd+click (Mac) or by using the three-dot menu. When selected, an item is highlighted yellow and appears on the map. By default, the application displays only the selected items on the map. This option can be altered from the three-dots menu, so that all listed items are displayed. The knife tool displays a dialog with the cross section of the selected items and the measuring tape tool displays distances of the selected items.</p>";
s += "<br><p><a href='video/HowTo_Overview.mp4' target='_blank'>Click here to watch an explanatory video.</a></p>";
document.getElementById("MessageDialogContent").innerHTML = s; document.getElementById("MessageDialog").style.backgroundColor = "seashell";
}
/**
* Displays a how-to dialog
*/
static Display_HowToChangePassword_Dialog() {
var dialog_obj = $( "#MessageDialog" ).dialog(
{ height: 555, width: 620, title: "How to Change Password",
buttons: [ { text: 'Close', id: 'howtodialogCloseBtn', class: 'dialogCloseBtn', click: function () { $("#MessageDialog").dialog('close'); } } ],
open: function(event, ui) { $( this ).siblings( ".ui-dialog-titlebar" ).find( "button" ).focus(); }
}
);
dialog_obj.prev(".ui-dialog-titlebar").css("background", "brown"); dialog_obj.prev(".ui-dialog-titlebar").css("color", "white");
var s = "";
s += "<h3>How to Change Password</h3>";
s += "<p><ul><li>Click at your username on the upper right corner.</li><li>Select 'Settings'.</li><li>Type your current password and the new password.</li><li>Click the 'Save Changes' button.</li></ul></p>";
s += "<br><p><a href=''>Click here to watch an explanatory video.</a></p>";
document.getElementById("MessageDialogContent").innerHTML = s; document.getElementById("MessageDialog").style.backgroundColor = "seashell";
}
/**
* Displays a how-to dialog
*/
static Display_HowToSearch_Dialog() {
var dialog_obj = $( "#MessageDialog" ).dialog(
{ height: 555, width: 620, title: "How to Search for an item",
buttons: [ { text: 'Close', id: 'howtodialogCloseBtn', class: 'dialogCloseBtn', click: function () { $("#MessageDialog").dialog('close'); } } ],
open: function(event, ui) { $( this ).siblings( ".ui-dialog-titlebar" ).find( "button" ).focus(); }
}
);
dialog_obj.prev(".ui-dialog-titlebar").css("background", "brown"); dialog_obj.prev(".ui-dialog-titlebar").css("color", "white");
var s = "";
s += "<h3>How to Search for an item</h3>";
s += "<p>The search tools are located at the top left of the screen. The items list on the left will contain the search results. The search results can also be rendered on the map if the corresponding setting from the three-dots menu is enabled.</p>";
s += "<p>Clicking on the small triangle displays all available item types and sub-types. Selecting one of them will fill the items list only with items of the respected type. The types are displayed in bold and the sub-types in normal letters. Usually different types are denoted with different color.</p>";
s += "<p>You can search for a specific text by typing in the text box and hitting the enter key. The items list will show only those items which contain the search term in their title, description or identification number. Below the items-list you can see how many items are listed out of total.</p>";
s += "<p>Clicking on the magnifying glass at the right of the text box pops a dialog window which supports a more advanced searching scheme, based on specific data fields. Different search criteria can be typed for each of the fields. Only the items which fulfill all the criteria will be displayed in the items list. Also, the asterisk can be used as a wildcard to be substituted for any other character. For example B3* will display all items whose identifier starts from B3.</p>";
s += "<br><p><a href='video/HowTo_Search.mp4' target='_blank'>Click here to watch an explanatory video.</a></p>";
document.getElementById("MessageDialogContent").innerHTML = s; document.getElementById("MessageDialog").style.backgroundColor = "seashell";
}
/**
* Displays a how-to dialog
*/
static Display_HowToSort_Dialog() {
var dialog_obj = $( "#MessageDialog" ).dialog(
{ height: 555, width: 620, title: "How to sort items in list",
buttons: [ { text: 'Close', id: 'howtodialogCloseBtn', class: 'dialogCloseBtn', click: function () { $("#MessageDialog").dialog('close'); } } ],
open: function(event, ui) { $( this ).siblings( ".ui-dialog-titlebar" ).find( "button" ).focus(); }
}
);
dialog_obj.prev(".ui-dialog-titlebar").css("background", "brown"); dialog_obj.prev(".ui-dialog-titlebar").css("color", "white");
var s = "";
s += "<h3>How to sort the items in the list</h3>";
s += "<p><ul><li>Click on the three-dots menu button.</li><li>Select the 'Sort items' option.</li><li>Choose the desired order of the sorting criteria by dragging and dropping the tabs. The top-most will be the first and most important one.</li><li>Press the OK button.</li></ul></p>";
s += "<p>If for example the two top-most tabs are 'Category' and 'Title' then all items will be sorted by Category and those belonging to the same Category will be sorted by Title.</p>";
s += "<br><p><a href='video/HowTo_Sort.mp4' target='_blank'>Click here to watch an explanatory video.</a></p>";
document.getElementById("MessageDialogContent").innerHTML = s; document.getElementById("MessageDialog").style.backgroundColor = "seashell";
}
/**
* Displays a how-to dialog
*/
static Display_HowToItemInfo_Dialog() {
var dialog_obj = $( "#MessageDialog" ).dialog(
{ height: 555, width: 620, title: "How to view and edit item information",
buttons: [ { text: 'Close', id: 'howtodialogCloseBtn', class: 'dialogCloseBtn', click: function () { $("#MessageDialog").dialog('close'); } } ],
open: function(event, ui) { $( this ).siblings( ".ui-dialog-titlebar" ).find( "button" ).focus(); }
}
);
dialog_obj.prev(".ui-dialog-titlebar").css("background", "brown"); dialog_obj.prev(".ui-dialog-titlebar").css("color", "white");
var s = "";
s += "<h3>How to view and edit item information</h3>";