function importFuelLogs() {
$('.breadcrumb').hide();
$('tr:not(.complete) .match-status').append('Pending tbody > tr:not(.complete)").length;
$('#page-match-status').html(' Matching In Progress Keep page open until complete.');
$('#page-match-status').after('
');
submitNext();
var failureCount = 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');
} else {
$('.match-status', $row).html('Error');
}
$('.match-message', $row).text(result.Message);
failureCount++;
$('.progress .bar').addClass('bar-warning');
}
if (result.Action != undefined && result.Action != null) {
$('.match-status', $row).append(" " + result.Action);
}
submitNext();
}
});
} else {
$('.breadcrumb').show();
$('.progress').removeClass('progress-striped');
$('.progress').removeClass('active');
if (failureCount == 0) {
$('#page-match-status').html('Complete with all matches.');
$('.progress .bar').addClass('bar-success');
} else {
$('#page-match-status').html('Complete but with errors. See details below.');
}
}
}
}