]>
git.proxmox.com Git - mirror_novnc.git/blob - core/util/browser.js
2 * noVNC: HTML5 VNC client
3 * Copyright (C) 2012 Joel Martin
4 * Licensed under MPL 2.0 (see LICENSE.txt)
6 * See README.md for usage and integration instructions.
9 import * as Log
from './logging.js';
12 export var isTouchDevice
= ('ontouchstart' in document
.documentElement
) ||
13 // requried for Chrome debugger
14 (document
.ontouchstart
!== undefined) ||
15 // required for MS Surface
16 (navigator
.maxTouchPoints
> 0) ||
17 (navigator
.msMaxTouchPoints
> 0);
18 window
.addEventListener('touchstart', function onFirstTouch() {
20 window
.removeEventListener('touchstart', onFirstTouch
, false);
23 var _cursor_uris_supported
= null;
25 export function supportsCursorURIs () {
26 if (_cursor_uris_supported
=== null) {
28 var target
= document
.createElement('canvas');
29 target
.style
.cursor
= 'url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default';
31 if (target
.style
.cursor
) {
32 Log
.Info("Data URI scheme cursor supported");
33 _cursor_uris_supported
= true;
35 Log
.Warn("Data URI scheme cursor not supported");
36 _cursor_uris_supported
= false;
39 Log
.Error("Data URI scheme cursor test exception: " + exc
);
40 _cursor_uris_supported
= false;
44 return _cursor_uris_supported
;
47 export function isMac() {
48 return navigator
&& !!(/mac/i).exec(navigator
.platform
);
51 export function isIE() {
52 return navigator
&& !!(/trident/i).exec(navigator
.userAgent
);
55 export function isEdge() {
56 return navigator
&& !!(/edge/i).exec(navigator
.userAgent
);
59 export function isFirefox() {
60 return navigator
&& !!(/firefox/i).exec(navigator
.userAgent
);
63 export function isWindows() {
64 return navigator
&& !!(/win/i).exec(navigator
.platform
);
67 export function isIOS() {
69 (!!(/ipad/i).exec(navigator
.platform
) ||
70 !!(/iphone/i).exec(navigator
.platform
) ||
71 !!(/ipod/i).exec(navigator
.platform
));