Author Topic: First attempt at km/mi selection  (Read 9820 times)

0 Members and 1 Guest are viewing this topic.

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 2727
  • Last Login:Today at 05:41:06 am
First attempt at km/mi selection
« on: May 10, 2017, 04:42:12 pm »
Please have a look at http://tmtest.teresco.org/stat.php which has the first attempt at supporting switching between miles and kilometers.  Other pages not yet done, so look only at stat.php functionality.  Once you have switched to metric once (or back), you'll have a browser cookie remembering your most recent choice, the same way it remembers your most recent user selection.

Comments welcome.  With one page done, it shouldn't be too hard to convert the rest of the site.

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 2727
  • Last Login:Today at 05:41:06 am
Re: First attempt at km/mi selection
« Reply #1 on: May 10, 2017, 05:45:17 pm »
One issue I've noticed since posting this is that my change to use thousands separators has broken the table sorting.  It seems now to be sorting strings instead of numeric values.  The table sorting code isn't mine, so I'm not sure how easily I'll be able to fix that up.

Offline michih

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 4554
  • Last Login:Yesterday at 02:35:49 pm
Re: First attempt at km/mi selection
« Reply #2 on: May 11, 2017, 04:35:16 am »
To be honest, I don't like the current solution. It's not intuitive that you can switch it there and it looks quite odd that the button is available in both tables (Active and active+preview).
Only the selected option should be displayed in the table where it is right now. I prefer a selection at the top next to the user selection.

If "miles" is selected, the first row of the right table has 2 lines. It's fine with "km" selected.
We already have the line break issue active for a long time.
« Last Edit: May 11, 2017, 04:37:49 am by michih »

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 2727
  • Last Login:Today at 05:41:06 am
Re: First attempt at km/mi selection
« Reply #3 on: May 12, 2017, 06:38:39 pm »
I prefer a selection at the top next to the user selection.

Thanks for the comments on it.

So anywhere we currently have the user selection dropdown menu and button to switch users, also have the miles/km selection?  Would you leave it out completely on the page I modified so far?

Offline mapcat

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 1627
  • Last Login:Yesterday at 11:32:22 pm
Re: First attempt at km/mi selection
« Reply #4 on: May 12, 2017, 07:20:07 pm »
How about a general user prefs page? We'd talked before about making other aspects of the site customizable, like systems to track/ignore. It could start with km/mi.
Clinched:

Offline michih

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 4554
  • Last Login:Yesterday at 02:35:49 pm
Re: First attempt at km/mi selection
« Reply #5 on: May 13, 2017, 03:15:03 am »
So anywhere we currently have the user selection dropdown menu and button to switch users, also have the miles/km selection?

Yes. Next to the user selection.

Would you leave it out completely on the page I modified so far?

I would display the selected option there w/o change option because it indicates that you can switch "active" table to km and leave "active+preview" table with miles etc.

I would add it everywhere you can select the user. The user can be selected on stats.php and in the HB but only when a route is selected, e.g. it's here but not here which is odd.

Maybe I should publish my thoughts about how to browse routes because it could help to fix this issue....


How about a general user prefs page? We'd talked before about making other aspects of the site customizable, like systems to track/ignore. It could start with km/mi.

I have it on the list for user-specific default data: https://github.com/TravelMapping/Web/issues/21. But I think it might be a way too far right now. We have more important things to do first. However, it's Jim's decision and time. In addition, I don't have any idea about the effort. Maybe it's less than I think.

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 2727
  • Last Login:Today at 05:41:06 am
Re: First attempt at km/mi selection
« Reply #6 on: May 17, 2017, 03:02:09 pm »
I got 1 negative and 0 positive responses about the first draft of metric support, so here's another attempt:

http://tmtest.teresco.org/stat.php

The user selector is now accompanied by a preferred units selector, with 4 options so far, defaulting to miles.

Let me know how this works and looks on the stat.php page and if it's OK, I'll spread the changes around to the other parts of the site.

I'm open to other ideas on distance units to include. 

Offline michih

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 4554
  • Last Login:Yesterday at 02:35:49 pm
Re: First attempt at km/mi selection
« Reply #7 on: May 17, 2017, 03:31:36 pm »
It's fine to me but do you really think ft and meters are necessary? Maybe ft makes sense but not meters because factor is 1,000.

952,898.22 miles
5,031,302,601.60 ft

1,533,541,032.97 meters
1,533,541.03 km

Theoretically, yard and inch might be added....

Dunno if "Preferred Units:" is perfect. Maybe just "Units:" because only one unit can or should be active at once.

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 2727
  • Last Login:Today at 05:41:06 am
Re: First attempt at km/mi selection
« Reply #8 on: May 17, 2017, 03:42:43 pm »
I doubt people would use anything other than miles or km other than for fun.  I thought about putting in light years.  But the way the code is designed, adding a name and a conversion factor from miles to a lookup table in one place will add that unit as an option everywhere.

"Units" in place of "Preferred Units" is OK with me.

Anyone else want to weigh in before I expand to the rest of the pages on the site?

Offline si404

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 1941
  • Last Login:Today at 08:16:51 am
Re: First attempt at km/mi selection
« Reply #9 on: May 17, 2017, 04:14:36 pm »
I like it.

And it would be easy to add Furlongs (8 to a mile), Chains (80 to a mile), Light Seconds (~186282 miles - only oscar and mapcat have travelled more than one), even though it's totally pointless.

Offline mapcat

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 1627
  • Last Login:Yesterday at 11:32:22 pm
Re: First attempt at km/mi selection
« Reply #10 on: May 17, 2017, 05:00:47 pm »
Looks great!
Clinched:

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 2727
  • Last Login:Today at 05:41:06 am
Re: First attempt at km/mi selection
« Reply #11 on: May 17, 2017, 05:46:48 pm »
I've expanded to a few more pages on the tmtest site.  Hope to get to the rest tonight.

Offline sipes23

  • Newbie
  • *
  • Posts: 29
  • Last Login:August 19, 2019, 12:44:31 am
Re: First attempt at km/mi selection
« Reply #12 on: May 17, 2017, 08:46:46 pm »
I like it. It's pretty unobtrusive, yet obvious enough if you want to switch units.

Offline Jim

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 2727
  • Last Login:Today at 05:41:06 am
Re: First attempt at km/mi selection
« Reply #13 on: May 17, 2017, 10:34:17 pm »
I think I've hit everything to honor and allow selection of units.  I've also made some other minor fixes and enhancements as I noticed them.  If I don't hear any major problems by Thursday night, I'll go live with this on the production site.  For now, I'd appreciate any testing you can do on tmtest.teresco.org pages.

Offline mapcat

  • TM Collaborator
  • Hero Member
  • *****
  • Posts: 1627
  • Last Login:Yesterday at 11:32:22 pm
Re: First attempt at km/mi selection
« Reply #14 on: May 17, 2017, 11:21:01 pm »
Table sorting is still hinky, regardless of unit (on user stats page, both by region and by system). That's all I've noticed.
Clinched: