function matchFuelLogs() { $('.breadcrumb').hide(); $('tr:not(.complete) .match-status').append('Pending tbody > tr:not(.complete)").length; $('#page-match-status').html(' Matching In Progress for ' + total + ' fuel logs. Keep page open until complete.'); $('#page-match-status').after('
'); $(".match-status a").addClass('pull-right'); submitNext(); var unmatchedCount = 0; var errorCount = 0; function submitNext() { var $fuelLogs = $("#fuellogs > tbody > tr:not(.complete)"); var percentComplete = Math.round( (1 - ($fuelLogs.length / total)) * 100 ); $('.progress .bar').attr('style', 'width:' + percentComplete + '%'); if ($fuelLogs.length > 0) { var $row = $($fuelLogs[0]); var data = $('form', $row).serialize(); var url = $('form', $row).attr('action'); $('.match-status', $row).html(' Submitting'); $.ajax({ url: url, type: 'post', data: data, success: function (result) { $row.addClass("complete"); if (result.Status == "Match") { $('.match-status', $row).html('Match found'); } else if (result.Status == "NoMatch" || result.Status == "Error") { if (result.Status == "NoMatch") { $('.match-status', $row).html('No Match'); unmatchedCount++; } else { $('.match-status', $row).html('Error'); errorCount++; $('.progress .bar').addClass('bar-warning'); } $('.match-message', $row).text(result.Message); } if (result.Action != undefined && result.Action != null) { $('.match-status', $row).append(" " + result.Action); $("a", $row).addClass('pull-right'); matchCountFunc.apply($("a[matchcount]", $row)); } submitNext(); } }); } else { $('.breadcrumb').show(); $('.progress').removeClass('progress-striped'); $('.progress').removeClass('active'); if (errorCount == 0) { $('#page-match-status').html('Complete ' + total + ' total with ' + unmatchedCount + ' left unmatched.'); $('.progress .bar').addClass('bar-success'); } else { $('#page-match-status').html('Complete with errors. See below.'); } } } }