blob: 67a6a8805ea8a63de42a9345cc03e7eb1905e798 [file] [log] [blame]
Akronf2279c42017-12-21 13:48:46 +01001window.KorAP = window.KorAP || {};
2KorAP.annotationHelper = KorAP.annotationHelper || { '-' : [] };
3
Akron80055992017-12-20 16:30:52 +01004define(function () {
Akronf2279c42017-12-21 13:48:46 +01005
6 var ah = KorAP.annotationHelper;
7
8 ah["getDesc"] = function (foundryLayer, value) {
9
10 if (!foundryLayer)
11 return;
12
13 var anno = this[foundryLayer];
14
15 if (!anno)
16 return;
17
18 if (value.indexOf(':') < 0) {
19 value += ' ';
20
21 // Iterate over all annotations and add the descriptions
22 // This is a classic hash-lookup-case, but we have
23 // to deal with lists ...
24 for (var i = 0; i < anno.length; i++) {
25 if (anno[i] &&
26 anno[i][1] == value) {
27 if (anno[i][2])
28 return anno[i][2];
29 else
30 return;
31 };
32 };
33
34 return;
35 }
36 else {
37 var text = '';
38 var v = value.split(":");
39 var l1 = v[0];
40 var l2 = v[1];
41
42 l1 += ':';
43
44 // Add key description
45 for (var i = 0; i < anno.length; i++) {
46 if (anno[i] &&
47 anno[i][1] == l1) {
48 if (anno[i][2])
49 text += anno[i][2];
50 else
51 text += anno[i][0];
52 break;
53 };
54 };
55
56 // Nothinmg found
57 if (text.length === 0)
58 return;
59
60 // Check next level
61 anno = this[foundryLayer + l1];
62
63 l2 += ' ';
64
65 // Add value description
66 for (var i = 0; i < anno.length; i++) {
67 if (anno[i] &&
68 anno[i][1] == l2) {
69 if (anno[i][2])
70 text += ': ' + anno[i][2];
71
72 return text;
73 };
74 };
75 };
76
77 return '';
78 };
79
80 return ah;
Akron80055992017-12-20 16:30:52 +010081});