2013-04-13 03:25:03 +00:00
|
|
|
/// <reference path="../Game.ts" />
|
|
|
|
|
|
|
|
/**
|
2013-04-18 15:49:08 +00:00
|
|
|
* Phaser - Device
|
|
|
|
*
|
|
|
|
* Detects device support capabilities. Using some elements from System.js by MrDoob and Modernizr
|
|
|
|
* https://github.com/Modernizr/Modernizr/blob/master/feature-detects/audio.js
|
2013-04-18 13:16:18 +00:00
|
|
|
*/
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
module Phaser {
|
|
|
|
|
|
|
|
export class Device {
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Device constructor
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
constructor() {
|
|
|
|
|
|
|
|
this._checkAudio();
|
|
|
|
this._checkBrowser();
|
|
|
|
this._checkCSS3D();
|
|
|
|
this._checkDevice();
|
|
|
|
this._checkFeatures();
|
|
|
|
this._checkOS();
|
2013-04-13 03:25:03 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
// Operating System
|
|
|
|
|
2013-05-04 11:59:59 +00:00
|
|
|
/**
|
|
|
|
* Is running desktop?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public desktop: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running on iOS?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public iOS: bool = false;
|
|
|
|
|
2013-05-04 11:59:59 +00:00
|
|
|
/**
|
|
|
|
* Is running on android?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public android: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running on chromeOS?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public chromeOS: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running on linux?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public linux: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running on maxOS?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public macOS: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running on windows?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public windows: bool = false;
|
|
|
|
|
|
|
|
// Features
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is canvas available?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public canvas: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is file available?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public file: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is fileSystem available?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public fileSystem: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is localStorage available?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public localStorage: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is webGL available?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public webGL: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is worker available?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public worker: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is touch available?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public touch: bool = false;
|
|
|
|
|
2013-05-16 01:36:58 +00:00
|
|
|
/**
|
|
|
|
* Is mspointer available?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
public mspointer: bool = false;
|
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is css3D available?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public css3D: bool = false;
|
|
|
|
|
|
|
|
// Browser
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running in arora?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public arora: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running in chrome?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public chrome: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running in epiphany?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public epiphany: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running in firefox?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public firefox: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running in ie?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public ie: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Version of ie?
|
|
|
|
* @type Number
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public ieVersion: number = 0;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running in mobileSafari?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public mobileSafari: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running in midori?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public midori: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running in opera?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public opera: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running in safari?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public safari: bool = false;
|
|
|
|
public webApp: bool = false;
|
|
|
|
|
|
|
|
// Audio
|
|
|
|
|
|
|
|
/**
|
2013-07-16 13:45:08 +00:00
|
|
|
* Are Audio tags available?
|
2013-05-04 11:59:59 +00:00
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public audioData: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-07-16 13:45:08 +00:00
|
|
|
* Is the WebAudio API available?
|
2013-05-04 11:59:59 +00:00
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-07-16 13:45:08 +00:00
|
|
|
public webAudio: bool = false;
|
2013-04-18 13:16:18 +00:00
|
|
|
|
|
|
|
/**
|
2013-07-16 13:45:08 +00:00
|
|
|
* Can this device play ogg files?
|
2013-05-04 11:59:59 +00:00
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public ogg: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-07-16 13:45:08 +00:00
|
|
|
* Can this device play opus files?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
public opus: bool = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Can this device play mp3 files?
|
2013-05-04 11:59:59 +00:00
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public mp3: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-07-16 13:45:08 +00:00
|
|
|
* Can this device play wav files?
|
2013-05-04 11:59:59 +00:00
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public wav: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-07-16 13:45:08 +00:00
|
|
|
* Can this device play m4a files?
|
2013-05-04 11:59:59 +00:00
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public m4a: bool = false;
|
|
|
|
|
2013-07-16 13:45:08 +00:00
|
|
|
/**
|
|
|
|
* Can this device play webm files?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
public webm: bool = false;
|
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
// Device
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running on iPhone?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public iPhone: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running on iPhone4?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public iPhone4: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Is running on iPad?
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public iPad: bool = false;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* PixelRatio of the host device?
|
|
|
|
* @type Number
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public pixelRatio: number = 0;
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Check which OS is game running on.
|
|
|
|
* @private
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
private _checkOS() {
|
|
|
|
|
|
|
|
var ua = navigator.userAgent;
|
|
|
|
|
|
|
|
if (/Android/.test(ua))
|
|
|
|
{
|
|
|
|
this.android = true;
|
|
|
|
}
|
|
|
|
else if (/CrOS/.test(ua))
|
|
|
|
{
|
|
|
|
this.chromeOS = true;
|
|
|
|
}
|
|
|
|
else if (/iP[ao]d|iPhone/i.test(ua))
|
|
|
|
{
|
|
|
|
this.iOS = true;
|
|
|
|
}
|
|
|
|
else if (/Linux/.test(ua))
|
|
|
|
{
|
|
|
|
this.linux = true;
|
|
|
|
}
|
|
|
|
else if (/Mac OS/.test(ua))
|
|
|
|
{
|
|
|
|
this.macOS = true;
|
|
|
|
}
|
|
|
|
else if (/Windows/.test(ua))
|
|
|
|
{
|
|
|
|
this.windows = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.windows || this.macOS || this.linux)
|
|
|
|
{
|
|
|
|
this.desktop = true;
|
|
|
|
}
|
|
|
|
|
2013-04-13 03:25:03 +00:00
|
|
|
}
|
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Check HTML5 features of the host environment.
|
|
|
|
* @private
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
private _checkFeatures() {
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
this.canvas = !!window['CanvasRenderingContext2D'];
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
this.localStorage = !!localStorage.getItem;
|
|
|
|
}
|
|
|
|
catch (error)
|
|
|
|
{
|
|
|
|
this.localStorage = false;
|
|
|
|
}
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
this.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob'];
|
|
|
|
this.fileSystem = !!window['requestFileSystem'];
|
|
|
|
this.webGL = !!window['WebGLRenderingContext'];
|
|
|
|
this.worker = !!window['Worker'];
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
if ('ontouchstart' in document.documentElement || window.navigator.msPointerEnabled)
|
|
|
|
{
|
|
|
|
this.touch = true;
|
|
|
|
}
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-05-16 01:36:58 +00:00
|
|
|
if (window.navigator.msPointerEnabled)
|
|
|
|
{
|
|
|
|
this.mspointer = true;
|
|
|
|
}
|
|
|
|
|
2013-04-13 03:25:03 +00:00
|
|
|
}
|
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Check what browser is game running in.
|
|
|
|
* @private
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
private _checkBrowser() {
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
var ua = navigator.userAgent;
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
if (/Arora/.test(ua))
|
|
|
|
{
|
|
|
|
this.arora = true;
|
|
|
|
}
|
|
|
|
else if (/Chrome/.test(ua))
|
|
|
|
{
|
|
|
|
this.chrome = true;
|
|
|
|
}
|
|
|
|
else if (/Epiphany/.test(ua))
|
|
|
|
{
|
|
|
|
this.epiphany = true;
|
|
|
|
}
|
|
|
|
else if (/Firefox/.test(ua))
|
|
|
|
{
|
|
|
|
this.firefox = true;
|
|
|
|
}
|
|
|
|
else if (/Mobile Safari/.test(ua))
|
|
|
|
{
|
|
|
|
this.mobileSafari = true;
|
|
|
|
}
|
|
|
|
else if (/MSIE (\d+\.\d+);/.test(ua))
|
2013-07-16 13:45:08 +00:00
|
|
|
{
|
2013-04-18 13:16:18 +00:00
|
|
|
this.ie = true;
|
|
|
|
this.ieVersion = parseInt(RegExp.$1);
|
|
|
|
}
|
|
|
|
else if (/Midori/.test(ua))
|
|
|
|
{
|
|
|
|
this.midori = true;
|
|
|
|
}
|
|
|
|
else if (/Opera/.test(ua))
|
|
|
|
{
|
|
|
|
this.opera = true;
|
|
|
|
}
|
|
|
|
else if (/Safari/.test(ua))
|
|
|
|
{
|
|
|
|
this.safari = true;
|
|
|
|
}
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
// WebApp mode in iOS
|
|
|
|
if (navigator['standalone'])
|
2013-04-13 03:25:03 +00:00
|
|
|
{
|
2013-04-18 13:16:18 +00:00
|
|
|
this.webApp = true;
|
|
|
|
}
|
2013-04-13 03:25:03 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-07-16 13:45:08 +00:00
|
|
|
public canPlayAudio(type: string): bool {
|
|
|
|
|
|
|
|
if (type == 'mp3' && this.mp3)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (type == 'ogg' && (this.ogg || this.opus))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (type == 'm4a' && this.m4a)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (type == 'wav' && this.wav)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (type == 'webm' && this.webm)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Check audio support.
|
|
|
|
* @private
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
private _checkAudio() {
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
this.audioData = !!(window['Audio']);
|
2013-07-16 13:45:08 +00:00
|
|
|
this.webAudio = !!(window['webkitAudioContext'] || window['AudioContext']);
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
var audioElement: HTMLAudioElement = <HTMLAudioElement> document.createElement('audio');
|
|
|
|
var result = false;
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
try
|
2013-04-13 03:25:03 +00:00
|
|
|
{
|
2013-04-18 13:16:18 +00:00
|
|
|
if (result = !!audioElement.canPlayType)
|
2013-04-13 03:25:03 +00:00
|
|
|
{
|
2013-04-18 13:16:18 +00:00
|
|
|
if (audioElement.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ''))
|
|
|
|
{
|
|
|
|
this.ogg = true;
|
|
|
|
}
|
|
|
|
|
2013-07-16 13:45:08 +00:00
|
|
|
if (audioElement.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, ''))
|
|
|
|
{
|
|
|
|
this.opus = true;
|
|
|
|
}
|
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
if (audioElement.canPlayType('audio/mpeg;').replace(/^no$/, ''))
|
|
|
|
{
|
|
|
|
this.mp3 = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mimetypes accepted:
|
|
|
|
// developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements
|
|
|
|
// bit.ly/iphoneoscodecs
|
|
|
|
if (audioElement.canPlayType('audio/wav; codecs="1"').replace(/^no$/, ''))
|
|
|
|
{
|
|
|
|
this.wav = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (audioElement.canPlayType('audio/x-m4a;') || audioElement.canPlayType('audio/aac;').replace(/^no$/, ''))
|
|
|
|
{
|
|
|
|
this.m4a = true;
|
|
|
|
}
|
2013-07-16 13:45:08 +00:00
|
|
|
|
|
|
|
if (audioElement.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, ''))
|
|
|
|
{
|
|
|
|
this.webm = true;
|
|
|
|
}
|
2013-04-13 03:25:03 +00:00
|
|
|
}
|
2013-04-18 13:16:18 +00:00
|
|
|
} catch (e) { }
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
}
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Check PixelRatio of devices.
|
|
|
|
* @private
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
private _checkDevice() {
|
|
|
|
|
|
|
|
this.pixelRatio = window['devicePixelRatio'] || 1;
|
|
|
|
this.iPhone = navigator.userAgent.toLowerCase().indexOf('iphone') != -1;
|
|
|
|
this.iPhone4 = (this.pixelRatio == 2 && this.iPhone);
|
|
|
|
this.iPad = navigator.userAgent.toLowerCase().indexOf('ipad') != -1;
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Check whether the host environment support 3D CSS.
|
|
|
|
* @private
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
private _checkCSS3D() {
|
|
|
|
|
|
|
|
var el = document.createElement('p');
|
|
|
|
var has3d;
|
|
|
|
var transforms = {
|
|
|
|
'webkitTransform': '-webkit-transform',
|
|
|
|
'OTransform': '-o-transform',
|
|
|
|
'msTransform': '-ms-transform',
|
|
|
|
'MozTransform': '-moz-transform',
|
|
|
|
'transform': 'transform'
|
|
|
|
};
|
|
|
|
|
|
|
|
// Add it to the body to get the computed style.
|
|
|
|
document.body.insertBefore(el, null);
|
|
|
|
|
|
|
|
for (var t in transforms)
|
|
|
|
{
|
|
|
|
if (el.style[t] !== undefined)
|
2013-04-13 03:25:03 +00:00
|
|
|
{
|
2013-04-18 13:16:18 +00:00
|
|
|
el.style[t] = "translate3d(1px,1px,1px)";
|
|
|
|
has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
|
2013-04-13 03:25:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
document.body.removeChild(el);
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
this.css3D = (has3d !== undefined && has3d.length > 0 && has3d !== "none");
|
2013-04-13 03:25:03 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-05-18 02:05:28 +00:00
|
|
|
public isConsoleOpen(): bool {
|
|
|
|
|
|
|
|
if (window.console && window.console['firebug'])
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window.console)
|
|
|
|
{
|
|
|
|
console.profile();
|
|
|
|
console.profileEnd();
|
|
|
|
|
|
|
|
if (console.clear) console.clear();
|
|
|
|
|
|
|
|
return console['profiles'].length > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
/**
|
2013-05-04 11:59:59 +00:00
|
|
|
* Get all informations of host device.
|
|
|
|
* @return {string} Informations in a string.
|
|
|
|
*/
|
2013-04-18 13:16:18 +00:00
|
|
|
public getAll(): string {
|
|
|
|
|
|
|
|
var output: string = '';
|
|
|
|
|
|
|
|
output = output.concat('Device\n');
|
|
|
|
output = output.concat('iPhone : ' + this.iPhone + '\n');
|
|
|
|
output = output.concat('iPhone4 : ' + this.iPhone4 + '\n');
|
|
|
|
output = output.concat('iPad : ' + this.iPad + '\n');
|
|
|
|
|
|
|
|
output = output.concat('\n');
|
|
|
|
output = output.concat('Operating System\n');
|
|
|
|
output = output.concat('iOS: ' + this.iOS + '\n');
|
|
|
|
output = output.concat('Android: ' + this.android + '\n');
|
|
|
|
output = output.concat('ChromeOS: ' + this.chromeOS + '\n');
|
|
|
|
output = output.concat('Linux: ' + this.linux + '\n');
|
|
|
|
output = output.concat('MacOS: ' + this.macOS + '\n');
|
|
|
|
output = output.concat('Windows: ' + this.windows + '\n');
|
|
|
|
|
|
|
|
output = output.concat('\n');
|
|
|
|
output = output.concat('Browser\n');
|
|
|
|
output = output.concat('Arora: ' + this.arora + '\n');
|
|
|
|
output = output.concat('Chrome: ' + this.chrome + '\n');
|
|
|
|
output = output.concat('Epiphany: ' + this.epiphany + '\n');
|
|
|
|
output = output.concat('Firefox: ' + this.firefox + '\n');
|
|
|
|
output = output.concat('Internet Explorer: ' + this.ie + ' (' + this.ieVersion + ')\n');
|
|
|
|
output = output.concat('Mobile Safari: ' + this.mobileSafari + '\n');
|
|
|
|
output = output.concat('Midori: ' + this.midori + '\n');
|
|
|
|
output = output.concat('Opera: ' + this.opera + '\n');
|
|
|
|
output = output.concat('Safari: ' + this.safari + '\n');
|
|
|
|
|
|
|
|
output = output.concat('\n');
|
|
|
|
output = output.concat('Features\n');
|
|
|
|
output = output.concat('Canvas: ' + this.canvas + '\n');
|
|
|
|
output = output.concat('File: ' + this.file + '\n');
|
|
|
|
output = output.concat('FileSystem: ' + this.fileSystem + '\n');
|
|
|
|
output = output.concat('LocalStorage: ' + this.localStorage + '\n');
|
|
|
|
output = output.concat('WebGL: ' + this.webGL + '\n');
|
|
|
|
output = output.concat('Worker: ' + this.worker + '\n');
|
|
|
|
output = output.concat('Touch: ' + this.touch + '\n');
|
2013-05-16 01:36:58 +00:00
|
|
|
output = output.concat('MSPointer: ' + this.mspointer + '\n');
|
2013-04-18 13:16:18 +00:00
|
|
|
output = output.concat('CSS 3D: ' + this.css3D + '\n');
|
|
|
|
|
|
|
|
output = output.concat('\n');
|
|
|
|
output = output.concat('Audio\n');
|
|
|
|
output = output.concat('Audio Data: ' + this.canvas + '\n');
|
|
|
|
output = output.concat('Web Audio: ' + this.canvas + '\n');
|
|
|
|
output = output.concat('Can play OGG: ' + this.canvas + '\n');
|
|
|
|
output = output.concat('Can play MP3: ' + this.canvas + '\n');
|
|
|
|
output = output.concat('Can play M4A: ' + this.canvas + '\n');
|
|
|
|
output = output.concat('Can play WAV: ' + this.canvas + '\n');
|
|
|
|
|
|
|
|
return output;
|
2013-04-13 03:25:03 +00:00
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
}
|
2013-04-13 03:25:03 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
}
|