From 77db2f1d14f28cd6df8e3c81bcabed3399078b1d Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 25 Sep 2017 19:09:09 +0200 Subject: [PATCH] Two dumbfixes --- Site/Automation/Formatting.aspx.cs | 2 +- .../v5/Financial/CurrencyTextBox.ascx | 36 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Site/Automation/Formatting.aspx.cs b/Site/Automation/Formatting.aspx.cs index b5a29746..eb7dac79 100644 --- a/Site/Automation/Formatting.aspx.cs +++ b/Site/Automation/Formatting.aspx.cs @@ -40,7 +40,7 @@ namespace Swarmops.Frontend.Automation return input.ToString("N2"); } - + [WebMethod] public static AjaxInputCallResult FormatCurrencyString(string input) { double outParse = 0.0; diff --git a/Site/Controls/v5/Financial/CurrencyTextBox.ascx b/Site/Controls/v5/Financial/CurrencyTextBox.ascx index 4572b507..7c990e2c 100644 --- a/Site/Controls/v5/Financial/CurrencyTextBox.ascx +++ b/Site/Controls/v5/Financial/CurrencyTextBox.ascx @@ -29,15 +29,17 @@ } $(document).ready(function () { - var currencyText = $('#<%=this.ClientID%>_TextInput').val(); - var jsonData = {}; - jsonData.input = currencyText; + $('#<%=this.ClientID%>_TextInput').blur(function () { - if (currencyText.trim().indexOf(' ') >= 0) { - // the text contains at least one space, so try to interpret it and convert it to presentation currency + var currencyText = $('#<%=this.ClientID%>_TextInput').val(); + + var jsonData = {}; + jsonData.input = currencyText; + + if (currencyText.trim().indexOf(' ') >= 0) { + // the text contains at least one space, so try to interpret it and convert it to presentation currency - $('#<%=this.ClientID%>_TextInput').blur(function() { SwarmopsJS.ajaxCall('/Automation/FinancialFunctions.aspx/InterpretCurrency', jsonData, function(data) { @@ -45,19 +47,19 @@ alert("PresentationAmount:" + data.DisplayAmount + "\r\nUsed Currency:" + data.CurrencyCode + "\r\nEntered Amount:" + data.EnteredAmount); } }); - }); - } else { - // the text does NOT contain at least one space, so we should format it for presentation currency - $('#<%=this.ClientID%>_TextInput').blur(function() { - SwarmopsJS.ajaxCall('/Automation/Formatting.aspx/FormatCurrencyString', - jsonData, - function(data) { - if (data.Success) { - $('#<%=this.ClientID%>_TextInput').val(data.Result); - } + } else { + // the text does NOT contain at least one space, so we should format it for presentation currency + $('#<%=this.ClientID%>_TextInput').blur(function() { + SwarmopsJS.ajaxCall('/Automation/Formatting.aspx/FormatCurrencyString', + jsonData, + function(data) { + if (data.Success) { + $('#<%=this.ClientID%>_TextInput').val(data.Result); + } + }); }); + } }); - } });