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