Easier way to determine the selected tab ad JS restructured

Hi,

as already commented on the other pull request, here comes my latest changes.

1. Just a small comment fix (typo)
2. I restructured the validTabs in combination with your elsif construct. I think this is more maintainable. I let find just return the first matching tab. The order in which find checks those tabs is defined by the order of the validTabs definition.
3. I removed some unused functions. On the other hand I changed the way you trigger the click event. 
$('.tab-history.selected').not('#tab-history_all')[0] && $('.tab-history.selected').not('#tab-history_all')[0].click();
This line just searches for all selected tabs, remove history_all and search for the first indice. If there is only history_all selected, this will return undefined, which prevents the second call to be executed. If the first construct gives some value (for example: tabtime_time), the second construct will be triggered and fire the click()-event.

If you have some questions or concerns, just comment back. Some feedback would be great as usual.

By the way, this should work out of the box, this time my VM works, which means I could directly upload my code to you.

Best regards,
Daniel