<commit_before>var StatementUI = (function(){
    "use strict";
    var tableID = "statement-table";
    var columns = ["date", "ref", "act", "desc", "credit", "bal"];
    var header = ["Date", "Ref.", "Action", "Description", "Credit/Debit", "Balance"];
    var footer = ["", "", "", "", "", ""];

    function createEmptyStatementTable(){
        var localizedHeader = header.map(function(t){ return text.localize(t); });
        localizedHeader[5] = localizedHeader[5] + "(" + TUser.get().currency + ")";

        var metadata = {
            id: tableID,
            cols: columns
        };
        var data = [];
        var $tableContainer = Table.createFlexTable(data, metadata, localizedHeader, footer);
        return $tableContainer;
    }

    function updateStatementTable(transactions){
        Table.appendTableBody(tableID, transactions, createStatementRow);
        updateStatementFooter(transactions);
        $("#" + tableID +">tfoot").show();
    }

    function clearTableContent(){
        Table.clearTableBody(tableID);
        $("#" + tableID +">tfoot").hide();
    }


    function updateStatementFooter(transactions){
        TradeSocket.send({balance: 1, passthrough: {purpose: "statement_footer"}});

        var allCredit = [].slice.call(document.querySelectorAll("td.credit"));
        allCredit = allCredit.map(function(node){return node.textContent;});

        var totalCredit = allCredit.reduce(function(p, c){return p + parseFloat(c);}, 0);
        totalCredit = Number(totalCredit).toFixed(2);

        var $footerRow = $("#" + tableID + " > tfoot > tr").first();
        var creditCell = $footerRow.children(".credit");
        var creditType = (totalCredit >= 0) ? "profit" : "loss";

        creditCell.text(totalCredit);
        creditCell.removeClass("profit").removeClass("loss");
        creditCell.addClass(creditType);
    }

    function createStatementRow(transaction){
        var dateObj = new Date(transaction["transaction_time"] * 1000);
        var momentObj = moment.utc(dateObj);
        var dateStr = momentObj.format("YYYY-MM-DD");
        var timeStr = momentObj.format("HH:mm:ss");

        var date = dateStr + "\n" + timeStr;
        var ref = transaction["transaction_id"];
        var action = StringUtil.toTitleCase(transaction["action_type"]);
        var desc = transaction["longcode"];<commit_msg>reduced dom access<commit_after>var StatementUI = (function(){
    "use strict";
    var tableID = "statement-table";
    var columns = ["date", "ref", "act", "desc", "credit", "bal"];
    var header = ["Date", "Ref.", "Action", "Description", "Credit/Debit", "Balance"];
    var footer = ["", "", "", "", "", ""];

    function createEmptyStatementTable(){
        var localizedHeader = header.map(function(t){ return text.localize(t); });
        localizedHeader[5] = localizedHeader[5] + "(" + TUser.get().currency + ")";

        var metadata = {
            id: tableID,
            cols: columns
        };
        var data = [];
        var $tableContainer = Table.createFlexTable(data, metadata, localizedHeader, footer);
        return $tableContainer;
    }

    function updateStatementTable(transactions){
        Table.appendTableBody(tableID, transactions, createStatementRow);
        updateStatementFooter(transactions);
        $("#" + tableID +">tfoot").show();
    }

    function clearTableContent(){
        Table.clearTableBody(tableID);
        $("#" + tableID +">tfoot").hide();
    }


    function updateStatementFooter(transactions){
        TradeSocket.send({balance: 1, passthrough: {purpose: "statement_footer"}});
        var accCredit = document.querySelector("#statement-table > tfoot > tr > .credit").textContent;
        accCredit = parseFloat(accCredit);
        if (isNaN(accCredit)) {
            accCredit = 0;
        }

        var newCredits = transactions.reduce(function(p, c){ return p + parseFloat(c.amount); }, 0);

        var totalCredit = accCredit + newCredits;
        totalCredit = Number(totalCredit).toFixed(2);

        var $footerRow = $("#" + tableID + " > tfoot > tr").first();
        var creditCell = $footerRow.children(".credit");
        var creditType = (totalCredit >= 0) ? "profit" : "loss";

        creditCell.text(totalCredit);
        creditCell.removeClass("profit").removeClass("loss");
        creditCell.addClass(creditType);
    }

    function createStatementRow(transaction){
        var dateObj = new Date(transaction["transaction_time"] * 1000);
        var momentObj = moment.utc(dateObj);
        var dateStr = momentObj.format("YYYY-MM-DD");
        var timeStr = momentObj.format("HH:mm:ss");

        var date = dateStr + "\n" + timeStr;
        var ref = transaction["transaction_id"];
        var action = StringUtil.toTitleCase(transaction["action_type"]);
        var desc = transaction["longcode"];
{'fraction_non_alphanumeric': 0.15605029890744176, 'fraction_numerical': 0.004329004329004329, 'mean_word_length': 3.05685618729097, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7245542', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1336, 'n_words': 280}