This project is read-only.

js decimal error


In TimelineNet the decimal character reflects the regional settings of the computer that the application is run on.
It shouldn't do that since javascript always uses period for decimals regardless the system's regional settings.
When running on Danish (and many other) systems the emitted javascript contains comma instead of period, and this causes a javascript error in the browser.
The attached pdf contains screenshots of what I'm trying to describe.
Until fixed, a workaround for the problem is to go to control panel > regional settings and change the decimal character to . (period).

file attachments


joeaudette wrote Jul 12, 2009 at 1:51 PM

I came across this issue today. I believe it is the browser language preference rather than the machine regional settings. I was informed about the issue by a Dutch user and I was able to produce the issue by setting my browser preferred language to nl-NL. By default ASP.NET will set the executing thread to the culture of the browser language preference, so calling .ToString() on a decimal value will localize the format.
I was able to fix it by modifying the source of Timeline.NET and rebuilding it.
In the file Band.cs I added at the top:
using System.Globalization;
Then I fixed the 2 lines where a decimal was being converted .ToString() approximate line number in the file is 57, my copy now looks like this and it works.

if(TrackHeight > 0) sb.Append(string.Format(",trackHeight: {0}\n", TrackHeight.ToString(CultureInfo.InvariantCulture))); // Joe Audette - added InvariantCulture
if (TrackGap > 0) sb.Append(string.Format(",trackGap: {0}\n", TrackGap.ToString(CultureInfo.InvariantCulture))); // Joe Audette - added InvariantCulture

using .ToString(CultureInfo.InvariantCulture) makes it format the decimal without regard to localization and this prevents the javascript error that would occur if the decimal was formatted as a comma.

Hope the maintainer will integrate this fix and others I have posted, but until then I have to maintain my own copy of the source code for use in my projects.

wrote Feb 14, 2013 at 7:33 PM