js/ui.js
/**
 * Builds the block producers table.
 *
 * @param producers list of active block producers.
 * */
Builds the block producers table.
@param producers list of active block producers.
Builds the block producers table . @param producers list of active block producers .
function buildTable(producers) {
    let table = document.getElementsByTagName('tbody')[0]
    let sortedProducers = producers.sort((a, b) => Number(a.total_votes) > Number(b.total_votes) ? -1 : 1)
    for (let i = 0; i < sortedProducers.length; i++) {
        let producer = sortedProducers[i]
        let rowSanitized = sanitizeUrl(producer.url)
        let tr = document.createElement('tr')
        let rank = i + 1
        tr.setAttribute("id", 'row' + i)
        tr.append(addTd('<input name="bpFollow" type="radio" value="' + producer.owner + '" ' + (producer.owner === favoriteBlockProducerName ? 'checked' : '') + ' >'))
        tr.append(addTd(rank))
        tr.append(addTd("", producer.owner === favoriteBlockProducerName ? "rankIcon" : ""))
        tr.append(addTd("<a href='" + rowSanitized + "'>" + producer.owner + "</a>"))
        tr.append(addTd((producer.total_votes / chainState.total_producer_vote_weight * 100).toFixed(3)))
        tr.append(addTd(numberWithCommas((producer.total_votes / calculateVoteWeight() / 10000).toFixed(0))))
        if (document.getElementById('row' + i) != null) {
            table.replaceChild(tr, table.childNodes[i])
        } else {
            table.append(tr)
        }
        if (producer.owner === favoriteBlockProducerName) {
            checkRanking(rank)
            setRankIcon(rank)
            favoriteBlockProducerCurrentRanking = rank
        }
    }
    document.getElementsByName("bpFollow").forEach(e => {
        e.onclick = selectBlockProducer
    })
    selectBlockProducer()
    return table
}
function buildTable ( producers ) { let table = document . getElementsByTagName ( 'tbody' ) [ 0 ] let sortedProducers = producers . sort ( ( a , b ) => Number ( a . total_votes ) > Number ( b . total_votes ) ? - 1 : 1 ) for ( let i = 0 ; i < sortedProducers . length ; i ++ ) { let producer = sortedProducers [ i ] let rowSanitized = sanitizeUrl ( producer . url ) let tr = document . createElement ( 'tr' ) let rank = i + 1 tr . setAttribute ( "id" , 'row' + i ) tr . append ( addTd ( '<input name="bpFollow" type="radio" value="' + producer . owner + '" ' + ( producer . owner === favoriteBlockProducerName ? 'checked' : '' ) + ' >' ) ) tr . append ( addTd ( rank ) ) tr . append ( addTd ( "" , producer . owner === favoriteBlockProducerName ? "rankIcon" : "" ) ) tr . append ( addTd ( "<a href='" + rowSanitized + "'>" + producer . owner + "</a>" ) ) tr . append ( addTd ( ( producer . total_votes / chainState . total_producer_vote_weight * 100 ) . toFixed ( 3 ) ) ) tr . append ( addTd ( numberWithCommas ( ( producer . total_votes / calculateVoteWeight ( ) / 10000 ) . toFixed ( 0 ) ) ) ) if ( document . getElementById ( 'row' + i ) != null ) { table . replaceChild ( tr , table . childNodes [ i ] ) } else { table . append ( tr ) } if ( producer . owner === favoriteBlockProducerName ) { checkRanking ( rank ) setRankIcon ( rank ) favoriteBlockProducerCurrentRanking = rank } } document . getElementsByName ( "bpFollow" ) . forEach ( e => { e . onclick = selectBlockProducer } ) selectBlockProducer ( ) return table }
Builds the block producers table.
Builds the block producers table .