-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCatTreeLite.html
813 lines (680 loc) · 26.3 KB
/
CatTreeLite.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
<!DOCTYPE html>
<html lang="zh-tw">
<head>
<title>CatTree Lite</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.8/themes/default/style.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jstree-bootstrap-theme@1.0.1/src/themes/proton/style.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.18/css/dataTables.bootstrap4.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.18/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.18/js/dataTables.bootstrap4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.8.2/xlsx.full.min.js"></script>
<style type='text/css'>
button{
border-radius:5px;
background-color:teal;
color:white;
padding: 1.5px 1.5px;
}
</style>
<script>
$(document).ready(function() {
//console.log( "ready!" );
$('#independentToolModal').modal('show');
var url = getUrlParameter('url');
if(url){
if(url.includes('.json')){
$.ajax({
url: url,
type: "GET",
success: function(data) {
var TreeStructures = [];
TreeStructures = data;
var event = {};
event.data = TreeStructures;
receiveMessage(event);
},
error : function(error) {
alert('Error');
}
});
}
}
});
function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
}
function xlsxUpload(e) {
//取得上傳第一個檔案
//var files = e.target.files;
var f = e.files[0];
//使用FileReader讀檔
var reader = new FileReader();
//檔案名稱
var name = f.name;
//onload觸發事件
reader.onload = function (e) {
//對象內資料
var data = e.target.result;
//讀取xlsx資料
var xlsxInJSON = readxlsx(data, 'json');
processXLSX(xlsxInJSON);
//console.log(xlsxInJSON);
//var retcsv = readxlsx(data, 'csv');
$('#independentToolModal').modal('hide');
};
//以BinaryString讀入
reader.readAsBinaryString(f);
}
function readxlsx(inpdata, fmt) {
//讀取xlsx檔
//參數
//inpdata為由input file讀入之data
//fmt為讀取格式,可有"json"或"csv",csv格式之分欄符號為逗號,分行符號為[\n]
//說明
//所使用函式可參考js-xlsx的GitHub文件[https://github.com/SheetJS/js-xlsx]
//to_json
function to_json(workbook) {
var result = {};
workbook.SheetNames.forEach(function (sheetName) {
var roa = XLSX.utils.sheet_to_row_object_array(workbook.Sheets[sheetName]);
if (roa.length > 0) {
result[sheetName] = roa;
}
});
return result;
}
//to_csv
function to_csv(workbook) {
var result = [];
workbook.SheetNames.forEach(function(sheetName) {
var csv = XLSX.utils.sheet_to_csv(workbook.Sheets[sheetName]);
if(csv.length > 0){
result.push('SHEET: ' + sheetName);
result.push('\n');
result.push(csv);
}
});
return result;
}
//讀檔
var workbook = XLSX.read(inpdata, { type: 'binary' });
//轉為json物件回傳
if (fmt === 'json') {
return to_json(workbook);
}
else {
return to_csv(workbook);
}
}
function processXLSX(xlsxInJSON){
//console.log(xlsxInJSON);
var sheetName = [];
for (let key in xlsxInJSON){
if(xlsxInJSON.hasOwnProperty(key)){
sheetName.push(key);
//console.log(`${key} : ${xlsxInJSON[key]}`)
}
}
var buttonHTML = '';
var TreeHTML = '';
for(let key in sheetName){
buttonHTML += `<button class="controlBtn" type="button" bt="${key}">${sheetName[key]}</button>`;
TreeHTML += `<div class="tree" id="CatTree${key}"></div>`;
}
$('#buttonAndTree').append(buttonHTML);
$('#buttonAndTree').append(TreeHTML);
$(".tree").hide();
$(".controlBtn").hide();
if(sheetName.length == 1){
$(".tree").show();
}else{
$(".controlBtn").show();
$("#CatTree0").show();
$(".controlBtn").click(function(){
var getIndex = $(this).attr('bt');
$(".tree").hide();
$("#CatTree"+getIndex).show();
});
}
for(let index in sheetName){
var columnName = new Set();
var numberL = 0;
var DocuSkySearchData = [];
for(let key in xlsxInJSON[sheetName[index]]){
for(let rowKey in xlsxInJSON[sheetName[index]][key]){
if(xlsxInJSON[sheetName[index]][key].hasOwnProperty(rowKey)){
columnName.add(rowKey);
}
}
}
columnName = Array.from(columnName);
//console.log(columnName);
for(let columnNameIndex in columnName){
if(columnName[columnNameIndex].includes("L")){
numberL++;
}
}
for(let i = 1; i <= numberL; i++){
if(!columnName.includes("L"+i)){
alert("缺少/ Missing L"+i);
}
}
//console.log(numberL);
for(let rowIndex in xlsxInJSON[sheetName[index]]){
//console.log(xlsxInJSON[sheetName[index]][rowIndex]);
var DocuSkySearchDataRow = "";
for(let i = 1; i <= numberL; i++){
if(xlsxInJSON[sheetName[index]][rowIndex]["L"+i] && $.trim(xlsxInJSON[sheetName[index]][rowIndex]["L"+i])){
DocuSkySearchDataRow += "/" + xlsxInJSON[sheetName[index]][rowIndex]["L"+i];
}else{
DocuSkySearchDataRow += "/-";
}
}
DocuSkySearchDataRow = DocuSkySearchDataRow.slice(1,DocuSkySearchDataRow.length);
//console.log(DocuSkySearchDataRow);
let isDocuSkySearchDataRowExist = false;
for(let DocuSkySearchDataIndex in DocuSkySearchData){
if(DocuSkySearchData[DocuSkySearchDataIndex].cue == DocuSkySearchDataRow){
DocuSkySearchData[DocuSkySearchDataIndex].cnt += 1;
isDocuSkySearchDataRowExist = true;
break;
}
}
if(!isDocuSkySearchDataRowExist){
DocuSkySearchData.push({cue:DocuSkySearchDataRow, cnt:1});
}
}
var receiveData = {};
receiveData.DocuSkySearch = DocuSkySearchData;
receiveData.id = index;
receiveData.title = sheetName[index];
//console.log(receiveData);
initialTreefromDocuSkySearch(receiveData);
$('#CatTree' + index).on("changed.jstree", function (e, data) {
var i, j;
for(i = 0, j = data.selected.length; i < j; i++) {
var DocuSkySearchDataRow = "";
for(let parentNodeIndex in data.node.parents){
if(data.node.parents[parentNodeIndex] != "0" && data.node.parents[parentNodeIndex] != "#"){
DocuSkySearchDataRow = $('#CatTree' + index).jstree()._model.data[data.node.parents[parentNodeIndex]].text + "/" + DocuSkySearchDataRow;
}
}
DocuSkySearchDataRow += data.node.text.replace(/\(\d+件\)/g,'');
//console.log(sheetName[index]+" "+DocuSkySearchDataRow);
plotCSVTable(sheetName[index],xlsxInJSON[sheetName[index]],DocuSkySearchDataRow);
//console.log(DocuSkySearchDataRow);
/*if(data.node.original.url){
window.open(data.node.original.url);
}*/
}
});
openTreeRoot(index);
}
}
function outputContentValueWithMetadataSetting(columnNameValue,value){
//console.log(columnNameValue+" " +value);
if(columnNameValue.includes("RefId")){
if(value.includes("twgis_") || value.includes("dila_PL") || value.includes("hvd_")){
return `<a href="https://docusky.org.tw/DocuSky/docuTools/DocuGIS/api/lite.html?&id=${value};;;default" target="_blank">DocuGIS Lite</a>`;
}
else if(value.includes("xy=")){
return `${value}`;
}
else if(value.includes("cbdb_")){
let cbdburl = "https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=" + value.split("cbdb_")[1];
return `<a href=${cbdburl} target="_blank">CBDB</a>`;
}
else if(value.includes("dila_A")){
let dilaurl = "https://authority.dila.edu.tw/person/search.php?aid=" + value.split("dila_")[1];
return `<a href=${dilaurl} target="_blank">DILA</a>`;
}
}
else if(columnNameValue.includes("Url")){
let url = new URL(value);
return `<a href="${value}" target="_blank">${url.hostname}</a>`;
}
else if(columnNameValue.includes("IiifManifest")){
return `<a href="${value}" target="_blank">IiifManifest</a>`;
}
else{
return value;
}
}
function plotCSVTable(title,sheetContent,nodeSeq){
var columnName = new Set();
for(let key in sheetContent){
for(let rowKey in sheetContent[key]){
if(sheetContent[key].hasOwnProperty(rowKey)){
columnName.add(rowKey);
}
}
}
columnName = Array.from(columnName);
columnName = columnName.sort();
//console.log(columnName);
var thead = "<thead><tr>";
for(index in columnName){
if(!columnName[index].includes("L")){
thead += `<th>${columnName[index]}</th>`;
}
}
thead += "</tr></thead>";
var tbody = "<tbody>"
if(title == nodeSeq){
for( index in sheetContent){
tbody += "<tr>";
for(key in columnName){
if(!columnName[key].includes("L")){
if(sheetContent[index].hasOwnProperty(columnName[key])){
tbody += `<td>${outputContentValueWithMetadataSetting(columnName[key],sheetContent[index][columnName[key]])}</td>`;
//tbody += `<td>${sheetContent[index][columnName[key]]}</td>`;
}else{
tbody += `<td>-</td>`;
}
}
}
tbody += "</tr>";
}
}else{
var nodeArr = nodeSeq.split("/");
var numberNodeArrWithoutEmpty = 0;
for(i in nodeArr){
if(nodeArr[i] != "-"){
numberNodeArrWithoutEmpty += 1;
}
}
for(index in sheetContent){
numberMatch = 0;
for(i in nodeArr){
if(nodeArr[i] != "-" && sheetContent[index].hasOwnProperty("L"+(i*1+1)) && sheetContent[index]["L"+(i*1+1)] == nodeArr[i]){
numberMatch += 1;
}
}
if(numberNodeArrWithoutEmpty == numberMatch){
tbody += "<tr>";
for(key in columnName){
if(!columnName[key].includes("L")){
if(sheetContent[index].hasOwnProperty(columnName[key])){
tbody += `<td>${outputContentValueWithMetadataSetting(columnName[key],sheetContent[index][columnName[key]])}</td>`;
//tbody += `<td>${sheetContent[index][columnName[key]]}</td>`;
}else{
tbody += `<td>-</td>`;
}
}
}
tbody += "</tr>";
}
}
}
tbody += "</tbody>";
//alert(thead);
//alert(tbody);
//console.log(columnName)
$('#CSVTable').DataTable().destroy();
$('#CSVTable').html(thead+tbody);
$('#CSVTable').DataTable({
paging:true,
searching:true,
info:true,
});
}
function initialTreefromTreeStructure(receiveData){
if(receiveData.theme == 'original'){
$('#CatTree' + receiveData.id).jstree({
'core' : {
'data' : receiveData.TreeStructure
},
'plugins': ['search'],
'search': {
'show_only_matches': true,
'show_only_matches_children': true
}
});
}
else if(receiveData.theme == 'dark'){
$('#CatTree' + receiveData.id).jstree({
'core' : {
'data' : receiveData.TreeStructure,
'themes': {
'responsive': true
}
},
'plugins': ['search'],
'search': {
'show_only_matches': true,
'show_only_matches_children': true
}
});
}
else if(receiveData.theme == 'proton'){
$('#CatTree' + receiveData.id).jstree({
'core' : {
'data' : receiveData.TreeStructure,
'themes': {
'name': 'proton',
'responsive': true
}
},
'plugins': ['search'],
'search': {
'show_only_matches': true,
'show_only_matches_children': true
}
});
}
else{
$('#CatTree' + receiveData.id).jstree({
'core' : {
'data' : receiveData.TreeStructure,
'themes': {
'name': 'proton',
'responsive': true
}
},
'plugins': ['search'],
'search': {
'show_only_matches': true,
'show_only_matches_children': true
}
});
}
$('#CatTree' + receiveData.id).on("changed.jstree", function (e, data) {
var i, j;
for(i = 0, j = data.selected.length; i < j; i++) {
//console.log(data);
if(data.node.original.url){
window.open(data.node.original.url);
}
}
});
//console.log(receiveData);
openTreeTerm(receiveData);
}
function initialTreefromDocuSkySearch(receiveData){
//console.log(DocuSkySearch);
var TreeStructure = [];
if(receiveData.title){
TreeStructure[0] = {'id': '0', 'parent': '#', 'text': receiveData.title};
}else{
TreeStructure[0] = {'id': '0', 'parent': '#', 'text': 'CatTree Lite'};
}
var TreeStructureAppendInfo = {'id':1};
for(index in receiveData.DocuSkySearch){
//console.log(DocuSkySearch[index].cnt);
//console.log(DocuSkySearch[index]);
var splitArr = receiveData.DocuSkySearch[index].cue.split('/');
var cnt = receiveData.DocuSkySearch[index].cnt;
var url = "";
if(receiveData.DocuSkySearch[index].url){
url = receiveData.DocuSkySearch[index].url;
}
for(indexNode in splitArr){
//console.log(DocuSkySearch[index].cue);
//console.log(splitArr);
if(!isNodeNameinTreeStructure(indexNode,splitArr,TreeStructure)){
//console.log(DocuSkySearch[index].cue.split('/')[indexNode]);
//console.log(splitArr[indexNode]);
//console.log(splitArr);
//console.log(cnt);
//console.log(TreeStructure);
addNodeNametoTreeStructure(indexNode,cnt,url,splitArr,TreeStructure,TreeStructureAppendInfo, receiveData);
}
}
}
//console.log(TreeStructure);
receiveData.TreeStructure = TreeStructure;
initialTreefromTreeStructure(receiveData);
}
function isNodeNameinTreeStructure(indexNode,splitArr,TreeStructure){
if(indexNode==0){
for(index in TreeStructure){
if(TreeStructure[index].text == splitArr[indexNode] && TreeStructure[index].parent==0){
return true;
}
}
return false;
}else{
for(index in TreeStructure){
if(TreeStructure[index].text == splitArr[indexNode]){
//splitArr[indexNode-1] = TreeStructure[TreeStructure[index].parent].text;
//splitArr[indexNode-2] = TreeStructure[TreeStructure[index].parent].text;
var parentID = TreeStructure[index].parent;
for(var i = indexNode-1; i>=0; i--){
if(splitArr[i]==TreeStructure[parentID].text){
parentID = TreeStructure[parentID].parent;
}else{
return false;
}
}
if(parentID==0){
return true;
}
}
}
return false;
}
}
function getParentID(indexNode,splitArr,TreeStructure){
if(indexNode==0){
return 0;
}else{
var parentID = 0;
var grandID = -1;
for(index in TreeStructure){
if(TreeStructure[index].text == splitArr[indexNode-1]){
//splitArr[indexNode-1] = TreeStructure[TreeStructure[index].parent].text;
//splitArr[indexNode-2] = TreeStructure[TreeStructure[index].parent].text;
parentID = TreeStructure[index].id;
grandID = TreeStructure[index].id;
if(splitArr.length>2){
for(var i = indexNode-2; i>=0; i--){
if(splitArr[i]==TreeStructure[TreeStructure[grandID].parent].text){
grandID = TreeStructure[grandID].parent;
}
}
}
/*if(TreeStructure[grandID].parent==0){
return parentID;
}*/
}
}
return parentID;
}
}
function addNodeNametoTreeStructure(indexNode,count,url,splitArr,TreeStructure,TreeStructureAppendInfo, receiveData){
if(indexNode==0 && splitArr.length==1 && count!=0){
if(receiveData.quantifierTerm){
TreeStructure[TreeStructureAppendInfo.id] = {'id': TreeStructureAppendInfo.id, 'parent': '0', 'text': splitArr[indexNode]+`(${count}${receiveData.quantifierTerm})`};
}else{
TreeStructure[TreeStructureAppendInfo.id] = {'id': TreeStructureAppendInfo.id, 'parent': '0', 'text': splitArr[indexNode]+`(${count}件)`};
}
if(url){
TreeStructure[TreeStructureAppendInfo.id].url = url;
}
}else if(indexNode==splitArr.length-1){
var ParentID = getParentID(indexNode,splitArr,TreeStructure);
if(receiveData.quantifierTerm){
TreeStructure[TreeStructureAppendInfo.id] = {'id': TreeStructureAppendInfo.id, 'parent': ParentID, 'text': splitArr[indexNode]+`(${count}${receiveData.quantifierTerm})`};
}else{
TreeStructure[TreeStructureAppendInfo.id] = {'id': TreeStructureAppendInfo.id, 'parent': ParentID, 'text': splitArr[indexNode]+`(${count}件)`};
}
if(url){
TreeStructure[TreeStructureAppendInfo.id].url = url;
}
}else{
var ParentID = getParentID(indexNode,splitArr,TreeStructure);
TreeStructure[TreeStructureAppendInfo.id] = {'id': TreeStructureAppendInfo.id, 'parent': ParentID, 'text': splitArr[indexNode]};
}
TreeStructureAppendInfo.id += 1;
}
function initialTreefromTreeStructureandDocuSkySearch(receiveData){
//console.log(TreeStructure);
var TreeStructurewithCNT = receiveData.TreeStructure;
for(index in receiveData.DocuSkySearch){
var splitArr = receiveData.DocuSkySearch[index].cue.split('/');
var cnt = receiveData.DocuSkySearch[index].cnt;
var ParentID = getParentID(splitArr.length-1,splitArr,TreeStructurewithCNT);
for(indexStructure in TreeStructurewithCNT){
if(TreeStructurewithCNT[indexStructure].text==splitArr[splitArr.length-1] && ParentID==TreeStructurewithCNT[indexStructure].parent){
if(receiveData.quantifierTerm){
TreeStructurewithCNT[indexStructure].text += `(${cnt}${receiveData.quantifierTerm})`;
}else{
TreeStructurewithCNT[indexStructure].text += `(${cnt}件)`;
}
}
}
}
receiveData.TreeStructure = TreeStructurewithCNT;
initialTreefromTreeStructure(receiveData);
}
function openTreeRoot(index){
$("#CatTree" + index).on('loaded.jstree', function() {
$("#CatTree" + index).jstree("open_node", $("#0"));
});
}
function openTreeAll(index){
$("#CatTree" + index).on('loaded.jstree', function() {
$("#CatTree" + index).jstree('open_all');
});
}
function openTreeTerm(receiveData){
if(receiveData.openTreeTerm){
$("#CatTree" + receiveData.id).on('loaded.jstree', function() {
$("#CatTree" + receiveData.id).jstree(true).search(receiveData.openTreeTerm);
});
}
}
function receiveMessage( event ) {
//console.log( 'receiveMessageData', event.data );
if(event.data.length==0){
alert('Error No Tree Data');
return;
}
if(!Array.isArray(event.data)){
processXLSX(event.data);
$('#independentToolModal').modal('hide');
}
else{
var buttonHTML = '';
var TreeHTML = '';
for(index in event.data){
var receiveData = event.data[index];
//console.log(receiveData);
receiveData.id = index;
if(receiveData.title){
buttonHTML += `<button class="controlBtn" type="button" bt="${index}">${receiveData.title}</button>`;
}
else{
buttonHTML += `<button class="controlBtn" type="button" bt="${index}">CatTree Lite ${index}</button>`;
}
TreeHTML += `<div class="tree" id="CatTree${index}"></div>`;
}
$('#buttonAndTree').append(buttonHTML);
$('#buttonAndTree').append(TreeHTML);
for(index in event.data){
var receiveData = event.data[index];
receiveData.id = index;
if(receiveData.DocuSkySearch && receiveData.TreeStructure){
initialTreefromTreeStructureandDocuSkySearch(receiveData);
}else if(receiveData.DocuSkySearch){
initialTreefromDocuSkySearch(receiveData);
}else if(receiveData.TreeStructure){
initialTreefromTreeStructure(receiveData);
}else{
alert('Error No Tree Data');
}
openTreeRoot(receiveData.id);
if(receiveData.openTreeAll){
openTreeAll(receiveData.id);
}
}
$('#independentToolModal').modal('hide');
$('#ShowCSVTable').hide();
$(".tree").hide();
$(".controlBtn").hide();
if(event.data.length == 1){
$(".tree").show();
}else{
$(".controlBtn").show();
$("#CatTree0").show();
$(".controlBtn").click(function(){
var getIndex = $(this).attr('bt');
$(".tree").hide();
$("#CatTree"+getIndex).show();
});
}
}
}
window.addEventListener("message", receiveMessage, false);
</script>
</head>
<body>
<div class="container">
<div class="row">
<div id='buttonAndTree' class="col-lg-3">
</div>
<div class="col-lg-1">
</div>
<div id='ShowCSVTable' class="col-lg-8">
<table id="CSVTable" class="display" style="width:100%">
<thead>
<tr>
<th>歡迎</th>
</tr>
</thead>
<tbody>
<tr>
<td>請點選左方的樹狀圖節點,此表單會顯示節點內的文本資料</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- The ContactModal -->
<div class="modal fade" id="independentToolModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">CatTree Lite</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<p>這是一個用來觀察文件分類的工具<br> (<a href="./ExcelMessageSpecifications.xlsx" target="_blank">Excel 規範表</a>、<a href="./ExcelMessage.xlsx" target="_blank">Excel 範例</a>、<a href="https://hackmd.io/rTNOT6u8QGmswCIhhh0bKg?view" target="_blank">介接說明</a>、<a href="./Test.html" target="_blank">介接示範</a>)</p>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text" id="inputGroupFileAddon01 selectInFile">Upload Excel</span>
</div>
<div class="custom-file">
<input type="file" class="custom-file-input" id="selectInFile" aria-describedby="inputGroupFileAddon01" onchange="xlsxUpload(this)" accept='.xls, .xlsx'>
<label class="custom-file-label" for="inputGroupFileAddon01">Choose file</label>
</div>
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</body>
</html>