blob: 05e1f3b04b4dd76231655ba8bc11888e077d569a [file] [log] [blame]
define(['util'], function () {
/*
author, editor title, subTitle textSigle
in corpusAuthor (corpusEditor), corpusTitle, corpusSubTitle, corpusSigle
in docAuthor (docEditor), docTitle, docSubTitle, docSigle
publisher
reference
creationDate
foundries
keywords
textClass
textColumn
textDomain
textType
textTypeArt
textTypeRef
language
license
pages
pubDate
layerInfo
tokenSource
biblEditionStatement
fileEditionStatement
*/
// Localization values
const loc = KorAP.Locale;
loc.METADATA = loc.METADATA || 'Metadata';
return {
/**
* Create new match object
*/
create : function (match, fields) {
return Object.create(this)._init(match, fields);
},
/**
* Initialize object
*/
_init : function (match, fields) {
this._match = match;
this._fields = fields;
// this.opened = false;
return this;
},
/**
* Get match object
*/
match : function () {
return this._match;
},
/**
* Create match reference view.
*/
element : function () {
if (this._element !== undefined)
return this._element;
if (this._fields === null)
return;
var metaDL = document.createElement('dl');
this._element = metaDL;
var fields = this._fields;
// TODO:
// This should only remember array positions by index
// and keep all other field information intact
var metaInfo = {};
for (var i in fields) {
var value = fields[i].value;
if (value instanceof Array) {
metaInfo[fields[i].key] = value.join(", ");
}
else {
metaInfo[fields[i].key] = value;
};
};
// console.log(fields);
// TODO: Meta fields should be separated
var keys = Object.keys(metaInfo);
for (var i in keys.sort()) {
var k = keys[i];
if (k !== "UID" &&
k !== "corpusID" &&
k !== "docID" &&
k !== "textID" &&
/*
k !== "corpusSigle" &&
k !== "docSigle" &&
*/
k !== "layerInfos") {
var metaL = document.createElement('div');
metaL.addE('dt').addT(k);
metaL.addE('dd').addT(metaInfo[k]);
metaDL.appendChild(metaL);
};
};
return this._element;
}
};
});