Match count badges

This commit is contained in:
2015-10-13 20:39:51 -04:00
parent 49c55ffba6
commit 78e8924bfa
4 changed files with 59 additions and 17 deletions
+34 -14
View File
@@ -21,11 +21,13 @@ $(function () {
$("form select#Year").change(function () {
var year = $(this).val();
var months = availableLogYearMonths[year];
var options = '<option>Select Month</option>';
for (var i = 0; i < months.length; i++) {
options += '<option>' + months[i] + '</option>';
}
$("form select#Month").html(options);
var options = '<option>Select Month</option>';
if (months != undefined) {
for (var i = 0; i < months.length; i++) {
options += '<option>' + months[i] + '</option>';
}
}
$("form select#Month").html(options);
});
$("input#ModelYear,input#Price,input#VehicleId,input#EndOdometer,input#GasPurchased").numeric();
@@ -70,15 +72,33 @@ $(function () {
// add recent logs to a div if it exists
$(function () {
var $recentLogs = $("#RecentLogs");
if ($recentLogs.length > 0) {
$.ajax({
url: "/CreateLog/RecentLogs",
success: function (data) {
$recentLogs.append(data);
}
});
}
var $recentLogs = $("#RecentLogs");
if ($recentLogs.length > 0) {
$.ajax({
url: "/FuelLog/RecentLogs",
success: function (data) {
$recentLogs.append(data);
}
});
}
});
// add get match count for all the current items
$(function () {
var $requests = $("a[matchcount]").map(function() {
var $link = $(this);
return $.ajax({
url: $link.attr("matchcount"),
success: function (matchcount) {
if (matchcount > 0) {
$link.append(" <span class='badge badge-info'>" + matchcount + "</span>");
} else {
$link.append(" <span class='badge'>0</span>");
}
}
});
});
$.when.apply($, $requests);
});
$(function() {