Permalink
Browse files

Merge branch 'master' into gh-pages

  • Loading branch information...
2 parents 2845e65 + 806500d commit c910b0b596ccabf73c3eb12b93f671c4bd2fcd82 @qiao committed May 23, 2012
Showing with 47 additions and 29 deletions.
  1. +1 −1 index.html
  2. +39 −27 lib/Detector.js
  3. +7 −1 notsupported.html
View
2 index.html
@@ -7,7 +7,7 @@
<link href="./build/application.css" rel="stylesheet" />
<script src="./lib/Detector.js" type="text/javascript"></script>
<script type="text/javascript">
- if (!Detector.webgl) {
+ if (!Detector.webgl || !Detector.chrome) {
window.location = './notsupported.html';
}
</script>
View
66 lib/Detector.js
@@ -5,46 +5,58 @@
Detector = {
- canvas: !! window.CanvasRenderingContext2D,
- webgl: ( function () { try { return !! window.WebGLRenderingContext && !! document.createElement( 'canvas' ).getContext( 'experimental-webgl' ); } catch( e ) { return false; } } )(),
- workers: !! window.Worker,
- fileapi: window.File && window.FileReader && window.FileList && window.Blob,
+ chrome: window.navigator.userAgent.toLowerCase().indexOf('chrome') > -1,
+ canvas: !! window.CanvasRenderingContext2D,
+ webgl: ( function () { try { return !! window.WebGLRenderingContext && !! document.createElement( 'canvas' ).getContext( 'experimental-webgl' ); } catch( e ) { return false; } } )(),
+ workers: !! window.Worker,
+ fileapi: window.File && window.FileReader && window.FileList && window.Blob,
- getWebGLErrorMessage: function () {
+ getNotChromeMessage: function () {
- var element = document.createElement( 'div' );
- element.id = 'webgl-error-message';
+ var element = document.createElement( 'div' );
+ element.id = 'webgl-error-message';
- if ( ! this.webgl ) {
+ element.innerHTML = 'Sorry, this demo only supports <a href="https://www.google.com/chrome">Google Chrome</a>';
- element.innerHTML = window.WebGLRenderingContext ? [
- 'Your graphics card does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a>.<br />',
- 'Find out how to get it <a href="http://get.webgl.org/" >here</a>.'
- ].join( '\n' ) : [
- 'Your browser does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" >WebGL</a>.<br/>',
- 'Find out how to get it <a href="http://get.webgl.org/" >here</a>.'
- ].join( '\n' );
+ return element;
- }
+ },
- return element;
+ getWebGLErrorMessage: function () {
- },
+ var element = document.createElement( 'div' );
+ element.id = 'webgl-error-message';
- addGetWebGLMessage: function ( parameters ) {
+ if ( ! this.webgl ) {
- var parent, id, element;
+ element.innerHTML = window.WebGLRenderingContext ? [
+ 'Your graphics card does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a>.<br />',
+ 'Find out how to get it <a href="http://get.webgl.org/" >here</a>.'
+ ].join( '\n' ) : [
+ 'Your browser does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" >WebGL</a>.<br/>',
+ 'Find out how to get it <a href="http://get.webgl.org/" >here</a>.'
+ ].join( '\n' );
- parameters = parameters || {};
+ }
- parent = parameters.parent !== undefined ? parameters.parent : document.body;
- id = parameters.id !== undefined ? parameters.id : 'oldie';
+ return element;
- element = Detector.getWebGLErrorMessage();
- element.id = id;
+ },
- parent.appendChild( element );
+ addGetWebGLMessage: function ( parameters ) {
- }
+ var parent, id, element;
+
+ parameters = parameters || {};
+
+ parent = parameters.parent !== undefined ? parameters.parent : document.body;
+ id = parameters.id !== undefined ? parameters.id : 'oldie';
+
+ element = Detector.getWebGLErrorMessage();
+ element.id = id;
+
+ parent.appendChild( element );
+
+ }
};
View
8 notsupported.html
@@ -26,7 +26,13 @@
<body>
<script src="./lib/Detector.js" type="text/javascript"></script>
<script type="text/javascript">
- document.body.appendChild(Detector.getWebGLErrorMessage());
+ var message;
+ if (!Detector.chrome) {
+ message = Detector.getNotChromeMessage();
+ } else if (!Detector.webgl) {
+ message = Detector.getWebGLErrorMessage();
+ }
+ document.body.appendChild(message);
</script>
</body>
</html>

0 comments on commit c910b0b

Please sign in to comment.