<commit_before>

var all_data = {
    'company': {
        'name': '<NAME>',
        'periods': [
            {
                'eqyYear': 2015,
                'period': 'YE',
                'fhr': {
                    'stOverall': 45
                }
            },
            {
                'eqyYear': 2014,
                'period': 'Q2',
                'fhr': {
                    'stOverall': 65
                }
            }
        ]
    }
};


var attached_elems = {};


function find_value(gres, rel_data) {
    var cdata = all_data;
    if (gres.startsWith('.')) {
        cdata = rel_data;
        gres = gres.slice(1);
    }
    while (gres.indexOf('.') != -1) {
        var field = gres.split('.', 1)[0];
        cdata = cdata[field]
        gres = gres.slice(gres.indexOf('.') + 1);
    }
    return cdata[gres];
}


function reload(elem, rel_data) {
    console.log("Reload: " + elem.attr('id'));
    if (elem.hasClass('gtext')) {
        var gres = elem.attr('data-res');
        var value = find_value(gres, rel_data);
        elem.text(value);
    }
    if (elem.hasClass('glist')) {
        var gres = elem.attr('data-res');
        var list = find_value(gres, rel_data);
        var orig_elems = elem.children();
        var first_elem = $(orig_elems[0]);
        first_elem.hide();
        var new_elems = [];
        for (var i in list) {
            var new_elem = $(first_elem).clone();
            new_elems[new_elems.length] = new_elem;
        }
        for (var i in new_elems) {
            var item = list[i];
            var new_elem = new_elems[i];
            elem.append(new_elem);
            new_elem.show();
            reload(new_elem, item);
        }
//        for (var i in orig_elems) {
//            $(orig_elems[i]).remove();
//        }
        elem.prepend(first_elem);
    }
    elem.children().each(function() {
        reload($(this), rel_data);
    });
}


function attach(elem, data) {
    attached_elems[elem] = data;
    reload(elem);
}


$( document ).ready(function() {
    console.log( "go!" );
    attach($('#main'), all_data);
});<commit_msg>Fixing list<commit_after>

var all_data = {
    'company': {
        'name': '<NAME>',
        'periods': [
            {
                'eqyYear': 2015,
                'period': 'YE',
                'fhr': {
                    'stOverall': 45
                }
            },
            {
                'eqyYear': 2014,
                'period': 'Q2',
                'fhr': {
                    'stOverall': 65
                }
            }
        ]
    }
};


var attached_elems = {};


function find_value(gres, rel_data) {
    var cdata = all_data;
    if (gres.startsWith('.')) {
        cdata = rel_data;
        gres = gres.slice(1);
    }
    while (gres.indexOf('.') != -1) {
        var field = gres.split('.', 1)[0];
        cdata = cdata[field]
        gres = gres.slice(gres.indexOf('.') + 1);
    }
    return cdata[gres];
}


function reload(elem, rel_data) {
    console.log("Reload: " + elem.attr('id'));
    if (elem.hasClass('gtext')) {
        var gres = elem.attr('data-res');
        var value = find_value(gres, rel_data);
        elem.text(value);
        console.log("Val:"+value);
    }
    if (elem.hasClass('glist')) {
        var gres = elem.attr('data-res');
        var list = find_value(gres, rel_data);
        var orig_elems = elem.children();
        var first_elem = $(orig_elems[0]);
        first_elem.hide();
        var new_elems = [];
        for (var i in list) {
            var new_elem = $(first_elem).clone();
            new_elems[new_elems.length] = new_elem;
        }
        for (var i in new_elems) {
            var item = list[i];
            var new_elem = new_elems[i];
            elem.append(new_elem);
            new_elem.show();
            reload(new_elem, item);
        }
        orig_elems.remove();
        elem.prepend(first_elem);
    }
    else {
        elem.children().each(function() {
            reload($(this), rel_data);
        });
    }
}


function attach(elem, data) {
    attached_elems[elem] = data;
    reload(elem);
}


$( document ).ready(function() {
    console.log( "go!" );
    attach($('#main'), all_data);
});
{'fraction_non_alphanumeric': 0.16169507575757575, 'fraction_numerical': 0.008996212121212122, 'mean_word_length': 1.5390625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5742978', 'n_tokens_mistral': 1433, 'n_tokens_neox': 1366, 'n_words': 256}