Created
July 11, 2013 15:29
-
-
Save cwardzala/5976476 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var platforms = [ | |
{ category: 'windows', tokens: /(Windows)/i }, | |
{ category: 'mac', tokens: /(Macintosh)/i }, | |
{ category: 'iOS', tokens: /(iPad|iPhone|iPod)/i }, | |
{ category: 'android', tokens: /(Android)/i }, | |
{ category: 'silk', tokens: /(Silk)/i }, | |
{ category: 'winmobile', tokens: /(Windows Phone OS|Zune)/i }, | |
// Linux is tricky because Anroid reports itself as Linux. | |
// If you are using is.linux to detect desktop linux make sure you also check !is.android | |
{ category: 'linux', tokens: /(Linux)/i } | |
]; | |
for (var i=0;i<platforms.length;i++) { | |
if (platforms[i].tokens.test(window.navigator.userAgent)) { | |
$('html').addClass('is-' + platforms[i].category); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment