diff --git a/Views/Shared/_Layout.cshtml b/Views/Shared/_Layout.cshtml
index 5694d37..146d012 100644
--- a/Views/Shared/_Layout.cshtml
+++ b/Views/Shared/_Layout.cshtml
@@ -6,6 +6,7 @@
var useDarkMode = userConfig.UseDarkMode;
var enableCsvImports = userConfig.EnableCsvImports;
var shortDatePattern = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
+ var numberFormat = System.Globalization.CultureInfo.CurrentCulture.NumberFormat;
shortDatePattern = shortDatePattern.ToLower();
if (!shortDatePattern.Contains("dd"))
{
@@ -54,6 +55,16 @@
pattern: "@shortDatePattern"
}
}
+ function globalParseFloat(input){
+ //remove thousands separator.
+ var thousandSeparator = "@numberFormat.NumberGroupSeparator";
+ var decimalSeparator = "@numberFormat.NumberDecimalSeparator";
+ //strip thousands from input.
+ input = input.replace(thousandSeparator, "");
+ //convert to JS format where decimal is only separated by .
+ input = input.replace(decimalSeparator, ".");
+ return parseFloat(input);
+ }
@await RenderSectionAsync("Scripts", required: false)
diff --git a/Views/Vehicle/Index.cshtml b/Views/Vehicle/Index.cshtml
index 0d7f3a5..3a3e42a 100644
--- a/Views/Vehicle/Index.cshtml
+++ b/Views/Vehicle/Index.cshtml
@@ -153,6 +153,11 @@
+
\ No newline at end of file
diff --git a/Views/Vehicle/_SupplyUsage.cshtml b/Views/Vehicle/_SupplyUsage.cshtml
index ea08ac0..c58acdc 100644
--- a/Views/Vehicle/_SupplyUsage.cshtml
+++ b/Views/Vehicle/_SupplyUsage.cshtml
@@ -1,40 +1,57 @@
@model List
-
+
\ No newline at end of file
diff --git a/wwwroot/js/gasrecord.js b/wwwroot/js/gasrecord.js
index 9524575..e7621e1 100644
--- a/wwwroot/js/gasrecord.js
+++ b/wwwroot/js/gasrecord.js
@@ -91,14 +91,14 @@ function getAndValidateGasRecordValues() {
} else {
$("#gasRecordMileage").removeClass("is-invalid");
}
- if (gasGallons.trim() == '' || parseFloat(gasGallons) <= 0) {
+ if (gasGallons.trim() == '' || globalParseFloat(gasGallons) <= 0) {
hasError = true;
$("#gasRecordGallons").addClass("is-invalid");
} else {
$("#gasRecordGallons").removeClass("is-invalid");
}
if (gasCostType != undefined && gasCostType == 'unit') {
- var convertedGasCost = parseFloat(gasCost) * parseFloat(gasGallons);
+ var convertedGasCost = globalParseFloat(gasCost) * globalParseFloat(gasGallons);
gasCost = convertedGasCost.toFixed(2).toString();
if (isNaN(gasCost))
{
diff --git a/wwwroot/js/reports.js b/wwwroot/js/reports.js
index 2a2a336..1c5bcbb 100644
--- a/wwwroot/js/reports.js
+++ b/wwwroot/js/reports.js
@@ -12,12 +12,8 @@ function generateVehicleHistoryReport() {
}
})
}
-var debounce = null;
-function updateCheck(sender) {
- clearTimeout(debounce);
- debounce = setTimeout(function () {
- refreshBarChart();
- }, 1000);
+function updateCheck() {
+ setDebounce(refreshBarChart);
}
function refreshMPGChart() {
var vehicleId = GetVehicleId().vehicleId;
@@ -26,7 +22,7 @@ function refreshMPGChart() {
$("#monthFuelMileageReportContent").html(data);
})
}
-function refreshBarChart(callBack) {
+function refreshBarChart() {
var selectedMetrics = [];
var vehicleId = GetVehicleId().vehicleId;
var year = getYear();
diff --git a/wwwroot/js/shared.js b/wwwroot/js/shared.js
index 85fe061..04904f6 100644
--- a/wwwroot/js/shared.js
+++ b/wwwroot/js/shared.js
@@ -147,4 +147,11 @@ function decodeHTMLEntities(text) {
return $("")
.html(text)
.text();
+}
+var debounce = null;
+function setDebounce(callBack) {
+ clearTimeout(debounce);
+ debounce = setTimeout(function () {
+ callBack();
+ }, 1000);
}
\ No newline at end of file
diff --git a/wwwroot/js/supplyrecord.js b/wwwroot/js/supplyrecord.js
index 82a1131..ba12e72 100644
--- a/wwwroot/js/supplyrecord.js
+++ b/wwwroot/js/supplyrecord.js
@@ -93,7 +93,7 @@ function getAndValidateSupplyRecordValues() {
} else {
$("#supplyRecordDescription").removeClass("is-invalid");
}
- if (supplyQuantity.trim() == '' || !isValidMoney(supplyQuantity) || parseFloat(supplyQuantity) < 0) {
+ if (supplyQuantity.trim() == '' || !isValidMoney(supplyQuantity) || globalParseFloat(supplyQuantity) < 0) {
hasError = true;
$("#supplyRecordQuantity").addClass("is-invalid");
} else {