blob: 41d40af7e58d987ae76e761d99cc36df78b7a606 [file] [log] [blame]
Akron30ee5142015-06-26 01:50:14 +02001/*
2 author, editor title, subTitle textSigle
3 in corpusAuthor (corpusEditor), corpusTitle, corpusSubTitle, corpusSigle
4 in docAuthor (docEditor), docTitle, docSubTitle, docSigle
5 publisher
6 reference
7 creationDate
8 foundries
9 keywords
10 textClass
11 textColumn
12 textDomain
13 textType
14 textTypeArt
15 textTypeRef
16 language
17 license
18 pages
19 pubDate
20 layerInfo
21 tokenSource
22 biblEditionStatement
23 fileEditionStatement
24*/
Akronbd342982018-01-25 18:01:46 +010025define(['util'], function () {
26
27 // Localization values
28 var loc = KorAP.Locale;
29 loc.METADATA = loc.METADATA || 'Metadata';
30
Akron24866cf2018-01-23 20:22:01 +010031 return {
32
33 /**
34 * Create new match object
35 */
36 create : function (match) {
37 return Object.create(this)._init(match);
38 },
39
40 /**
41 * Initialize object
42 */
43 _init : function (match) {
44 this._match = match;
45 this.opened = false;
46 return this;
47 },
48
49 /**
50 * Get match object
51 */
52 match : function () {
53 return this._match;
54 },
55
56 /**
57 * Create match reference view.
58 */
59 element : function (metaInfo) {
60 if (this._element !== undefined)
61 return this._element;
62
Akronbd342982018-01-25 18:01:46 +010063 var metaTable = document.createElement('div');
Akron24866cf2018-01-23 20:22:01 +010064 metaTable.classList.add('metatable');
65
Akron8b592d42018-01-26 18:33:06 +010066 /*
Akronbd342982018-01-25 18:01:46 +010067 var header = metaTable.appendChild(
68 document.createElement('h6')
69 );
70
71 header.appendChild(
72 document.createElement('div')
73 ).appendChild(
74 document.createTextNode(loc.METADATA)
75 );
Akron8b592d42018-01-26 18:33:06 +010076 */
Akronbd342982018-01-25 18:01:46 +010077
78 var metaDL = metaTable.appendChild(
79 document.createElement('dl')
80 );
81
Akron24866cf2018-01-23 20:22:01 +010082 this._element = metaTable;
83
84 // TODO: Meta fields should be separated
85 var keys = Object.keys(metaInfo);
86 for (var i in keys.sort()) {
87 var k = keys[i];
88 if (k !== "UID" &&
89 k !== "corpusID" &&
90 k !== "docID" &&
91 k !== "textID" &&
Akron8b592d42018-01-26 18:33:06 +010092 /*
Akron24866cf2018-01-23 20:22:01 +010093 k !== "corpusSigle" &&
94 k !== "docSigle" &&
Akron8b592d42018-01-26 18:33:06 +010095 */
Akron24866cf2018-01-23 20:22:01 +010096 k !== "layerInfos") {
97
98 var metaL = document.createElement('div');
99 metaL.appendChild(
100 document.createElement('dt')
101 ).appendChild(
102 document.createTextNode(k)
103 );
104
105 metaL.appendChild(
106 document.createElement('dd')
107 ).appendChild(
108 document.createTextNode(metaInfo[k])
109 );
110
Akronbd342982018-01-25 18:01:46 +0100111 metaDL.appendChild(metaL);
Akron24866cf2018-01-23 20:22:01 +0100112 };
113 };
114
115 return this._element;
116 }
117 };
Akron30ee5142015-06-26 01:50:14 +0200118});