<commit_before>function getItemSummariesFromTable( table ) {
    var itemSummaries = {};

    table.find('tbody tr').each(function(i, tableRow) { 
        var summary = getItemSummaryFromRow( tableRow );
        itemSummaries[summary.id] = summary;
    });

    return itemSummaries;
}


function getItemSummaryFromRow( row ) {
    var rawUrl = $('td:first a', row).attr('href'),
        detailsUrl = parseUrl(rawUrl),
        id = detailsUrl.params.stock_num

    return {
        id: id,
        store: detailsUrl.params.store,
        detailsUrl: detailsUrl
    };
}

var items = getItemSummariesFromTable($('#bid_items'));




// ====================
// Utilities
// ====================

// REF: http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
function splitUrlParams(queryPart) {
    if (typeof a === undefined ) return {};

    queryPart = queryPart.split('?') ? queryPart.split('?')[1] : queryPart;

    var a = queryPart.split('&'),
        b = {},
        i = 0;
        limit = a.length;

    for (; i < limit; ++i)
    {
        var p=a[i].split('=');
        if (p.length != 2) continue;
        b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
    }
    return b;
}

// REF: http://stackoverflow.com/questions/736513/how-do-i-parse-a-url-into-hostname-and-path-in-javascript
function parseUrl(url) {
    var result = {},
        anchor = document.createElement('a'),
        keys = 'protocol hostname host pathname port search hash href'.split(' ');

    anchor.href = url;
    for (k in keys) {
        var me = keys[k]; 
        result[me] = anchor[me];
    }

    result.toString = function() { return anchor.href; };
    result.requestUri = result.pathname + result.search;
    result.params = splitUrlParams( result.search );
    return result;
};<commit_msg>Functional proof of concept<commit_after>function preparetableForThumbnails( table ) {
    table.find('thead tr').prepend('<th class="header">&nbsp;</th>');
    table.find('tbody tr').each(function(i, row) {
        var me = $(row);
        if ( me.find('.thumb').length == 0 ) {
            me.prepend('<td class="js-controls"></td>');            
        }
    });
}

function getItemSummariesFromTable( table ) {
    var itemSummaries = {};

    table.find('tbody tr').each(function(i, tableRow) { 
        if (i >= 30) return;
        var summary = getItemSummaryFromRow( tableRow );
        updateItemRowWithThumbnail( tableRow, summary );
        itemSummaries[summary.id] = summary;
    });

    return itemSummaries;
}


function getItemSummaryFromRow( row ) {
    var rawUrl = $('td a', row).eq(1).attr('href'),
        detailsUrl = parseUrl(rawUrl),
        id = detailsUrl.params.stock_num

    return {
        id: id,
        store: detailsUrl.params.store,
        detailsUrl: detailsUrl
    };
}


function updateItemRowWithThumbnail( row, summary ) {

    $.get(summary.detailsUrl, function( data ){
        var srcImage = $('img[name="image1"]', data),
            a = $('<a class="thumb" target="_blank"></a>')
                        .attr('href', summary.detailsUrl),
            img = $('<img alt="loading..."/>')
                        .attr('src', srcImage[0].src)
                        .attr('width', 245)
                        .appendTo(a);

        $('.js-controls', row).append(a);
    });
}


var t = $('#bid_items');
preparetableForThumbnails( t );
var items = getItemSummariesFromTable( t );


// ====================
// Utilities
// ====================

// REF: http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
function splitUrlParams(queryPart) {
    if (typeof a === undefined ) return {};

    queryPart = queryPart.split('?') ? queryPart.split('?')[1] : queryPart;

    var a = queryPart.split('&'),
        b = {},
        i = 0;
        limit = a.length;

    for (; i < limit; ++i)
    {
        var p=a[i].split('=');
        if (p.length != 2) continue;
        b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
    }
    return b;
}

// REF: http://stackoverflow.com/questions/736513/how-do-i-parse-a-url-into-hostname-and-path-in-javascript
function parseUrl(url) {
    var result = {},
        anchor = document.createElement('a'),
        keys = 'protocol hostname host pathname port search hash href'.split(' ');

    anchor.href = url;
    for (k in keys) {
        var me = keys[k]; 
        result[me] = anchor[me];
    }

    result.toString = function() { return anchor.href; };
    result.requestUri = result.pathname + result.search;
    result.params = splitUrlParams( result.search );
    return result;
};
{'fraction_non_alphanumeric': 0.1793103448275862, 'fraction_numerical': 0.009267241379310344, 'mean_word_length': 2.5185746777862015, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 11, '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': '7175970', 'n_tokens_mistral': 1512, 'n_tokens_neox': 1443, 'n_words': 288}