diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-08-05 01:21:38 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-08-05 01:21:38 -0400 |
| commit | 18f6f0219474f0f43e7403a5f5f8cff7c3dd0246 (patch) | |
| tree | 228fd343f36da554e540a70a0522eae489ad62fc /public/js/vendor/util.js | |
| parent | d0b4cd4f7e6364a35a420f2f3b0fcdbb502d8a9a (diff) | |
login view, lobby view
Diffstat (limited to 'public/js/vendor/util.js')
| -rw-r--r-- | public/js/vendor/util.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/public/js/vendor/util.js b/public/js/vendor/util.js index 0f5c6ed..7c73ae2 100644 --- a/public/js/vendor/util.js +++ b/public/js/vendor/util.js @@ -240,6 +240,41 @@ if (!Function.prototype.bind) { }; }()); +// Identify browser based on useragent string +(function( ua ) { + ua = ua.toLowerCase(); + var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || + /(webkit)[ \/]([\w.]+)/.exec( ua ) || + /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || + /(msie) ([\w.]+)/.exec( ua ) || + ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || + []; + var matched = { + browser: match[ 1 ] || "", + version: match[ 2 ] || "0" + }; + browser = {}; + if ( matched.browser ) { + browser[ matched.browser ] = true; + browser.version = matched.version; + } + // Chrome is Webkit, but Webkit is also Safari. + if ( browser.chrome ) { + browser.webkit = true; + } else if ( browser.webkit ) { + browser.safari = true; + } + if (window.$) $.browser = browser; + return browser; +})( navigator.userAgent ); + +// Naive useragent detection pattern +var is_iphone = (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) +var is_ipad = (navigator.userAgent.match(/iPad/i)) +var is_android = (navigator.userAgent.match(/Android/i)) +var is_mobile = is_iphone || is_ipad || is_android +var is_desktop = ! is_mobile; +var app_devicePixelRatio = is_mobile ? devicePixelRatio : 1; function selectElementContents(el) { if (window.getSelection && document.createRange) { |
