Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

innerhtml cleanup 2 #3675

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { EventID, TypedEvent } from '../../typed_event.js';

import { ResultComponent, ResultComponentConfig, SimResultData } from './result_component.js';
import tippy from 'tippy.js'
import { element, fragment, ref } from 'tsx-vanilla'

declare var $: any;

Expand Down Expand Up @@ -39,15 +40,15 @@ export abstract class MetricsTable<T> extends ResultComponent {
super(config);
this.columnConfigs = columnConfigs;

this.rootElem.innerHTML = `
<table class="metrics-table tablesorter">
<thead class="metrics-table-header">
<tr class="metrics-table-header-row"></tr>
</thead>
<tbody class="metrics-table-body">
</tbody>
</table>
`;
this.rootElem.appendChild(
<table className="metrics-table tablesorter">
<thead className="metrics-table-header">
<tr className="metrics-table-header-row"></tr>
</thead>
<tbody className="metrics-table-body">
</tbody>
</table>
);

this.tableElem = this.rootElem.getElementsByClassName('metrics-table')[0] as HTMLTableSectionElement;
this.bodyElem = this.rootElem.getElementsByClassName('metrics-table-body')[0] as HTMLElement;
Expand All @@ -62,11 +63,10 @@ export abstract class MetricsTable<T> extends ResultComponent {
if (columnConfig.columnClass) {
headerCell.classList.add(columnConfig.columnClass);
}
headerCell.innerHTML = `<span>${columnConfig.name}</span>`;
headerCell.appendChild(<span>{columnConfig.name}</span>);
if (columnConfig.tooltip) {
tippy(headerCell, {
'content': columnConfig.tooltip,
'allowHTML': true,
content: columnConfig.tooltip,
});
}
headerRowElem.appendChild(headerCell);
Expand Down Expand Up @@ -187,15 +187,16 @@ export abstract class MetricsTable<T> extends ResultComponent {
name: 'Name',
fillCell: (metric: T, cellElem: HTMLElement, rowElem: HTMLElement) => {
const data = getData(metric);
cellElem.innerHTML = `
<a class="metrics-action-icon"></a>
<span class="metrics-action-name">${data.name}</span>
<span class="expand-toggle fa fa-caret-down"></span>
<span class="expand-toggle fa fa-caret-right"></span>
`;

const iconElem = cellElem.getElementsByClassName('metrics-action-icon')[0] as HTMLAnchorElement;
data.actionId.setBackgroundAndHref(iconElem);
const iconElem = ref<HTMLAnchorElement>();
cellElem.appendChild(
<>
<a ref={iconElem} className="metrics-action-icon"></a>
<span className="metrics-action-name">{data.name}</span>
<span className="expand-toggle fa fa-caret-down"></span>
<span className="expand-toggle fa fa-caret-right"></span>
</>
);
data.actionId.setBackgroundAndHref(iconElem.value!);
},
};
}
Expand All @@ -204,10 +205,12 @@ export abstract class MetricsTable<T> extends ResultComponent {
return {
name: 'Name',
fillCell: (player: UnitMetrics, cellElem: HTMLElement, rowElem: HTMLElement) => {
cellElem.innerHTML = `
<img class="metrics-action-icon" src="${player.iconUrl}"></img>
<span class="metrics-action-name text-${player.classColor}">${player.label}</span>
`;
cellElem.appendChild(
<>
<img className="metrics-action-icon" src={player.iconUrl}></img>
<span className={`metrics-action-name text-${player.classColor}`}>player.label</span>
</>
);
},
};
}
Expand Down
12 changes: 6 additions & 6 deletions ui/core/components/detailed_results/timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ export class Timeline extends ResultComponent {
const totalDamage = castLog.totalDamage();

const tt = (
<div>
<>
<span>{castLog.actionId!.name} from {castLog.timestamp.toFixed(2)}s to {(castLog.timestamp + castLog.castTime).toFixed(2)}s ({castLog.castTime.toFixed(2)}s, {castLog.effectiveTime.toFixed(2)}s GCD Time){travelTimeStr}</span>
<ul className="rotation-timeline-cast-damage-list">
{castLog.damageDealtLogs.map(ddl => (
Expand All @@ -803,7 +803,7 @@ export class Timeline extends ResultComponent {
}
</ul>
{totalDamage > 0 && <span>Total: {totalDamage.toFixed(2)} ({(totalDamage / (castLog.effectiveTime || 1)).toFixed(2)} DPET)</span>}
</div>
</>
);

tippy(castElem, {
Expand All @@ -818,10 +818,10 @@ export class Timeline extends ResultComponent {
rowElem.appendChild(tickElem);

const tt = (
<div>
<>
<span>{ddl.timestamp.toFixed(2)}s - {ddl.actionId!.name} {ddl.resultString()}</span>
{ddl.source?.isTarget && <span className="threat-metrics"> ({ddl.threat.toFixed(1)} Threat)</span>}
</div>
</>
);

tippy(tickElem, {
Expand Down Expand Up @@ -1033,7 +1033,7 @@ export class Timeline extends ResultComponent {

private tooltipAurasSectionElem(log: SimLog): JSX.Element {
if (log.activeAuras.length == 0) {
return (<div></div>);
return (<></>);
}

return (
Expand All @@ -1045,7 +1045,7 @@ export class Timeline extends ResultComponent {
{log.activeAuras.map(auraLog => {
return (
<li>
{auraLog.actionId!.iconUrl && <img className="timeline-tooltip-icon" src={`${auraLog.actionId!.iconUrl}`}></img>}
{auraLog.actionId!.iconUrl && <img className="timeline-tooltip-icon" src={auraLog.actionId!.iconUrl}></img>}
<span>{auraLog.actionId!.name}</span>
</li>
);
Expand Down
2 changes: 1 addition & 1 deletion ui/core/components/enum_picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class EnumPicker<ModObject> extends Input<ModObject, number> {

this.selectElem = document.createElement('select');
this.selectElem.classList.add('enum-picker-selector', 'form-select');
this.rootElem.appendChild(this.selectElem);

config.values.forEach((value) => {
const option = document.createElement('option');
Expand All @@ -32,6 +31,7 @@ export class EnumPicker<ModObject> extends Input<ModObject, number> {
option.title = value.tooltip;
}
});
this.rootElem.appendChild(this.selectElem);

this.init();

Expand Down
Loading