mirror of
https://github.com/Kornstalx/5etools-mirror-2.github.io.git
synced 2025-10-28 20:45:35 -05:00
v1.198.1
This commit is contained in:
54
js/render-tables.js
Normal file
54
js/render-tables.js
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
|
||||
class RenderTables {
|
||||
static _getPartTableFrom (it) {
|
||||
if (it.parentEntity) {
|
||||
switch (it.parentEntity.type) {
|
||||
case "class": {
|
||||
return `<tr class="text"><td colspan="6">
|
||||
${Renderer.get().render(`{@note ${it.__prop === "table" ? `This table is` : "These tables are"} from the {@class ${it.parentEntity.name}|${it.parentEntity.source}} class.}`)}
|
||||
</td></tr>`;
|
||||
}
|
||||
|
||||
case "subclass": {
|
||||
return `<tr class="text"><td colspan="6">
|
||||
${Renderer.get().render(`{@note ${it.__prop === "table" ? `This table is` : "These tables are"} from the {@class ${it.parentEntity.className}|${it.parentEntity.classSource}|${it.parentEntity.name}|${it.parentEntity.shortName}|${it.parentEntity.source}} <span title="Source: ${Parser.sourceJsonToFull(it.parentEntity.classSource)}">${it.parentEntity.className}</span> subclass.}`)}
|
||||
</td></tr>`;
|
||||
}
|
||||
|
||||
default: {
|
||||
const tag = Parser.getPropTag(it.parentEntity.type);
|
||||
const displayName = Parser.getPropDisplayName(it.parentEntity.type);
|
||||
|
||||
return `<tr class="text"><td colspan="6">
|
||||
${Renderer.get().render(`{@note ${it.__prop === "table" ? `This table is` : "These tables are"} from the {@${tag} ${it.parentEntity.name}|${it.parentEntity.source}} ${displayName.toLowerCase()}.}`)}
|
||||
</td></tr>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (it.chapter) {
|
||||
return `<tr class="text"><td colspan="6">
|
||||
${Renderer.get().render(`{@note ${it.__prop === "table" ? `This table` : "These tables"} can be found in ${Parser.sourceJsonToFull(it.source)}${Parser.bookOrdinalToAbv(it.chapter.ordinal, true)}, {@book ${it.chapter.name}|${it.source}|${it.chapter.index}|${it.chapter.name}}.}`)}
|
||||
</td></tr>`;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
static $getRenderedTable (it) {
|
||||
it.type = it.type || "table";
|
||||
|
||||
const ptFrom = this._getPartTableFrom(it);
|
||||
|
||||
return $$`
|
||||
${Renderer.utils.getBorderTr()}
|
||||
${Renderer.utils.getExcludedTr({entity: it, dataProp: "table"})}
|
||||
${Renderer.utils.getNameTr(it, {page: UrlUtil.PG_TABLES})}
|
||||
<tr><td class="divider" colspan="6"><div></div></td></tr>
|
||||
<tr><td colspan="6">${Renderer.get().setFirstSection(true).render(it)}</td></tr>
|
||||
${ptFrom}
|
||||
${Renderer.utils.getPageTr(it)}
|
||||
${Renderer.utils.getBorderTr()}`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user