@@ -53,12 +53,22 @@ cc.create3DContext = function (canvas, opt_attribs) {
5353 */
5454cc . Browser = { } ;
5555( function ( ) {
56- cc . Browser . ua = navigator . userAgent . toLowerCase ( ) ;
56+ var ua = navigator . userAgent ;
57+ cc . Browser . ua = ua . toLowerCase ( ) ;
5758 cc . Browser . platform = navigator . platform . toLowerCase ( ) ;
58- cc . Browser . UA = cc . Browser . ua . match ( / ( o p e r a | i e | f i r e f o x | c h r o m e | v e r s i o n ) [ \s \/ : ] ( [ \w \d \. ] + ) ? .* ?( s a f a r i | v e r s i o n [ \s \/ : ] ( [ \w \d \. ] + ) | $ ) / ) || [ null , 'unknown' , 0 ] ;
59- cc . Browser . mode = cc . Browser . UA [ 1 ] == 'ie' && document . documentMode ;
60- cc . Browser . type = ( cc . Browser . UA [ 1 ] == 'version' ) ? cc . Browser . UA [ 3 ] : cc . Browser . UA [ 1 ] ;
6159 cc . Browser . isMobile = ( cc . Browser . ua . indexOf ( 'mobile' ) != - 1 || cc . Browser . ua . indexOf ( 'android' ) != - 1 ) ;
60+ cc . Browser . type = ( function ( ) {
61+ var browserTypes = cc . Browser . ua . match ( / m i c r o m e s s e n g e r | q q b r o w s e r | m q q b r o w s e r | u c b r o w s e r | 3 6 0 b r o w s e r | b a i d u b r o w s e r | m a x t h o n | i e | o p e r a | f i r e f o x / ) || cc . Browser . ua . match ( / c h r o m e | s a f a r i / ) ;
62+ if ( browserTypes . length > 0 ) {
63+ var el = browserTypes [ 0 ] ;
64+ if ( el == 'micromessenger' ) {
65+ return 'wechat' ;
66+ }
67+ return el ;
68+ }
69+ return "unknow" ;
70+ } ) ( ) ;
71+ cc . Browser . mode = cc . Browser . type == 'ie' && document . documentMode ;
6272
6373 if ( ! document [ "ccConfig" ] )
6474 document [ "ccConfig" ] = { } ;
@@ -67,23 +77,23 @@ cc.Browser = {};
6777 // check supportWebGL item
6878 cc . _userRenderMode = parseInt ( c [ "renderMode" ] ) || 0 ;
6979
70- if ( cc . _userRenderMode === 1 ) {
71- //canvas only
80+ if ( cc . _userRenderMode === 1 ) {
81+ //canvas only
7282 cc . Browser . supportWebGL = false ;
73- } else {
83+ } else {
7484 // WebGL first
7585 cc . Browser . supportWebGL = ! ( window . WebGLRenderingContext == null ) ;
7686 var tempCanvas = document . createElement ( "Canvas" ) ;
7787 var tempContext = cc . create3DContext ( tempCanvas , { 'stencil' :true , 'preserveDrawingBuffer' :true } ) ;
7888 cc . Browser . supportWebGL = ! ( tempContext == null )
7989 }
80- if ( cc . _userRenderMode === 2 && ! cc . Browser . supportWebGL ) {
90+ if ( cc . _userRenderMode === 2 && ! cc . Browser . supportWebGL ) {
8191 // WebGL render only, but browser doesn't support WebGL.
8292 cc . __renderDoesnotSupport = true ;
8393 }
8494
8595 // check if browser supports Web Audio
86- cc . Browser . supportWebAudio = ( function ( ) {
96+ cc . Browser . supportWebAudio = ( function ( ) {
8797 // check Web Audio's context
8898 try {
8999 var ctx = new ( window . AudioContext || window . webkitAudioContext || window . mozAudioContext ) ( ) ;
@@ -94,8 +104,8 @@ cc.Browser = {};
94104 } ) ( ) ;
95105} ) ( ) ;
96106
97- cc . RenderDoesnotSupport = function ( ) {
98- if ( cc . __renderDoesnotSupport === "undefined" )
107+ cc . RenderDoesnotSupport = function ( ) {
108+ if ( cc . __renderDoesnotSupport === "undefined" )
99109 return false ;
100110 return cc . __renderDoesnotSupport ;
101111} ;
0 commit comments