Skip to content

Commit 3ce0984

Browse files
Format
1 parent 95e62a8 commit 3ce0984

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

page.in/dndtables.in.html

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
forCollection(collection) {
4343
const entry = new Entry(this.table, this.id, this.text);
4444
entry.collection = collection;
45-
entry.id = this.table.name + '.' + this.id;
45+
entry.id = this.table.name + "." + this.id;
4646
entry.originaltable = entry.originaltable || entry.table;
4747
entry.table = collection;
4848
return entry;
@@ -53,7 +53,7 @@
5353
}
5454

5555
getIdText() {
56-
return this.collection ? this.id.split('.').at(-1) : this.id;
56+
return this.collection ? this.id.split(".").at(-1) : this.id;
5757
}
5858

5959
getTableRow() {
@@ -65,7 +65,7 @@
6565
a.setAttribute("href", `#${this.table.name}:${this.id}`);
6666
a.innerText = this.getIdText();
6767
idTd.appendChild(a);
68-
if(this.collection) {
68+
if (this.collection) {
6969
const space = document.createElement("br");
7070
idTd.appendChild(space);
7171

@@ -198,19 +198,19 @@
198198

199199
getAllEntries(seen) {
200200
seen = seen || {};
201-
if(seen[this.name]) {
201+
if (seen[this.name]) {
202202
return [];
203203
}
204204
seen[this.name] = true;
205205

206206
switch (this.def.entrytype) {
207207
case "collection":
208208
const entries = [];
209-
for(const tableKey of this.def.tables) {
209+
for (const tableKey of this.def.tables) {
210210
const table = tables[tableKey];
211211
entries.push(...table.getAllEntries(seen));
212212
}
213-
return entries.map(entry => entry.forCollection(this));
213+
return entries.map((entry) => entry.forCollection(this));
214214
default:
215215
return this.entries;
216216
}
@@ -219,12 +219,13 @@
219219
getEntryById(id) {
220220
switch (this.def.entrytype) {
221221
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());
223225
return tables[tableId].getEntryById(entryId);
224226
default:
225227
return this.entries[parseInt(id) - 1];
226228
}
227-
228229
}
229230

230231
getRandomEntry() {
@@ -233,11 +234,13 @@
233234
}
234235

235236
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) {
238241
const span = document.createElement("span");
239242
span.innerText = "Source: ";
240-
for(const sourcelink of sourceLinks) {
243+
for (const sourcelink of sourceLinks) {
241244
const a = document.createElement("a");
242245
a.setAttribute("href", sourcelink);
243246
a.innerText = sourcelink;
@@ -247,8 +250,7 @@
247250
span.appendChild(sep);
248251
}
249252
return span;
250-
}
251-
else {
253+
} else {
252254
return document.createElement("span");
253255
}
254256
}
@@ -272,13 +274,17 @@
272274
const mainTableBody = document.getElementById("maintablebody");
273275

274276
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+
) {
276281
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+
) {
279286
return 1;
280-
}
281-
else {
287+
} else {
282288
return table1.getDescription().localeCompare(table2.getDescription());
283289
}
284290
});
@@ -307,7 +313,9 @@
307313

308314
document.getElementById("tablesource").innerHTML = "";
309315

310-
document.getElementById("tablesource").appendChild(focusedTable.getSourceLabel());
316+
document
317+
.getElementById("tablesource")
318+
.appendChild(focusedTable.getSourceLabel());
311319

312320
const focusTableBody = document.getElementById("focustablebody");
313321

0 commit comments

Comments
 (0)