blob: 9462874cfcfa1df51a162f02bd1c06a40e7b7be6 [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
Akronbd342982018-01-25 18:01:46 +010066 var header = metaTable.appendChild(
67 document.createElement('h6')
68 );
69
70 header.appendChild(
71 document.createElement('div')
72 ).appendChild(
73 document.createTextNode(loc.METADATA)
74 );
75
76 var metaDL = metaTable.appendChild(
77 document.createElement('dl')
78 );
79
Akron24866cf2018-01-23 20:22:01 +010080 this._element = metaTable;
81
82 // TODO: Meta fields should be separated
83 var keys = Object.keys(metaInfo);
84 for (var i in keys.sort()) {
85 var k = keys[i];
86 if (k !== "UID" &&
87 k !== "corpusID" &&
88 k !== "docID" &&
89 k !== "textID" &&
90 k !== "corpusSigle" &&
91 k !== "docSigle" &&
92 k !== "layerInfos") {
93
94 var metaL = document.createElement('div');
95 metaL.appendChild(
96 document.createElement('dt')
97 ).appendChild(
98 document.createTextNode(k)
99 );
100
101 metaL.appendChild(
102 document.createElement('dd')
103 ).appendChild(
104 document.createTextNode(metaInfo[k])
105 );
106
Akronbd342982018-01-25 18:01:46 +0100107 metaDL.appendChild(metaL);
Akron24866cf2018-01-23 20:22:01 +0100108 };
109 };
110
111 return this._element;
112 }
113 };
Akron30ee5142015-06-26 01:50:14 +0200114});