Akron | 30ee514 | 2015-06-26 01:50:14 +0200 | [diff] [blame] | 1 | /* |
| 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 | */ |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame^] | 25 | define(['util'], function () { |
| 26 | |
| 27 | // Localization values |
| 28 | var loc = KorAP.Locale; |
| 29 | loc.METADATA = loc.METADATA || 'Metadata'; |
| 30 | |
Akron | 24866cf | 2018-01-23 20:22:01 +0100 | [diff] [blame] | 31 | 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 | |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame^] | 63 | var metaTable = document.createElement('div'); |
Akron | 24866cf | 2018-01-23 20:22:01 +0100 | [diff] [blame] | 64 | metaTable.classList.add('metatable'); |
| 65 | |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame^] | 66 | 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 | |
Akron | 24866cf | 2018-01-23 20:22:01 +0100 | [diff] [blame] | 80 | 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 | |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame^] | 107 | metaDL.appendChild(metaL); |
Akron | 24866cf | 2018-01-23 20:22:01 +0100 | [diff] [blame] | 108 | }; |
| 109 | }; |
| 110 | |
| 111 | return this._element; |
| 112 | } |
| 113 | }; |
Akron | 30ee514 | 2015-06-26 01:50:14 +0200 | [diff] [blame] | 114 | }); |