Skip to content

Commit a86ca6b

Browse files
committed
Let use JSRootCore.js in Web Workers
First step to allow usage of JSROOT in Workers
1 parent e913d9a commit a86ca6b

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

scripts/JSRootCore.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,18 @@
9393

9494
JSROOT.id_counter = 0;
9595

96-
JSROOT.touches = ('ontouchend' in document); // identify if touch events are supported
97-
98-
JSROOT.browser = {};
96+
JSROOT.touches = false;
97+
JSROOT.browser = { isOpera:false, isFirefox:true, isSafari: false, isChrome: false, isIE: false };
98+
99+
if ((typeof document !== "undefined") && (typeof window !== "undefined")) {
100+
JSROOT.touches = ('ontouchend' in document); // identify if touch events are supported
101+
JSROOT.browser.isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
102+
JSROOT.browser.isFirefox = typeof InstallTrigger !== 'undefined';
103+
JSROOT.browser.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
104+
JSROOT.browser.isChrome = !!window.chrome && !JSROOT.browser.isOpera;
105+
JSROOT.browser.isIE = false || !!document.documentMode;
106+
}
99107

100-
JSROOT.browser.isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
101-
JSROOT.browser.isFirefox = typeof InstallTrigger !== 'undefined';
102-
JSROOT.browser.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
103-
JSROOT.browser.isChrome = !!window.chrome && !JSROOT.browser.isOpera;
104-
JSROOT.browser.isIE = false || !!document.documentMode;
105108
JSROOT.browser.isWebKit = JSROOT.browser.isChrome || JSROOT.browser.isSafari;
106109

107110
// default draw styles, can be changed after loading of JSRootCore.js
@@ -1306,6 +1309,12 @@
13061309

13071310
JSROOT.Initialize = function() {
13081311

1312+
if (typeof document === "undefined") {
1313+
JSROOT.source_dir = "";
1314+
JSROOT.source_min = false;
1315+
return this;
1316+
}
1317+
13091318
function window_on_load(func) {
13101319
if (func!=null) {
13111320
if (document.attachEvent ? document.readyState === 'complete' : document.readyState !== 'loading')
@@ -1332,7 +1341,7 @@
13321341

13331342
JSROOT.console("Set JSROOT.source_dir to " + JSROOT.source_dir);
13341343

1335-
if (JSROOT.GetUrlOption('gui', src)!=null)
1344+
if (JSROOT.GetUrlOption('gui', src) !== null)
13361345
return window_on_load( function() { JSROOT.BuildSimpleGUI(); } );
13371346

13381347
if ( typeof define === "function" && define.amd )

0 commit comments

Comments
 (0)