examples/javascript/beatport-charts.js
function parseSearchResults(err, body) {
    if (err) { return tubesio.finish(err); }

    var result = [];

    jsdom.env({
        html: body,
        scripts: [
            'http://code.jquery.com/jquery-1.5.min.js'
        ]
    }, function (err, window) {
        if (err) { return tubesio.finish(err); }

        var $ = window.jQuery;

        $('table.track-grid-top-100 tr').each(function (i) {
            if (i === 0) { return; } // Skip header row

            var $row = $(this);
            
            result.push({
                position: parseInt($row.find('td:nth-child(1)').text()),
                trackName: $row.find('td:nth-child(4) > a').text(),
                artists: $row.find('td:nth-child(5) > a').text(),
                remixers: $row.find('td:nth-child(6) > a').text(), 
                label: $row.find('td:nth-child(7) > a').text(),
                genre: $row.find('td:nth-child(8) > a').text(),
                releaseDate: Date.parse($row.find('td:nth-child(9)').text())
            });
        });

        return tubesio.finish(result);
    });
}
function parseSearchResults(err, body) {
    if (err) { return tubesio.finish(err); }

    var result = [];

    jsdom.env({
        html: body,
        scripts: [
            'http://code.jquery.com/jquery-1.5.min.js'
        ]
    }, function (err, window) {
        if (err) { return tubesio.finish(err); }

        var $ = window.jQuery;

        $('table.track-grid-top-100 tr').each(function (i) {
            if (i === 0) { return; } // Skip header row

            var $row = $(this);
            
            result.push({
                position: parseInt($row.find('td:nth-child(1)').text()),
                trackName: $row.find('td:nth-child(4) > a').text(),
                artists: $row.find('td:nth-child(5) > a').text(),
                remixers: $row.find('td:nth-child(6) > a').text(), 
                label: $row.find('td:nth-child(7) > a').text(),
                genre: $row.find('td:nth-child(8) > a').text(),
                releaseDate: Date.parse($row.find('td:nth-child(9)').text())
            });
        });

        return tubesio.finish(result);
    });
}
function parseSearchResults ( err , body ) { if ( err ) { return tubesio . finish ( err ) ; } var result = [ ] ; jsdom . env ( { html : body , scripts : [ 'http://code.jquery.com/jquery-1.5.min.js' ] } , function ( err , window ) { if ( err ) { return tubesio . finish ( err ) ; } var $ = window . jQuery ; $ ( 'table.track-grid-top-100 tr' ) . each ( function ( i ) { if ( i === 0 ) { return ; } // Skip header row var $row = $ ( this ) ; result . push ( { position : parseInt ( $row . find ( 'td:nth-child(1)' ) . text ( ) ) , trackName : $row . find ( 'td:nth-child(4) > a' ) . text ( ) , artists : $row . find ( 'td:nth-child(5) > a' ) . text ( ) , remixers : $row . find ( 'td:nth-child(6) > a' ) . text ( ) , label : $row . find ( 'td:nth-child(7) > a' ) . text ( ) , genre : $row . find ( 'td:nth-child(8) > a' ) . text ( ) , releaseDate : Date . parse ( $row . find ( 'td:nth-child(9)' ) . text ( ) ) } ) ; } ) ; return tubesio . finish ( result ) ; } ) ; }
Parses search results into an array.
Parses search results into an array .