1+ /****************************************************************************
2+ http://www.cocos2d-html5.org
3+ http://www.cocos2d-iphone.org
4+ http://www.cocos2d-x.org
5+
6+ Permission is hereby granted, free of charge, to any person obtaining a copy
7+ of this software and associated documentation files (the "Software"), to deal
8+ in the Software without restriction, including without limitation the rights
9+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ copies of the Software, and to permit persons to whom the Software is
11+ furnished to do so, subject to the following conditions:
12+
13+ The above copyright notice and this permission notice shall be included in
14+ all copies or substantial portions of the Software.
15+
16+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+ THE SOFTWARE.
23+ ****************************************************************************/
24+
25+ var sys = sys || { } ;
26+
27+ /** LocalStorage is a local storage component.
28+ */
29+ sys . localStorage = window . localStorage ;
30+
31+
32+ /** Capabilities
33+ */
34+ Object . defineProperties ( sys ,
35+ {
36+ "capabilities" : {
37+ get : function ( ) {
38+ var capabilities = { "canvas" :true } ;
39+
40+ // if (window.DeviceOrientationEvent!==undefined || window.OrientationEvent!==undefined)
41+ // capabilities["accelerometer"] = true;
42+
43+ if ( 'ontouchstart' in document . documentElement )
44+ capabilities [ "touches" ] = true ;
45+ else if ( 'onmouseup' in document . documentElement )
46+ capabilities [ "mouse" ] = true ;
47+
48+ if ( 'onkeyup' in document . documentElement )
49+ capabilities [ "keyboard" ] = true ;
50+
51+ return capabilities ;
52+ } ,
53+ enumerable : true ,
54+ configurable : true
55+ } ,
56+ "os" : {
57+ get : function ( ) {
58+ var iOS = ( navigator . userAgent . match ( / ( i P a d | i P h o n e | i P o d ) / i) ? true : false ) ;
59+ var isAndroid = navigator . userAgent . match ( / a n d r o i d / i) || navigator . platform . match ( / a n d r o i d / i) ? true : false ;
60+ var OSName = navigator . appVersion ;
61+ if ( navigator . appVersion . indexOf ( "Win" ) != - 1 )
62+ OSName = "Windows" ;
63+ else if ( navigator . appVersion . indexOf ( "Mac" ) != - 1 )
64+ OSName = "OS X" ;
65+ else if ( navigator . appVersion . indexOf ( "X11" ) != - 1 )
66+ OSName = "UNIX" ;
67+ else if ( navigator . appVersion . indexOf ( "Linux" ) != - 1 )
68+ OSName = "Linux" ;
69+ else if ( iOS )
70+ OSName = "iOS" ;
71+ else if ( isAndroid )
72+ OSName = "Android" ;
73+ } ,
74+ enumerable : true ,
75+ configurable : true
76+ } ,
77+ "platform" : {
78+ get : function ( ) {
79+ return "browser" ;
80+ } ,
81+ enumerable : true ,
82+ configurable : true
83+ } ,
84+ "version" : {
85+ get : function ( ) {
86+ return cc . ENGINE_VERSION ;
87+ } ,
88+ enumerable : true ,
89+ configurable : true
90+ }
91+ } ) ;
0 commit comments