<commit_before>//===============================================================================
// Copyright (c) 2015, <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// MoneyWatch - https://github.com/jamesottinger/moneywatch
//===============================================================================
var MW = MW || {};

MW = {
    moneyWatchURL: '.',
    activeRowId: '',

    paintScreen: function () {
        MW.comm.sendCommand('I.SUMMARY.GET');
        MW.comm.sendCommand('B.SUMMARY.GET');
        $('#rightcontent2').hide();
        MW.comm.sendCommand('U.LINKS.GET');
        MW.timers.startTimers();
    },

    calcNetWorth: function () {
        var nw = MW.util.formatCurrency(($('#networth-investments').val() * 1.00) + ($('#networth-banks').val() * 1.00));
        $('#sum-worth-inv').html(MW.util.formatCurrency($('#networth-investments').val()));
        $('#sum-worth-bank').html(MW.util.formatCurrency($('#networth-banks').val()));
        $('#sum-worth-all').html(nw);
    }
};

// ------------------------------------------------------------------
// [== COMMUNICATION ==]
// ------------------------------------------------------------------
MW.comm = {
    sendCommand: function (in_job) {
        var formdata;
        var urlpost = MW.moneyWatchURL + '/action/' + in_job;

        switch(in_job) {
            case 'I.SUMMARY.GET':
                $.ajax({
                    url: urlpost,
                    data: {},
                    success: function(data) {
                        $('#rightcontent1').html(data);
                        MW.calcNetWorth();
                    }
                });
                break;
            case 'I.BULKADD.EDIT':
                MW.yui.panelUniversal.set('width', 950);
                MW.yui.panelUniversal.set('headerContent', "Investments - Bulk Add" + MW.yui.YUIcloseMarkup);
                $.ajax({
                    url: urlpost,
                    data: {job: in_job},
                    success: function(data) {
                        $('#paneluniversal-inner').html(data);
                        MW.yui.panelUniversal.show();
                    }
                });
                break;
            case 'I.BULKADD.SAVE':
                formdata = $('#ibulkedit').serialize();
                $.ajax({
                    type: 'POST',
                    url: urlpost,
                    data: formdata,
                    success: function(data) {
                        data = data.replace(/\n/gm, '');
                        if (data == 'ok') {
                            MW.yui.panelUniversal.hide();
                            MW.comm.sendCommand('I.SUMMARY.GET');
                            MW.comm.sendCommand('B.SUMMARY.GET');
                        }
                    }
                });
                break;
            case 'I.ENTRY.EDITSAVE':
            case 'I.ENTRY.ADDSAVE':
                formdata = $('#ieditsingle').serialize();
                var ielectionid = $('#ieditsingle-ielectionid').val();
                $.ajax({
                    type: 'POST',
                    url: urlpost,
                    data: formdata,
                    success: function(data) {
                        data = data.replace(/\n/gm, '');
                        if (data == 'ok') {
                            $('#' + MW.activeRowId).removeClass('activeinvrow');
                            $.ajax({
                                url: MW.moneyWatchURL + '/action/I.ELECTION.GET',
                                data: {'ielectionid': ielectionid},
                                success: function(data) {
                                    $('#transactionslist').html(data);
                                    $("#transactionslist").scrollTop($("#transactionslist")[0].scrollHeight);
                                }
                            });
                            $.ajax({
                                url: MW.moneyWatchURL + '/action/I.ENTRY.ADD',
                                data: {'ielectionid': ielectionid},
                                success: function(data) {
                                    $('#transactionsrightedit').html(data);
                                }
                            });
                            // reload underneath
                            MW.comm.sendCommand('I.SUMMARY.GET');
                        } else {
                            alert(data.substr(0,500));
                        }
                    }
                });
                break;
            case 'B.SUMMARY.GET':<commit_msg>unhighlight control box on investment update<commit_after>//===============================================================================
// Copyright (c) 2015, <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// MoneyWatch - https://github.com/jamesottinger/moneywatch
//===============================================================================
var MW = MW || {};

MW = {
    moneyWatchURL: '.',
    activeRowId: '',

    paintScreen: function () {
        MW.comm.sendCommand('I.SUMMARY.GET');
        MW.comm.sendCommand('B.SUMMARY.GET');
        $('#rightcontent2').hide();
        MW.comm.sendCommand('U.LINKS.GET');
        MW.timers.startTimers();
    },

    calcNetWorth: function () {
        var nw = MW.util.formatCurrency(($('#networth-investments').val() * 1.00) + ($('#networth-banks').val() * 1.00));
        $('#sum-worth-inv').html(MW.util.formatCurrency($('#networth-investments').val()));
        $('#sum-worth-bank').html(MW.util.formatCurrency($('#networth-banks').val()));
        $('#sum-worth-all').html(nw);
    }
};

// ------------------------------------------------------------------
// [== COMMUNICATION ==]
// ------------------------------------------------------------------
MW.comm = {
    sendCommand: function (in_job) {
        var formdata;
        var urlpost = MW.moneyWatchURL + '/action/' + in_job;

        switch(in_job) {
            case 'I.SUMMARY.GET':
                $.ajax({
                    url: urlpost,
                    data: {},
                    success: function(data) {
                        $('#rightcontent1').html(data);
                        MW.calcNetWorth();
                    }
                });
                break;
            case 'I.BULKADD.EDIT':
                MW.yui.panelUniversal.set('width', 950);
                MW.yui.panelUniversal.set('headerContent', "Investments - Bulk Add" + MW.yui.YUIcloseMarkup);
                $.ajax({
                    url: urlpost,
                    data: {job: in_job},
                    success: function(data) {
                        $('#paneluniversal-inner').html(data);
                        MW.yui.panelUniversal.show();
                    }
                });
                break;
            case 'I.BULKADD.SAVE':
                formdata = $('#ibulkedit').serialize();
                $.ajax({
                    type: 'POST',
                    url: urlpost,
                    data: formdata,
                    success: function(data) {
                        data = data.replace(/\n/gm, '');
                        if (data == 'ok') {
                            MW.yui.panelUniversal.hide();
                            MW.comm.sendCommand('I.SUMMARY.GET');
                            MW.comm.sendCommand('B.SUMMARY.GET');
                        }
                    }
                });
                break;
            case 'I.ENTRY.EDITSAVE':
            case 'I.ENTRY.ADDSAVE':
                formdata = $('#ieditsingle').serialize();
                var ielectionid = $('#ieditsingle-ielectionid').val();
                $.ajax({
                    type: 'POST',
                    url: urlpost,
                    data: formdata,
                    success: function(data) {
                        data = data.replace(/\n/gm, '');
                        if (data == 'ok') {
                            $('#' + MW.activeRowId).removeClass('activeinvrow');
                            $.ajax({
                                url: MW.moneyWatchURL + '/action/I.ELECTION.GET',
                                data: {'ielectionid': ielectionid},
                                success: function(data) {
                                    $('#transactionslist').html(data);
                                    $("#transactionslist").scrollTop($("#transactionslist")[0].scrollHeight);
                                }
                            });
                            $.ajax({
                                url: MW.moneyWatchURL + '/action/I.ENTRY.ADD',
                                data: {'ielectionid': ielectionid},
                                success: function(data) {
                                    $('#transactionsrightedit').html(data);
                                    // unhighlight the right control box
                                    $('#transactionsrightedit').removeClass('activeinveditmenu')
                                }
                            });
                            // reload underneath
                            MW.comm.sendCommand('I.SUMMARY.GET');
                        } else {
                            alert(data.substr(0,500));
                        }
                    }
                });
                break;
            case 'B.SUMMARY.GET':
{'fraction_non_alphanumeric': 0.19259182187077306, 'fraction_numerical': 0.004161897825408386, 'mean_word_length': 1.0442364951084644, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3359901', 'n_tokens_mistral': 2478, 'n_tokens_neox': 2225, 'n_words': 354}