<commit_before>function ynabEnhancedSelectedTotals() {
    var parent = document.getElementsByClassName("accounts-header-balances")[0];
    var totals = document.createElement("div");
    totals.className = "accounts-header-balances-selected hidden";
    totals.id = "accounts-selected-total";
    var label = document.createElement("div");
    label.className = "accounts-header-balances-label";
    label.innerText = "Selected transactions total"
    totals.appendChild(label);
    parent.appendChild(totals);
    ynabEnhancedSelectedTotalsPoll();
}

function ynabEnhancedSelectedTotalsCalculate() {
    var outflows = 0;
    var inflows = 0;
    var checkboxes = document.getElementsByClassName("ynab-checkbox-button");
    for (var i = 0; i < checkboxes.length; i++) {
        var checkbox = checkboxes[i];
        if ((' ' + checkbox.className + ' ').indexOf(' is-checked ') == -1) {
            continue;
        }
        var parent = document.getElementById(checkbox.parentElement.parentElement.parentElement.id);
        var outflow = parent.getElementsByClassName('ynab-grid-cell-outflow')[0].innerText;
        var inflow = parent.getElementsByClassName('ynab-grid-cell-inflow')[0].innerText;
        outflows += ynab.YNABSharedLib.currencyFormatter.convertToFixedPrecision(ynab.YNABSharedLib.currencyFormatter.unformat(outflow));
        inflows += ynab.YNABSharedLib.currencyFormatter.convertToFixedPrecision(ynab.YNABSharedLib.currencyFormatter.unformat(inflow));
        ynabEnhancedSelectedTotalsUpdate(inflows - outflows);
    }

    setTimeout(ynabEnhancedSelectedTotalsPoll, 750);
}

function ynabEnhancedSelectedTotalsUpdate(total) {
    var parent = document.getElementById('accounts-selected-total');
    if (parent == null) {
        return false;
    }
    if ((' ' + parent.className + ' ').indexOf(' hidden ') == -1 && total == 0) {
        parent.className += " hidden";
        return true;
    } else if (total == 0) {
        return true;
    }
    parent.className = "accounts-header-balances-selected";
    var spans = parent.getElementsByClassName("user-data");
    for (var i = 0; i < spans.length; i++) {
        spans[i].remove();
    }
    // '<span class="user-data" title="519&nbsp;879,71kr"><span class="user-data currency positive">519&nbsp;879,71<bdi>kr</bdi></span></span>'
    var totalFormatted = ynabEnhancedFormatCurrency(total);
    var userData = document.createElement("span");
    userData.className = "user-data";
    userData.title = totalFormatted;
    var userCurrency = document.createElement("span");<commit_msg>Cleanup<commit_after>function ynabEnhancedSelectedTotals() {
    var parent = document.getElementsByClassName("accounts-header-balances")[0];
    var totals = document.createElement("div");
    totals.className = "accounts-header-balances-selected hidden";
    totals.id = "accounts-selected-total";
    var label = document.createElement("div");
    label.className = "accounts-header-balances-label";
    label.innerText = "Selected transactions total"
    totals.appendChild(label);
    parent.appendChild(totals);
    ynabEnhancedSelectedTotalsPoll();
}

function ynabEnhancedSelectedTotalsCalculate() {
    var outflows = 0;
    var inflows = 0;
    var checkboxes = document.getElementsByClassName("ynab-checkbox-button");
    for (var i = 0; i < checkboxes.length; i++) {
        var checkbox = checkboxes[i];
        if ((' ' + checkbox.className + ' ').indexOf(' is-checked ') == -1) {
            continue;
        }
        var parent = document.getElementById(checkbox.parentElement.parentElement.parentElement.id);
        var outflow = parent.getElementsByClassName('ynab-grid-cell-outflow')[0].innerText;
        var inflow = parent.getElementsByClassName('ynab-grid-cell-inflow')[0].innerText;
        outflows += ynab.YNABSharedLib.currencyFormatter.convertToFixedPrecision(ynab.YNABSharedLib.currencyFormatter.unformat(outflow));
        inflows += ynab.YNABSharedLib.currencyFormatter.convertToFixedPrecision(ynab.YNABSharedLib.currencyFormatter.unformat(inflow));
        ynabEnhancedSelectedTotalsUpdate(inflows - outflows);
    }

    setTimeout(ynabEnhancedSelectedTotalsPoll, 750);
}

function ynabEnhancedSelectedTotalsUpdate(total) {
    var parent = document.getElementById('accounts-selected-total');
    if (parent == null) {
        return false;
    }
    if ((' ' + parent.className + ' ').indexOf(' hidden ') == -1 && total == 0) {
        parent.className += " hidden";
        return true;
    } else if (total == 0) {
        return true;
    }
    parent.className = "accounts-header-balances-selected";
    var spans = parent.getElementsByClassName("user-data");
    for (var i = 0; i < spans.length; i++) {
        spans[i].remove();
    }
    var totalFormatted = ynabEnhancedFormatCurrency(total);
    var userData = document.createElement("span");
    userData.className = "user-data";
    userData.title = totalFormatted;
    var userCurrency = document.createElement("span");
{'fraction_non_alphanumeric': 0.132317562149158, 'fraction_numerical': 0.008821170809943865, 'mean_word_length': 3.7741626794258374, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5821519', 'n_tokens_mistral': 1527, 'n_tokens_neox': 1492, 'n_words': 249}