Travel Mapping

Web Design Discussion => General Web Design Discussion => Topic started by: Jim on May 10, 2017, 04:42:12 pm

Title: First attempt at km/mi selection
Post by: Jim 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.
Title: Re: First attempt at km/mi selection
Post by: Jim 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.
Title: Re: First attempt at km/mi selection
Post by: michih 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.
Title: Re: First attempt at km/mi selection
Post by: Jim 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?
Title: Re: First attempt at km/mi selection
Post by: mapcat 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.
Title: Re: First attempt at km/mi selection
Post by: michih 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 (http://tm.teresco.org/hb/index.php?u=michih&r=deu.a001) but not here (http://tm.teresco.org/hb/?u=michih&rg=DEU) 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.
Title: Re: First attempt at km/mi selection
Post by: Jim 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. 
Title: Re: First attempt at km/mi selection
Post by: michih 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.
Title: Re: First attempt at km/mi selection
Post by: Jim 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?
Title: Re: First attempt at km/mi selection
Post by: si404 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.
Title: Re: First attempt at km/mi selection
Post by: mapcat on May 17, 2017, 05:00:47 pm
Looks great!
Title: Re: First attempt at km/mi selection
Post by: Jim 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.
Title: Re: First attempt at km/mi selection
Post by: sipes23 on May 17, 2017, 08:46:46 pm
I like it. It's pretty unobtrusive, yet obvious enough if you want to switch units.
Title: Re: First attempt at km/mi selection
Post by: Jim 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.
Title: Re: First attempt at km/mi selection
Post by: mapcat 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.
Title: Re: First attempt at km/mi selection
Post by: Jim on May 18, 2017, 12:03:40 am
Table sorting is still hinky, regardless of unit (on user stats page, both by region and by system). That's all I've noticed.

I definitely haven't sorted out what's going on with that table sorting...  I think if I remove the thousands separator commas, things should at least be as good as they were before this round of tinkering.
Title: Re: First attempt at km/mi selection
Post by: Jim on May 18, 2017, 04:27:49 pm
This is now live on the main site.  I haven't addressed the table sorting issues that were introduced by my adding in the thousands separators, but I'd like to leave them in for now.  Any volunteers to dive into the tablesorter library we use?  I am thinking a custom sorting comparator (or whatever the JS equivalent is called) will do it.
Title: Re: First attempt at km/mi selection
Post by: michih on May 21, 2017, 02:53:20 am
I haven't addressed the table sorting issues that were introduced by my adding in the thousands separators, but I'd like to leave them in for now.  Any volunteers to dive into the tablesorter library we use?  I am thinking a custom sorting comparator (or whatever the JS equivalent is called) will do it.

I've submitted an issue: https://github.com/TravelMapping/Web/issues/180
Title: Re: First attempt at km/mi selection
Post by: Jim on May 21, 2017, 08:40:49 am
I haven't addressed the table sorting issues that were introduced by my adding in the thousands separators, but I'd like to leave them in for now.  Any volunteers to dive into the tablesorter library we use?  I am thinking a custom sorting comparator (or whatever the JS equivalent is called) will do it.

I've submitted an issue: https://github.com/TravelMapping/Web/issues/180

Perfect, thanks.
Title: Re: First attempt at km/mi selection
Post by: Thing342 on June 02, 2017, 01:07:13 pm
This is now live on the main site.  I haven't addressed the table sorting issues that were introduced by my adding in the thousands separators, but I'd like to leave them in for now.  Any volunteers to dive into the tablesorter library we use?  I am thinking a custom sorting comparator (or whatever the JS equivalent is called) will do it.
(sorry about my periodic absence, having been managing school + a full time job)

I generally try to avoid wading in the depths of JavaScript, but I would be in favor of completely replacing the library currently in use, as it's a janky, barely-documented jQuery thing that I used because it was quick and easy. I think we should maybe try for a more encompassing table library, such as https://datatables.net/ for a more consistent UX.
Title: Re: First attempt at km/mi selection
Post by: Jim on June 02, 2017, 02:30:52 pm
I generally try to avoid wading in the depths of JavaScript, but I would be in favor of completely replacing the library currently in use, as it's a janky, barely-documented jQuery thing that I used because it was quick and easy. I think we should maybe try for a more encompassing table library, such as https://datatables.net/ for a more consistent UX.

Thanks.  One of my students currently working on the academic project side of this is looking into some options for better tables on that end, and I expect we'll find something appropriate to move back to the TM side.  I'll point her to https://datatables.net/ as one of the options to evaluate.
Title: Re: First attempt at km/mi selection
Post by: Thing342 on June 02, 2017, 04:14:14 pm
Thanks.  One of my students currently working on the academic project side of this is looking into some options for better tables on that end, and I expect we'll find something appropriate to move back to the TM side.  I'll point her to https://datatables.net/ as one of the options to evaluate.

I created an issue for it: https://github.com/TravelMapping/Web/issues/183 (https://github.com/TravelMapping/Web/issues/183)

I've been working on a proof-of-concept with it, but if your student wishes to work more on it, i'll yield to you.