gabceb / jquery-browser-plugin

A jQuery plugin for browser detection
Other
505 stars 324 forks source link

Ability to find out the iOS version #30

Open thehappycoder opened 10 years ago

thehappycoder commented 10 years ago

Is it possible with this plugin?

le717 commented 10 years ago

@thehappycoder No, it is not possible. $.browser.version will bring out the browser version, not the platform version. Would it be possible to support? Yes, it would, as the iOS version is listed in the UA. It would require a new $.browser variable, editing of the regex, and changing under scores to dots for consistency, but none of that is too terribly hard. I could probably do it, but I don't know how to regex yet. :(

le717 commented 10 years ago

@gabceb Would this featured be considering inside the scope of jquery-brower? I just dug through that link I posted above, and iOS has a fairly consistent UA. The iOS version usually comes after CPU OS, then the version number is stated in the form MAJOR_MINOR, with MAJOR_MINOR_PATCH occurring for patch versions and a very few using only MAJOR, followed by like Mac OS X. There are a few that have everything lowercase, so it needs to be a case-insensitive search. There are also a few that follow the same format but inject iPhone, so the format is CPU iPhone OS MAJOR[_MINOR_PATCH] like Mac OS X. And there are still a small few do not follow the format or do not list the iOS version at all (Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A101a Safari/419.3, for example).

So while it would be possible to get the iOS version from the UA in most cases thanks to it being rather consistency, I'm not sure if it is something that should be considered for a plugin that detects browser details.

le717 commented 10 years ago

I forgot to add that all other instances of OS occur in the phrase like Mac OS X, so that might make it easier to ensure the iOS version is actually gathered.

gabceb commented 10 years ago

@le717 send me a PR with the OS information code + test and I will test it out and add it if it works for all major OSs

le717 commented 10 years ago

@gabceb I'll see what I can do. Regex has been a confusion to me (this would be a good time to learn them), and I'm smack in the middle of a big deal with college work, so I may not get this completed any time soon, but I'll try. :)