Skip to content

Instantly share code, notes, and snippets.

@neave
Created May 20, 2011 10:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neave/982676 to your computer and use it in GitHub Desktop.
Save neave/982676 to your computer and use it in GitHub Desktop.
System.js with UAs reordered and iOS updated to include iPhone
/**
* @author mr.doob / http://mrdoob.com/
*/
System = {
browser: ( function () {
if ( navigator.userAgent.match( /msie/i ) ) {
return 'Internet Explorer';
} else if ( navigator.userAgent.match( /chrome/i ) ) {
return 'Chrome';
} else if ( navigator.userAgent.match( /firefox/i ) ) {
return 'Firefox';
} else if ( navigator.userAgent.match( /mobile safari/i ) ) {
return 'Mobile Safari';
} else if ( navigator.userAgent.match( /safari/i ) ) {
return 'Safari';
} else if ( navigator.userAgent.match( /opera/i ) ) {
return 'Opera';
} else if ( navigator.userAgent.match( /arora/i ) ) {
return 'Arora';
} else if ( navigator.userAgent.match( /epiphany/i ) ) {
return 'Epiphany';
} else if ( navigator.userAgent.match( /midori/i ) ) {
return 'Midori';
}
return false;
} )(),
os: ( function () {
if ( navigator.userAgent.match( /windows/i ) ) {
return 'Windows';
} else if ( navigator.userAgent.match( /macintosh/i ) ) {
return 'Macintosh';
} else if ( navigator.userAgent.match( /linux/i ) ) {
return 'Linux';
} else if ( navigator.userAgent.match( /android/i ) ) {
return 'Android';
} else if ( navigator.userAgent.match( /iphone|ipod|ipad/i ) ) {
return 'iOS';
}
return false;
} )(),
supports: {
canvas: !! window.CanvasRenderingContext2D,
webgl: ( function () {
try {
return !! window.WebGLRenderingContext && !! document.createElement( 'canvas' ).getContext( 'experimental-webgl' );
} catch( error ) {
return false;
}
} )(),
worker: !! window.Worker,
file: window.File && window.FileReader && window.FileList && window.Blob
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment