Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 1 | /** |
Akron | b6685bb | 2018-02-04 00:44:47 +0100 | [diff] [blame] | 2 | * Table representation of token-based |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 3 | * annotations of a match. |
| 4 | */ |
Akron | e51eaa3 | 2020-11-10 09:35:53 +0100 | [diff] [blame] | 5 | "use strict"; |
| 6 | |
Akron | b6685bb | 2018-02-04 00:44:47 +0100 | [diff] [blame] | 7 | define([ |
| 8 | 'match/querycreator', |
| 9 | "util" |
| 10 | ], function (matchQueryCreator) { |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 11 | |
Akron | b6685bb | 2018-02-04 00:44:47 +0100 | [diff] [blame] | 12 | /* |
| 13 | * TODO: |
| 14 | * Create base object for all matchinfo classes! |
| 15 | * TODO: |
| 16 | * Rename to match/annotationtable |
| 17 | */ |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 18 | const _TermRE = new RegExp("^(?:([^\/]+?)\/)?([^:]+?):(.+?)$"); |
| 19 | const d = document; |
| 20 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 21 | return { |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * Create new table view for a match |
| 25 | * based on a snippet string. |
| 26 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 27 | create : function (snippet) { |
| 28 | return Object.create(this)._init(snippet); |
| 29 | }, |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 30 | |
| 31 | // Initialize table based on snippet |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 32 | _init : function (snippet) { |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 33 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 34 | // Create html for traversal |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 35 | const html = d.createElement("div"); |
| 36 | const t = this; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 37 | html.innerHTML = snippet; |
| 38 | |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 39 | t._pos = 0; |
| 40 | t._token = []; |
Akron | b774905 | 2022-07-22 18:03:26 +0200 | [diff] [blame] | 41 | t._anno = []; |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 42 | t._mark = []; |
| 43 | t._markE = undefined; |
| 44 | t._cutted = []; |
| 45 | t._info = []; |
| 46 | t._foundry = {}; |
| 47 | t._layer = {}; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 48 | |
| 49 | // Parse the snippet |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 50 | t._parse(html.childNodes, false); |
Akron | b6685bb | 2018-02-04 00:44:47 +0100 | [diff] [blame] | 51 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 52 | html.innerHTML = ''; |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 53 | return t; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 54 | }, |
Akron | b6685bb | 2018-02-04 00:44:47 +0100 | [diff] [blame] | 55 | |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 56 | |
Akron | b6685bb | 2018-02-04 00:44:47 +0100 | [diff] [blame] | 57 | // TODO: Destroy match! |
| 58 | destroy : function () { |
| 59 | this._matchCreator = undefined; |
| 60 | }, |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 61 | |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 62 | |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 63 | /** |
| 64 | * Length of the table (columns), |
| 65 | * aka the number of tokens |
| 66 | * in the snippet. |
| 67 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 68 | length : function () { |
| 69 | return this._pos; |
| 70 | }, |
| 71 | |
Akron | ad1e46a | 2018-09-19 15:55:40 +0200 | [diff] [blame] | 72 | |
| 73 | /** |
| 74 | * Move the viewport to the match |
| 75 | */ |
| 76 | toMark : function () { |
| 77 | if (this._markE === undefined) |
| 78 | return; |
| 79 | this._markE.scrollIntoView({ |
| 80 | inline: "start", |
| 81 | block: "nearest" |
| 82 | }); |
| 83 | }, |
| 84 | |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 85 | |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 86 | /** |
| 87 | * Get the token in the snippet |
| 88 | * At a given position. |
| 89 | * |
| 90 | * @param pos |
| 91 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 92 | getToken : function (pos) { |
| 93 | if (pos === undefined) |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 94 | return this._token; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 95 | return this._token[pos]; |
| 96 | }, |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 97 | |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 98 | |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 99 | /** |
| 100 | * Get the annotation of a token |
| 101 | * in the snippet based on the position, |
| 102 | * the foundry, and the layer. |
| 103 | * |
| 104 | * @param pos |
| 105 | * @param foundry |
| 106 | * @param layer |
| 107 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 108 | getValue : function (pos, foundry, layer) { |
| 109 | return this._info[pos][foundry + '/' + layer] |
| 110 | }, |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 111 | |
Akron | aeceda7 | 2018-02-02 20:44:06 +0100 | [diff] [blame] | 112 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 113 | // Parse the snippet |
Akron | ad1e46a | 2018-09-19 15:55:40 +0200 | [diff] [blame] | 114 | _parse : function (children, mark) { |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 115 | |
| 116 | // Get all children |
Akron | 678c26f | 2020-10-09 08:52:50 +0200 | [diff] [blame] | 117 | children.forEach(function(c) { |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 118 | const t = this; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 119 | |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 120 | // Create object on position unless it exists |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 121 | if (t._info[t._pos] === undefined) { |
| 122 | t._info[t._pos] = {}; |
Akron | b774905 | 2022-07-22 18:03:26 +0200 | [diff] [blame] | 123 | t._anno[t._pos] = false; |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 124 | }; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 125 | |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 126 | // Store at position in foundry/layer as array |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 127 | const found = t._info[t._pos]; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 128 | |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 129 | // Element with title |
| 130 | if (c.nodeType === 1) { |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 131 | let newMark = mark; |
Akron | ad1e46a | 2018-09-19 15:55:40 +0200 | [diff] [blame] | 132 | |
| 133 | if (c.tagName === 'MARK') { |
| 134 | newMark = true; |
| 135 | } |
| 136 | |
Akron | 083ec57 | 2019-05-16 18:30:40 +0200 | [diff] [blame] | 137 | else if (c.hasAttribute("title") && |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 138 | _TermRE.exec(c.getAttribute("title"))) { |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 139 | |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 140 | // Fill position with info |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 141 | let foundry, layer, value; |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 142 | if (RegExp.$2) { |
| 143 | foundry = RegExp.$1; |
| 144 | layer = RegExp.$2; |
| 145 | } |
| 146 | else { |
| 147 | foundry = "base"; |
| 148 | layer = RegExp.$1 |
| 149 | }; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 150 | |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 151 | value = RegExp.$3; |
| 152 | |
| 153 | if (found[foundry + "/" + layer] === undefined) { |
| 154 | found[foundry + "/" + layer] = [value]; |
| 155 | } |
| 156 | else { |
Akron | 3b253d3 | 2018-07-15 10:16:06 +0200 | [diff] [blame] | 157 | // if (found[foundry + "/" + layer].indexOf(value) === -1) { |
| 158 | if (!found[foundry + "/" + layer].includes(value)) { |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 159 | // Push value to foundry/layer at correct position |
| 160 | found[foundry + "/" + layer].push(value); |
| 161 | }; |
| 162 | } |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 163 | |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 164 | // Set foundry |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 165 | if (t._foundry[foundry] === undefined) |
| 166 | t._foundry[foundry] = {}; |
| 167 | t._foundry[foundry][layer] = 1; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 168 | |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 169 | // Set layer |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 170 | if (t._layer[layer] === undefined) |
| 171 | t._layer[layer] = {}; |
| 172 | t._layer[layer][foundry] = 1; |
Akron | b774905 | 2022-07-22 18:03:26 +0200 | [diff] [blame] | 173 | |
| 174 | t._anno[t._pos] = true; |
Akron | 083ec57 | 2019-05-16 18:30:40 +0200 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | // The current position marks a cut |
| 178 | else if (c.hasAttribute("class") && c.getAttribute("class") == "cutted") { |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 179 | t._cutted.push(t._pos); |
| 180 | t._token[t._pos++] = ""; |
Akron | 083ec57 | 2019-05-16 18:30:40 +0200 | [diff] [blame] | 181 | } |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 182 | |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 183 | // depth search |
| 184 | if (c.hasChildNodes()) |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 185 | t._parse(c.childNodes, newMark); |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 186 | } |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 187 | |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 188 | // Leaf node |
| 189 | // store string on position and go to next string |
| 190 | else if (c.nodeType === 3) { |
Akron | b774905 | 2022-07-22 18:03:26 +0200 | [diff] [blame] | 191 | if (!c.nodeValue.match(/^\s+$/)) { |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 192 | t._mark[t._pos] = mark ? true : false; |
| 193 | t._token[t._pos++] = c.nodeValue; |
Akron | ad1e46a | 2018-09-19 15:55:40 +0200 | [diff] [blame] | 194 | }; |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 195 | }; |
Akron | 678c26f | 2020-10-09 08:52:50 +0200 | [diff] [blame] | 196 | }, this); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 197 | |
| 198 | delete this._info[this._pos]; |
| 199 | }, |
| 200 | |
| 201 | |
| 202 | /** |
| 203 | * Get HTML table view of annotations. |
| 204 | */ |
| 205 | element : function () { |
Akron | 24aa005 | 2020-11-10 11:00:34 +0100 | [diff] [blame] | 206 | if (this._el !== undefined) |
| 207 | return this._el; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 208 | |
| 209 | // First the legend table |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 210 | const wrap = d.createElement('div'); |
Akron | aeceda7 | 2018-02-02 20:44:06 +0100 | [diff] [blame] | 211 | |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 212 | const table = wrap.addE('table'); |
Akron | aeceda7 | 2018-02-02 20:44:06 +0100 | [diff] [blame] | 213 | |
Akron | 24aa005 | 2020-11-10 11:00:34 +0100 | [diff] [blame] | 214 | this._el = wrap; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 215 | |
| 216 | // Single row in head |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 217 | let tr = table.addE('thead').addE('tr'); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 218 | |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 219 | const ah = KorAP.annotationHelper || { "getDesc" : function () {}}; |
| 220 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 221 | // Add cell to row |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 222 | const addCell = function (type, key, value) { |
| 223 | const c = this.addE(type); |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 224 | |
Akron | f2279c4 | 2017-12-21 13:48:46 +0100 | [diff] [blame] | 225 | if (value === undefined) |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 226 | return c; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 227 | |
Akron | f2279c4 | 2017-12-21 13:48:46 +0100 | [diff] [blame] | 228 | if (key && value instanceof Array && value[1] !== undefined) { |
Akron | 4e47d0b | 2017-07-03 17:58:37 +0200 | [diff] [blame] | 229 | |
| 230 | // There are multiple values to add |
Akron | 856af1e | 2017-07-03 19:57:46 +0200 | [diff] [blame] | 231 | c.classList.add('matchkeyvalues'); |
Akron | f2279c4 | 2017-12-21 13:48:46 +0100 | [diff] [blame] | 232 | |
Akron | b50964a | 2020-10-12 11:44:37 +0200 | [diff] [blame] | 233 | let e, anno; |
| 234 | value.forEach(function(v) { |
| 235 | e = c.addE('div'); |
| 236 | e.addT(v); |
| 237 | |
| 238 | anno = ah.getDesc(key, v); |
Akron | f2279c4 | 2017-12-21 13:48:46 +0100 | [diff] [blame] | 239 | |
| 240 | if (anno) |
| 241 | e.setAttribute("title", anno); |
Akron | b50964a | 2020-10-12 11:44:37 +0200 | [diff] [blame] | 242 | }); |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 243 | } |
Akron | f2279c4 | 2017-12-21 13:48:46 +0100 | [diff] [blame] | 244 | |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 245 | else { |
Akron | f2279c4 | 2017-12-21 13:48:46 +0100 | [diff] [blame] | 246 | |
| 247 | if (value instanceof Array) |
| 248 | value = value[0]; |
| 249 | |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 250 | c.addT(value); |
Akron | f2279c4 | 2017-12-21 13:48:46 +0100 | [diff] [blame] | 251 | |
| 252 | // Add tooltip |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 253 | const anno = ah.getDesc(key, value); |
Akron | f2279c4 | 2017-12-21 13:48:46 +0100 | [diff] [blame] | 254 | if (anno) |
| 255 | c.setAttribute("title", anno); |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 256 | }; |
Akron | 8005599 | 2017-12-20 16:30:52 +0100 | [diff] [blame] | 257 | |
| 258 | return c; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 259 | }; |
| 260 | |
| 261 | tr.addCell = addCell; |
| 262 | |
| 263 | // Add header information |
Akron | f2279c4 | 2017-12-21 13:48:46 +0100 | [diff] [blame] | 264 | tr.addCell('th', undefined, 'Foundry'); |
| 265 | tr.addCell('th', undefined, 'Layer'); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 266 | |
| 267 | // Add tokens |
Akron | 678c26f | 2020-10-09 08:52:50 +0200 | [diff] [blame] | 268 | Object.keys(this._token).forEach(function(i) { |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 269 | const surface = this.getToken(i); |
| 270 | const c = tr.addCell('th', undefined, surface); |
Akron | ad1e46a | 2018-09-19 15:55:40 +0200 | [diff] [blame] | 271 | if (this._mark[i]) { |
| 272 | c.classList.add('mark'); |
| 273 | if (this._markE === undefined) { |
| 274 | this._markE = c; |
| 275 | }; |
Akron | 083ec57 | 2019-05-16 18:30:40 +0200 | [diff] [blame] | 276 | } |
Akron | 1a780fe | 2019-05-21 15:59:00 +0200 | [diff] [blame] | 277 | else if (this._cutted[0] == i || this._cutted[1] == i) { |
Akron | 083ec57 | 2019-05-16 18:30:40 +0200 | [diff] [blame] | 278 | c.classList.add('cutted'); |
Akron | ad1e46a | 2018-09-19 15:55:40 +0200 | [diff] [blame] | 279 | }; |
Akron | 5dc3117 | 2019-05-15 18:43:48 +0200 | [diff] [blame] | 280 | |
Akron | b774905 | 2022-07-22 18:03:26 +0200 | [diff] [blame] | 281 | if (!this._anno[i]) { |
| 282 | c.classList.add('no-anno'); |
| 283 | }; |
| 284 | |
Akron | 5dc3117 | 2019-05-15 18:43:48 +0200 | [diff] [blame] | 285 | // In case the title is very long - add a title attribute |
| 286 | if (surface.length > 20) { |
| 287 | c.setAttribute("title", surface) |
| 288 | } |
Akron | 678c26f | 2020-10-09 08:52:50 +0200 | [diff] [blame] | 289 | }, this); |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 290 | |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 291 | const tbody = table.addE('tbody'); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 292 | |
Akron | b50964a | 2020-10-12 11:44:37 +0200 | [diff] [blame] | 293 | let layerList, key, v, value, cell; |
| 294 | |
Akron | ff1b1f3 | 2020-10-18 11:41:29 +0200 | [diff] [blame] | 295 | Object.keys(this._foundry).sort().forEach(function(foundry) { |
Akron | b50964a | 2020-10-12 11:44:37 +0200 | [diff] [blame] | 296 | let layerList = |
Akron | 99713ef | 2017-06-28 18:19:28 +0200 | [diff] [blame] | 297 | Object.keys(this._foundry[foundry]).sort(); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 298 | |
Akron | b50964a | 2020-10-12 11:44:37 +0200 | [diff] [blame] | 299 | layerList.forEach(function(layer) { |
| 300 | |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 301 | tr = tbody.addE('tr'); |
Akron | 99713ef | 2017-06-28 18:19:28 +0200 | [diff] [blame] | 302 | tr.setAttribute('tabindex', 0); |
| 303 | tr.addCell = addCell; |
Akron | f2279c4 | 2017-12-21 13:48:46 +0100 | [diff] [blame] | 304 | tr.addCell('th', undefined, foundry); |
| 305 | tr.addCell('th', undefined, layer); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 306 | |
Akron | b50964a | 2020-10-12 11:44:37 +0200 | [diff] [blame] | 307 | key = foundry + '/' + layer + '='; |
Akron | 8005599 | 2017-12-20 16:30:52 +0100 | [diff] [blame] | 308 | |
Akron | b50964a | 2020-10-12 11:44:37 +0200 | [diff] [blame] | 309 | for (v = 0; v < this.length(); v++) { |
Akron | 8005599 | 2017-12-20 16:30:52 +0100 | [diff] [blame] | 310 | |
| 311 | // Get the cell value |
Akron | b50964a | 2020-10-12 11:44:37 +0200 | [diff] [blame] | 312 | value = this.getValue(v, foundry, layer); |
Akron | 8005599 | 2017-12-20 16:30:52 +0100 | [diff] [blame] | 313 | |
| 314 | // Add cell to row |
Akron | b50964a | 2020-10-12 11:44:37 +0200 | [diff] [blame] | 315 | cell = tr.addCell( |
Akron | 99713ef | 2017-06-28 18:19:28 +0200 | [diff] [blame] | 316 | 'td', |
Akron | f2279c4 | 2017-12-21 13:48:46 +0100 | [diff] [blame] | 317 | key, |
Akron | 8005599 | 2017-12-20 16:30:52 +0100 | [diff] [blame] | 318 | value |
Akron | 99713ef | 2017-06-28 18:19:28 +0200 | [diff] [blame] | 319 | ); |
Akron | ad1e46a | 2018-09-19 15:55:40 +0200 | [diff] [blame] | 320 | |
| 321 | if (this._mark[v]) { |
| 322 | cell.classList.add('mark'); |
| 323 | }; |
Akron | b774905 | 2022-07-22 18:03:26 +0200 | [diff] [blame] | 324 | |
| 325 | if (value === undefined && this._anno[v]) { |
| 326 | cell.classList.add("not-empty"); |
| 327 | }; |
Akron | 99713ef | 2017-06-28 18:19:28 +0200 | [diff] [blame] | 328 | }; |
Akron | b50964a | 2020-10-12 11:44:37 +0200 | [diff] [blame] | 329 | }, this); |
| 330 | }, this); |
Akron | b6685bb | 2018-02-04 00:44:47 +0100 | [diff] [blame] | 331 | |
| 332 | // Add query creator |
Akron | 24aa005 | 2020-11-10 11:00:34 +0100 | [diff] [blame] | 333 | this._matchCreator = matchQueryCreator.create(this._el); |
Akron | b6685bb | 2018-02-04 00:44:47 +0100 | [diff] [blame] | 334 | |
Akron | 24aa005 | 2020-11-10 11:00:34 +0100 | [diff] [blame] | 335 | return this._el; |
Akron | aeceda7 | 2018-02-02 20:44:06 +0100 | [diff] [blame] | 336 | }, |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 337 | }; |
| 338 | }); |