|
42 | 42 | forCollection(collection) { |
43 | 43 | const entry = new Entry(this.table, this.id, this.text); |
44 | 44 | entry.collection = collection; |
45 | | - entry.id = this.table.name + '.' + this.id; |
| 45 | + entry.id = this.table.name + "." + this.id; |
46 | 46 | entry.originaltable = entry.originaltable || entry.table; |
47 | 47 | entry.table = collection; |
48 | 48 | return entry; |
|
53 | 53 | } |
54 | 54 |
|
55 | 55 | getIdText() { |
56 | | - return this.collection ? this.id.split('.').at(-1) : this.id; |
| 56 | + return this.collection ? this.id.split(".").at(-1) : this.id; |
57 | 57 | } |
58 | 58 |
|
59 | 59 | getTableRow() { |
|
65 | 65 | a.setAttribute("href", `#${this.table.name}:${this.id}`); |
66 | 66 | a.innerText = this.getIdText(); |
67 | 67 | idTd.appendChild(a); |
68 | | - if(this.collection) { |
| 68 | + if (this.collection) { |
69 | 69 | const space = document.createElement("br"); |
70 | 70 | idTd.appendChild(space); |
71 | 71 |
|
|
198 | 198 |
|
199 | 199 | getAllEntries(seen) { |
200 | 200 | seen = seen || {}; |
201 | | - if(seen[this.name]) { |
| 201 | + if (seen[this.name]) { |
202 | 202 | return []; |
203 | 203 | } |
204 | 204 | seen[this.name] = true; |
205 | 205 |
|
206 | 206 | switch (this.def.entrytype) { |
207 | 207 | case "collection": |
208 | 208 | const entries = []; |
209 | | - for(const tableKey of this.def.tables) { |
| 209 | + for (const tableKey of this.def.tables) { |
210 | 210 | const table = tables[tableKey]; |
211 | 211 | entries.push(...table.getAllEntries(seen)); |
212 | 212 | } |
213 | | - return entries.map(entry => entry.forCollection(this)); |
| 213 | + return entries.map((entry) => entry.forCollection(this)); |
214 | 214 | default: |
215 | 215 | return this.entries; |
216 | 216 | } |
|
219 | 219 | getEntryById(id) { |
220 | 220 | switch (this.def.entrytype) { |
221 | 221 | case "collection": |
222 | | - const [tableId, entryId] = id.split(/\.(.*)/s).filter(s => s.trim()); |
| 222 | + const [tableId, entryId] = id |
| 223 | + .split(/\.(.*)/s) |
| 224 | + .filter((s) => s.trim()); |
223 | 225 | return tables[tableId].getEntryById(entryId); |
224 | 226 | default: |
225 | 227 | return this.entries[parseInt(id) - 1]; |
226 | 228 | } |
227 | | - |
228 | 229 | } |
229 | 230 |
|
230 | 231 | getRandomEntry() { |
|
233 | 234 | } |
234 | 235 |
|
235 | 236 | getSourceLabel() { |
236 | | - const sourceLinks = this.def.sourcelinks || (this.def.sourcelink ? [this.def.sourcelink] : null); |
237 | | - if(sourceLinks) { |
| 237 | + const sourceLinks = |
| 238 | + this.def.sourcelinks || |
| 239 | + (this.def.sourcelink ? [this.def.sourcelink] : null); |
| 240 | + if (sourceLinks) { |
238 | 241 | const span = document.createElement("span"); |
239 | 242 | span.innerText = "Source: "; |
240 | | - for(const sourcelink of sourceLinks) { |
| 243 | + for (const sourcelink of sourceLinks) { |
241 | 244 | const a = document.createElement("a"); |
242 | 245 | a.setAttribute("href", sourcelink); |
243 | 246 | a.innerText = sourcelink; |
|
247 | 250 | span.appendChild(sep); |
248 | 251 | } |
249 | 252 | return span; |
250 | | - } |
251 | | - else { |
| 253 | + } else { |
252 | 254 | return document.createElement("span"); |
253 | 255 | } |
254 | 256 | } |
|
272 | 274 | const mainTableBody = document.getElementById("maintablebody"); |
273 | 275 |
|
274 | 276 | const sortedTables = Object.values(tables).sort((table1, table2) => { |
275 | | - if(table1.def.entrytype === "collection" && table2.def.entrytype !== "collection") { |
| 277 | + if ( |
| 278 | + table1.def.entrytype === "collection" && |
| 279 | + table2.def.entrytype !== "collection" |
| 280 | + ) { |
276 | 281 | return -1; |
277 | | - } |
278 | | - else if(table2.def.entrytype === "collection" && table1.def.entrytype !== "collection") { |
| 282 | + } else if ( |
| 283 | + table2.def.entrytype === "collection" && |
| 284 | + table1.def.entrytype !== "collection" |
| 285 | + ) { |
279 | 286 | return 1; |
280 | | - } |
281 | | - else { |
| 287 | + } else { |
282 | 288 | return table1.getDescription().localeCompare(table2.getDescription()); |
283 | 289 | } |
284 | 290 | }); |
|
307 | 313 |
|
308 | 314 | document.getElementById("tablesource").innerHTML = ""; |
309 | 315 |
|
310 | | - document.getElementById("tablesource").appendChild(focusedTable.getSourceLabel()); |
| 316 | + document |
| 317 | + .getElementById("tablesource") |
| 318 | + .appendChild(focusedTable.getSourceLabel()); |
311 | 319 |
|
312 | 320 | const focusTableBody = document.getElementById("focustablebody"); |
313 | 321 |
|
|
0 commit comments