-
Notifications
You must be signed in to change notification settings - Fork 11
/
Detector.js
55 lines (38 loc) · 1.63 KB
/
Detector.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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,
getWebGLErrorMessage : function () {
var domElement = document.createElement( 'div' );
domElement.style.fontFamily = 'monospace';
domElement.style.fontSize = '13px';
domElement.style.textAlign = 'center';
domElement.style.background = '#eee';
domElement.style.color = '#000';
domElement.style.padding = '1em';
domElement.style.width = '475px';
domElement.style.margin = '5em auto 0';
if ( ! this.webgl ) {
domElement.innerHTML = window.WebGLRenderingContext ? [
'error'
].join( '\n' ) : [
'Sorry, your browser doesn\'t support WebGL</a><br/>',
'Please try with',
'<a href="http://www.google.com/chrome">Chrome</a>, ',
'<a href="http://www.mozilla.com/en-US/firefox/new/">Firefox 4</a> or',
'<a href="http://nightly.webkit.org/">Webkit Nightly (Mac)</a>'
].join( '\n' );
}
return domElement;
},
addGetWebGLMessage : function ( parameters ) {
var parent, id, domElement;
parameters = parameters || {};
parent = parameters.parent !== undefined ? parameters.parent : document.body;
id = parameters.id !== undefined ? parameters.id : 'oldie';
domElement = Detector.getWebGLErrorMessage();
domElement.id = id;
parent.appendChild( domElement );
}
};