]>
git.proxmox.com Git - mirror_novnc.git/blob - core/util/browser.js
2 * noVNC: HTML5 VNC client
3 * Copyright (C) 2018 The noVNC Authors
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 let 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);
24 // The goal is to find a certain physical width, the devicePixelRatio
25 // brings us a bit closer but is not optimal.
26 export let dragThreshold
= 10 * (window
.devicePixelRatio
|| 1);
28 let _cursor_uris_supported
= null;
30 export function supportsCursorURIs() {
31 if (_cursor_uris_supported
=== null) {
33 const target
= document
.createElement('canvas');
34 target
.style
.cursor
= 'url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default';
36 if (target
.style
.cursor
) {
37 Log
.Info("Data URI scheme cursor supported");
38 _cursor_uris_supported
= true;
40 Log
.Warn("Data URI scheme cursor not supported");
41 _cursor_uris_supported
= false;
44 Log
.Error("Data URI scheme cursor test exception: " + exc
);
45 _cursor_uris_supported
= false;
49 return _cursor_uris_supported
;
52 export function isMac() {
53 return navigator
&& !!(/mac/i).exec(navigator
.platform
);
56 export function isIE() {
57 return navigator
&& !!(/trident/i).exec(navigator
.userAgent
);
60 export function isEdge() {
61 return navigator
&& !!(/edge/i).exec(navigator
.userAgent
);
64 export function isFirefox() {
65 return navigator
&& !!(/firefox/i).exec(navigator
.userAgent
);
68 export function isWindows() {
69 return navigator
&& !!(/win/i).exec(navigator
.platform
);
72 export function isIOS() {
74 (!!(/ipad/i).exec(navigator
.platform
) ||
75 !!(/iphone/i).exec(navigator
.platform
) ||
76 !!(/ipod/i).exec(navigator
.platform
));