All files SidebarHelper.ts

100% Statements 20/20
100% Branches 8/8
100% Functions 2/2
100% Lines 17/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37        8x     8x       8x 8x   7x 7x   5x 5x   4x 4x 4x   4x 1x 2x       4x 4x   4x      
import {KeyInfo} from '../../types/Types'
 
export class SidebarHelper {
 
    private keys = new Map<string, KeyInfo>()
 
    public setKeys(keys: Map<string, KeyInfo>): void {
        this.keys = keys
    }
 
    public onPortalDetailsUpdated(data: any): void {
        const guid = data.guid as string | undefined
        if (!guid) return
 
        const keyInfo = this.keys.get(guid)
        if (!keyInfo) return
 
        const tbody = document.querySelector('#randdetails tbody')
        if (!tbody) return
 
        let html = '<tr>'
        html += `<td>Team: <strong>${keyInfo.total}</strong></td>`
        html += '<td colspan="3">'
 
        if (keyInfo.agentCounts.size > 0) {
            for (const [agent, count] of keyInfo.agentCounts) {
                html += `${agent}: ${count}<br />`
            }
        }
 
        html += '</td>'
        html += '</tr>'
 
        tbody.insertAdjacentHTML('beforeend', html)
    }
}