34 var ViewerRoot = ViewerRoot || {};
41 ViewerRoot.launch =
function() {
43 Debug.log(
"ViewerRoot.launch");
45 document.getElementById(
"omni").innerHTML =
"<div id='omniHistogramViewer'></div>";
46 ViewerRoot.omni = document.getElementById(
"omniHistogramViewer");
49 var w = ViewerRoot.w = window.innerWidth;
50 var h = ViewerRoot.h = window.innerHeight;
52 ViewerRoot.omni.style.position =
"absolute";
53 ViewerRoot.omni.style.left = 0 +
"px";
54 ViewerRoot.omni.style.top = 0 +
"px";
55 ViewerRoot.omni.style.width = w +
"px";
56 ViewerRoot.omni.style.height = h +
"px";
57 ViewerRoot.omni.style.backgroundColor =
"rgb(30,30,30)";
59 ViewerRoot.omni.innerHTML =
"<center><div id='loaderStatus' style='margin-top:" + (h/2-8) +
"px'>Loading Root Viewer...</div></center>";
66 loadScript(source_dir+
'ViewerRootHud.js',
function(){
67 loadScript(source_dir+
'JsRoot/scripts/JSRootCore.js',
function(){
68 JSROOT.AssertPrerequisites(
'2d;io;3d;',ViewerRoot.init);
95 var source_dir =
"/WebPath/js/visualizers_lib/ViewerRoot_lib/";
104 ViewerRoot.STREAMER_INFO_FILE_PATH =
"/WebPath/js/visualizers_lib/ViewerRoot_lib/streamerInfo.root";
106 ViewerRoot.LOAD_STREAMER_INFO_CHECK_PERIOD = 100;
107 ViewerRoot.DISPLAY_MIN_WIDTH = 450;
108 ViewerRoot.DISPLAY_MIN_HEIGHT = 300;
109 ViewerRoot.HUD_WIDTH = 300;
110 ViewerRoot.HUD_MARGIN_RIGHT = 0;
111 ViewerRoot.HUD_DROP_DOWN_SPEED = 40;
112 ViewerRoot.ROOT_CONTAINER_OFFY = 20;
113 ViewerRoot.ROOT_HEADER_HEIGHT = 20;
115 ViewerRoot.TILE_MODE = 0;
116 ViewerRoot.REPLACE_MODE = 1;
117 ViewerRoot.SUPERIMPOSE_MODE = 2;
119 ViewerRoot.ADMIN_PERMISSIONS_THRESHOLD = 1;
120 ViewerRoot.userPermissions = 0;
123 ViewerRoot.rootContainer;
127 ViewerRoot.rootElArr;
128 ViewerRoot.rootPosArr;
129 ViewerRoot.rootObjArr;
130 ViewerRoot.rootObjIndexArr;
131 ViewerRoot.rootHeaderElArr;
132 ViewerRoot.rootObjNameArr;
133 ViewerRoot.rootIsTransparentArr;
134 ViewerRoot.rootIsAutoRefreshArr;
136 ViewerRoot.numPositionsTiled;
137 ViewerRoot.rootTargetIndex;
142 ViewerRoot.hudAutoHide =
false;
143 ViewerRoot.nextObjectMode = 1;
144 ViewerRoot.clearEachRequest =
true;
145 ViewerRoot.autoRefreshDefault =
false;
146 ViewerRoot.autoRefreshPeriod = 1000;
147 ViewerRoot.pauseRefresh =
false;
148 ViewerRoot.hardRefresh =
true;
150 ViewerRoot.autoRefreshTimer = 0;
153 ViewerRoot.iterLoading =
false;
154 ViewerRoot.iterNumberRemaining;
155 ViewerRoot.iterNumPositionsTiled;
156 ViewerRoot.iterRunWildcard;
157 ViewerRoot.iterRootObjNameArr;
158 ViewerRoot.iterRootPosArr;
159 ViewerRoot.iterRootIsTransparentArr;
160 ViewerRoot.iterRootIsAutoRefreshArr;
161 ViewerRoot.iterSaveNextObjectMode;
162 ViewerRoot.iterSaveAutoRefreshDefault;
189 ViewerRoot.init =
function()
191 Debug.log(
"ViewerRoot.init");
195 ViewerRoot.rootElArr = [];
196 ViewerRoot.rootPosArr = [];
197 ViewerRoot.rootObjArr = [];
198 ViewerRoot.rootObjIndexArr = [];
199 ViewerRoot.rootObjNameArr = [];
200 ViewerRoot.rootObjTitleArr = [];
201 ViewerRoot.rootHeaderElArr = [];
202 ViewerRoot.rootIsTransparentArr = [];
203 ViewerRoot.rootIsAutoRefreshArr = [];
205 ViewerRoot.numPositionsTiled = 0;
206 ViewerRoot.rootTargetIndex = -1;
208 obj_list =
new Array();
209 ViewerRoot.objIndex = 0;
211 function_list =
new Array();
212 func_list =
new Array();
217 ViewerRoot.rootContainer = document.createElement(
'div');
218 ViewerRoot.rootContainer.setAttribute(
"id",
"reportContainer");
219 ViewerRoot.rootContainer.onmouseup =
function(){
220 Debug.log(
"Deselect all root containers");
221 ViewerRoot.rootTargetIndex = -1;
222 ViewerRoot.resizeRootObjects();
224 ViewerRoot.omni.appendChild(ViewerRoot.rootContainer);
226 ViewerRoot.hud =
new ViewerRoot.createHud();
227 window.onresize = ViewerRoot.handleWindowResize;
228 ViewerRoot.handleWindowResize();
230 window.clearInterval(ViewerRoot.autoRefreshTimer);
231 ViewerRoot.autoRefreshTimer = window.setInterval(
232 ViewerRoot.autoRefreshTick,
233 ViewerRoot.autoRefreshPeriod);
235 document.getElementById(
"loaderStatus").innerHTML =
"Root Viewer Loaded.<br>Use drop-down to make selections.";
236 ViewerRoot.getDirectoryContents(
"/");
239 ViewerRoot.autoRefreshMatchArr = [];
248 ViewerRoot.autoRefreshTick =
function()
251 if(ViewerRoot.pauseRefresh)
return;
253 if(ViewerRoot.autoRefreshMatchArr.length)
255 Debug.log(
"ViewerRoot autoRefreshTick not done yet! Refresh period too short.");
256 ViewerRoot.autoRefreshPeriod += 500;
259 window.clearInterval(ViewerRoot.autoRefreshTimer);
260 ViewerRoot.autoRefreshTimer = window.setInterval(
261 ViewerRoot.autoRefreshTick,
262 ViewerRoot.autoRefreshPeriod);
266 ViewerRoot.autoRefreshMatchArr = [];
267 for(var j=0;j<ViewerRoot.rootPosArr.length;++j)
268 if(ViewerRoot.rootIsAutoRefreshArr[j])
270 Debug.log(
"ViewerRoot autoRefreshTick " + j +
" " + ViewerRoot.rootObjNameArr[j]);
271 ViewerRoot.autoRefreshMatchArr.push([j, ViewerRoot.rootObjNameArr[j]]);
272 ViewerRoot.rootReq(ViewerRoot.rootObjNameArr[j],j);
276 window.clearInterval(ViewerRoot.autoRefreshTimer);
277 ViewerRoot.autoRefreshTimer = window.setInterval(
278 ViewerRoot.autoRefreshTick,
279 ViewerRoot.autoRefreshPeriod);
289 ViewerRoot.prepareNextLocation =
function(objName, objTitle)
291 Debug.log(
"ViewerRoot prepareNextLocation for ViewerRoot.objIndex " +
"mode " + ViewerRoot.nextObjectMode +
292 ": " + ViewerRoot.objIndex +
": " + objName);
295 if(ViewerRoot.rootTargetIndex > ViewerRoot.numPositionsTiled) ViewerRoot.rootTargetIndex = -1;
298 var ri = ViewerRoot.rootElArr.length;
299 ViewerRoot.rootElArr.push(document.createElement(
'div'));
300 ViewerRoot.rootElArr[ri].setAttribute(
"class",
"rootObjectContainer");
302 var tmpdiv = document.createElement(
'div');
303 tmpdiv.setAttribute(
"id",
"histogram"+ViewerRoot.objIndex);
304 tmpdiv.setAttribute(
"class",
"rootObjectContainerTarget");
305 ViewerRoot.rootElArr[ri].appendChild(tmpdiv);
308 ViewerRoot.rootContainer.appendChild(ViewerRoot.rootElArr[ri]);
310 var drawTransparently =
false;
311 if(!ViewerRoot.numPositionsTiled || ViewerRoot.nextObjectMode == ViewerRoot.TILE_MODE)
314 ViewerRoot.rootPosArr.push(ViewerRoot.numPositionsTiled++);
316 else if(ViewerRoot.nextObjectMode == ViewerRoot.REPLACE_MODE)
319 var repi = ViewerRoot.rootTargetIndex == -1? ViewerRoot.numPositionsTiled-1:ViewerRoot.rootTargetIndex;
320 ViewerRoot.removeAllAtPosition(repi);
322 ViewerRoot.rootPosArr.push(repi);
324 else if(ViewerRoot.nextObjectMode == ViewerRoot.SUPERIMPOSE_MODE)
327 var supi = ViewerRoot.rootTargetIndex == -1? ViewerRoot.numPositionsTiled-1:ViewerRoot.rootTargetIndex;
329 ViewerRoot.rootPosArr.push(supi);
330 drawTransparently =
true;
333 ViewerRoot.rootIsTransparentArr.push(drawTransparently);
334 ViewerRoot.rootIsAutoRefreshArr.push(ViewerRoot.autoRefreshDefault);
335 ViewerRoot.rootObjNameArr.push(objName);
336 ViewerRoot.rootObjTitleArr.push(objTitle);
338 ViewerRoot.manageRootHeaders();
339 ViewerRoot.resizeRootObjects(
true);
348 ViewerRoot.removeAllAtPosition =
function(posi, isClosingPosition) {
349 Debug.log(
"ViewerRoot removeAllAtPosition " + posi);
351 for(var i=0;i<ViewerRoot.rootPosArr.length;++i)
352 if(ViewerRoot.rootPosArr[i] == posi)
354 ViewerRoot.rootElArr[i].parentNode.removeChild(ViewerRoot.rootElArr[i]);
355 ViewerRoot.rootElArr.splice(i,1);
356 ViewerRoot.rootPosArr.splice(i,1);
357 delete ViewerRoot.rootObjArr[i]; ViewerRoot.rootObjArr[i] = null;
358 ViewerRoot.rootObjArr.splice(i,1);
359 ViewerRoot.rootObjIndexArr.splice(i,1);
360 ViewerRoot.rootObjNameArr.splice(i,1);
361 ViewerRoot.rootObjTitleArr.splice(i,1);
362 ViewerRoot.rootIsTransparentArr.splice(i,1);
363 ViewerRoot.rootIsAutoRefreshArr.splice(i,1);
367 else if(isClosingPosition && ViewerRoot.rootPosArr[i] > posi)
368 --ViewerRoot.rootPosArr[i];
370 if(isClosingPosition)
372 --ViewerRoot.numPositionsTiled;
373 ViewerRoot.manageRootHeaders();
374 if(ViewerRoot.rootTargetIndex > posi) --ViewerRoot.rootTargetIndex;
375 else if(ViewerRoot.rootTargetIndex >= ViewerRoot.numPositionsTiled) ViewerRoot.rootTargetIndex = -1;
376 ViewerRoot.resizeRootObjects(
true);
383 ViewerRoot.manageRootHeaders =
function()
385 Debug.log(
"ViewerRoot manageRootHeaders");
388 while(ViewerRoot.numPositionsTiled > ViewerRoot.rootHeaderElArr.length)
390 tmpdiv = document.createElement(
'div');
391 tmpdiv.setAttribute(
"id",
"rootContainerHeader-"+ViewerRoot.rootHeaderElArr.length);
392 tmpdiv.setAttribute(
"class",
"rootContainerHeader");
393 tmpdiv.onmouseup = ViewerRoot.handleRootPositionSelect;
394 ViewerRoot.rootContainer.appendChild(tmpdiv);
395 ViewerRoot.rootHeaderElArr.push(tmpdiv);
398 while(ViewerRoot.numPositionsTiled < ViewerRoot.rootHeaderElArr.length)
400 tmpdiv = ViewerRoot.rootHeaderElArr[ViewerRoot.rootHeaderElArr.length-1];
401 tmpdiv.parentNode.removeChild(tmpdiv);
402 ViewerRoot.rootHeaderElArr.splice(ViewerRoot.rootHeaderElArr.length-1,1);
409 var isAtLeastOneRefreshing;
410 for(var i=0;i<ViewerRoot.rootHeaderElArr.length;++i)
413 isAtLeastOneRefreshing =
false;
414 for(var j=0;j<ViewerRoot.rootPosArr.length;++j)
415 if(ViewerRoot.rootPosArr[j] == i) { ++found; fullPath = ViewerRoot.rootObjNameArr[j];
417 name=ViewerRoot.rootObjTitleArr[j];
418 if(ViewerRoot.rootIsAutoRefreshArr[j]) isAtLeastOneRefreshing =
true;
424 str +=
"<div title='" + fullPath +
"' class='rootContainerHeader-name'>" + (found == 1?name:
"Multiple Files...") +
"</div>";
427 str +=
"<a title='Close' href='Javascript:ViewerRoot.removeAllAtPosition("+i+
",true);' onmouseup='event.cancelBubble=true;' " +
428 "class='rootContainerHeader-closeBtn'>X</a>";
434 str +=
"<a title='Close' href='Javascript:ViewerRoot.toggleAllAtPositionAutoRefresh(" + i +
435 ");' onmouseup='event.cancelBubble=true;' " +
436 "class='rootContainerHeader-refreshBtn'><img id='rootContainerHeaderRefreshImg" + i +
437 "'src='/WebPath/images/iconImages/icon-rootAutoRefresh" + (isAtLeastOneRefreshing?
"On":
"Off") +
".png'></a>";
446 ViewerRoot.rootHeaderElArr[i].innerHTML = str;
456 ViewerRoot.toggleAllAtPositionAutoRefresh =
function(i)
458 Debug.log(
"ViewerRoot toggleAllAtPositionAutoRefresh " + i);
464 for(var j=0;j<ViewerRoot.rootPosArr.length;++j)
465 if(ViewerRoot.rootPosArr[j] == i)
467 if(!doover && ViewerRoot.rootIsAutoRefreshArr[j]) v =
false;
468 ViewerRoot.rootIsAutoRefreshArr[j] = v;
470 Debug.log(
"ViewerRoot toggleAllAtPositionAutoRefresh rootObj " + j +
" to " + v);
472 var tmp = document.getElementById(
"rootContainerHeaderRefreshImg" + i );
473 tmp.src =
"/WebPath/images/iconImages/icon-rootAutoRefresh" + (v?
"On":
"Off") +
".png";
474 if(lastv != v ){++found; lastv = v;}
476 if(!doover && found>1) doover =
true;
484 ViewerRoot.handleRootPositionSelect =
function(event)
486 event.cancelBubble =
true;
487 var i = parseInt(this.
id.substr(this.
id.indexOf(
"-")+1))
488 Debug.log("ViewerRoot handleRootPositionSelect " + i);
489 ViewerRoot.rootTargetIndex = i;
490 ViewerRoot.resizeRootObjects();
496 ViewerRoot.clearAll = function()
498 Debug.log(
"ViewerRoot clearAll");
500 ViewerRoot.rootTargetIndex = -1;
502 for(ViewerRoot.numPositionsTiled; ViewerRoot.numPositionsTiled>0; --ViewerRoot.numPositionsTiled)
503 ViewerRoot.removeAllAtPosition(ViewerRoot.numPositionsTiled-1);
504 ViewerRoot.manageRootHeaders();
505 ViewerRoot.resizeRootObjects();
510 ViewerRoot.handleWindowResize =
function() {
512 var w = ViewerRoot.w = window.innerWidth < ViewerRoot.DISPLAY_MIN_WIDTH? ViewerRoot.DISPLAY_MIN_WIDTH:window.innerWidth;
513 var h = ViewerRoot.h = window.innerHeight < ViewerRoot.DISPLAY_MIN_HEIGHT? ViewerRoot.DISPLAY_MIN_HEIGHT:window.innerHeight;
515 if(!ViewerRoot.hudAutoHide)
516 ViewerRoot.w = w -= ViewerRoot.HUD_WIDTH + ViewerRoot.HUD_MARGIN_RIGHT + (5*2);
518 Debug.log(
"ViewerRoot handleWindowResize " + w +
"-" + h);
520 ViewerRoot.omni.style.width = w +
"px";
521 ViewerRoot.omni.style.height = h +
"px";
523 ViewerRoot.hud.handleWindowResize();
524 ViewerRoot.resizeRootObjects(
true);
534 ViewerRoot.resizeRootObjects =
function(needToRedraw) {
536 ViewerRoot.rootContainer.style.width = ViewerRoot.w +
"px";
537 ViewerRoot.rootContainer.style.height = ViewerRoot.h +
"px";
539 if(ViewerRoot.numPositionsTiled < 1)
541 ViewerRoot.rootContainer.style.backgroundColor =
"rgba(0,0,0,0)";
544 ViewerRoot.rootContainer.style.backgroundColor =
"white";
547 var w = ViewerRoot.w;
548 var h = ViewerRoot.h - ViewerRoot.ROOT_CONTAINER_OFFY;
551 var r = Math.round(Math.sqrt(h*ViewerRoot.numPositionsTiled/aspect/w));
553 var c = Math.ceil(ViewerRoot.numPositionsTiled/r);
555 Debug.log(
"ViewerRoot resizeRootObjects " + r +
"-" + c +
" for " + ViewerRoot.numPositionsTiled);
561 Debug.log(
"ViewerRoot resizeRootObjects size " + w +
"-" + h );
564 var rootAspect = 3/4;
565 var rootw = h/w < rootAspect?h/rootAspect:w;
568 for(var i=0;i<ViewerRoot.rootElArr.length;++i)
570 ViewerRoot.rootElArr[i].style.width = rootw +
"px";
571 ViewerRoot.rootElArr[i].style.height = (h - ViewerRoot.ROOT_HEADER_HEIGHT) +
"px";
572 ViewerRoot.rootElArr[i].style.left = w*(ViewerRoot.rootPosArr[i]%c) + (w-rootw)/2 +
"px";
573 ViewerRoot.rootElArr[i].style.top = ViewerRoot.ROOT_CONTAINER_OFFY + ViewerRoot.ROOT_HEADER_HEIGHT +
574 h*Math.floor(ViewerRoot.rootPosArr[i]/c) +
"px";
579 if(needToRedraw && ViewerRoot.rootObjArr[i])
586 JSROOT.redraw(
'histogram'+
587 ViewerRoot.rootObjIndexArr[i],
588 ViewerRoot.rootObjArr[i],
"colz");
592 Debug.log(
"ROOT Object type '" + ViewerRoot.rootObjArr[i]._typename +
593 "' failed to draw: " + e);
594 document.getElementById(
"histogram" +
595 ViewerRoot.rootObjIndexArr[i],).textContent =
596 ViewerRoot.rootObjArr[i].JSON;
599 ViewerRoot.refreshTransparency(i);
604 for(var i=0;i<ViewerRoot.rootHeaderElArr.length;++i)
606 ViewerRoot.rootHeaderElArr[i].style.width = w-2 +
"px";
607 ViewerRoot.rootHeaderElArr[i].style.height = ViewerRoot.ROOT_HEADER_HEIGHT +
"px";
608 ViewerRoot.rootHeaderElArr[i].style.left = w*(i%c) +
"px";
609 ViewerRoot.rootHeaderElArr[i].style.top = ViewerRoot.ROOT_CONTAINER_OFFY + h*Math.floor(i/c) +
"px";
611 ViewerRoot.rootHeaderElArr[i].style.borderColor =
612 ViewerRoot.rootTargetIndex==i?
'rgb(68,156,44)':
'black';
613 ViewerRoot.rootHeaderElArr[i].style.backgroundColor =
614 ViewerRoot.rootTargetIndex==i?
'rgb(178,222,166)':
'rgba(0,0,0,0)';
621 ViewerRoot.refreshTransparency =
function(i) {
623 if(ViewerRoot.rootIsTransparentArr[i])
627 ViewerRoot.rootElArr[i].children[0].style.backgroundColor =
"rgba(0,0,0,0)";
629 var svg = ViewerRoot.rootElArr[i].children[0].getElementsByTagName(
'svg')[0];
630 svg.style.backgroundColor =
"rgba(0,0,0,0)";
632 if(svg.getElementsByTagName(
'rect')[0])
633 svg.getElementsByTagName(
'rect')[0].style.fill =
"rgba(0,0,0,0)";
648 ViewerRoot.checkStreamerInfoLoaded =
function() {
649 if(ViewerRoot.sFile &&
650 ViewerRoot.sFile.fStreamerInfo &&
651 gFile.fStreamerInfo.fClassMap &&
652 gFile.fStreamerInfo.fClassMap.length > 0)
654 document.getElementById(
"loaderStatus").innerHTML =
"Root Viewer Loaded.<br>Use drop-down to make selections.";
655 ViewerRoot.getDirectoryContents(
"/");
658 window.setTimeout(ViewerRoot.checkStreamerInfoLoaded,ViewerRoot.LOAD_STREAMER_INFO_CHECK_PERIOD);
664 ViewerRoot.getDirectoryContents =
function(path) {
666 Debug.log(
"ViewerRoot getDirectoryContents " + path);
668 if(path.indexOf(
".root/") >=0)
669 DesktopContent.XMLHttpRequest(
"Request?RequestType=getRoot",
"RootPath="+path, ViewerRoot.getDirContentsHandler,
675 DesktopContent.XMLHttpRequest(
"Request?RequestType=getDirectoryContents",
"Path="+path, ViewerRoot.getDirContentsHandler,
684 ViewerRoot.getDirContentsHandler =
function(req) {
685 Debug.log(
"ViewerRoot getDirContentsHandler " + req.responseText);
687 var permissions = DesktopContent.getXMLValue(req,
'permissions');
689 Debug.log(
"ViewerRoot getDirContentsHandler permissions missing");
690 else if(ViewerRoot.userPermissions != permissions)
692 Debug.log(
"ViewerRoot getDirContentsHandler user permissions = " + permissions);
693 ViewerRoot.userPermissions = permissions;
694 ViewerRoot.hud.handleWindowResize();
697 ViewerRoot.hud.handleDirContents(req);
703 ViewerRoot.rootReq =
function(rootPath,refreshIndex) {
705 if(refreshIndex === undefined) refreshIndex = -1;
707 Debug.log(
"ViewerRoot.rootReq " + rootPath );
708 DesktopContent.XMLHttpRequest(
"Request?RequestType=getRoot",
709 "RootPath="+rootPath,
710 ViewerRoot.getRootDataHandler,
714 refreshIndex<0?
false:
true );
719 ViewerRoot.rootConfigReq =
function(rootConfigPath)
722 DesktopContent.XMLHttpRequest(
"Request?RequestType=getRootConfig",
723 "RootConfigPath="+rootConfigPath,
724 ViewerRoot.getRootConfigHandler,
734 ViewerRoot.getRootConfigHandler =
function(req)
736 Debug.log(
"ViewerRoot getRootConfigHandler " + req.responseText );
738 var status = DesktopContent.getXMLValue(req,
"status");
740 { alert(
"Loading Root Pre-Made Configuration Failed: " + status);
return }
742 ViewerRoot.iterNumPositionsTiled = DesktopContent.getXMLValue(req,
"numPositionsTiled");
743 ViewerRoot.iterRunWildcard = DesktopContent.getXMLValue(req,
"runNumWildcard");
747 var tmp = req.responseXML.getElementsByTagName(
"rootObjName");
748 ViewerRoot.iterRootObjNameArr = [];
749 for(var i=0;i<tmp.length;++i) ViewerRoot.iterRootObjNameArr[i] = tmp[i].getAttribute(
"value");
751 tmp = req.responseXML.getElementsByTagName(
"rootPos");
752 ViewerRoot.iterRootPosArr = [];
753 for(var i=0;i<tmp.length;++i) ViewerRoot.iterRootPosArr[i] = tmp[i].getAttribute(
"value") | 0;
755 tmp = req.responseXML.getElementsByTagName(
"rootIsTransparent");
756 ViewerRoot.iterRootIsTransparentArr = [];
757 for(var i=0;i<tmp.length;++i) ViewerRoot.iterRootIsTransparentArr[i] = tmp[i].getAttribute(
"value") | 0;
759 tmp = req.responseXML.getElementsByTagName(
"rootIsAutoRefresh");
760 ViewerRoot.iterRootIsAutoRefreshArr = [];
761 for(var i=0;i<tmp.length;++i) ViewerRoot.iterRootIsAutoRefreshArr[i] = tmp[i].getAttribute(
"value") | 0;
763 ViewerRoot.clearAll();
765 ViewerRoot.iterLoading =
true;
766 ViewerRoot.iterNumberRemaining = ViewerRoot.iterRootObjNameArr.length;
767 ViewerRoot.iterSaveNextObjectMode = ViewerRoot.nextObjectMode;
768 ViewerRoot.iterSaveAutoRefreshDefault = ViewerRoot.autoRefreshDefault;
770 ViewerRoot.iterativeConfigLoader();
776 ViewerRoot.iterativeConfigLoader =
function() {
778 if(!ViewerRoot.iterNumberRemaining)
780 ViewerRoot.autoRefreshDefault = ViewerRoot.iterSaveAutoRefreshDefault;
781 ViewerRoot.nextObjectMode = ViewerRoot.iterSaveNextObjectMode;
782 ViewerRoot.iterLoading =
false;
786 --ViewerRoot.iterNumberRemaining;
790 for(var i=0;i<ViewerRoot.iterRootPosArr.length;++i)
791 if(min == -1 || ViewerRoot.iterRootPosArr[i] < ViewerRoot.iterRootPosArr[min]) min = i;
793 ViewerRoot.nextObjectMode = ViewerRoot.iterRootIsTransparentArr[min]?ViewerRoot.SUPERIMPOSE_MODE:ViewerRoot.TILE_MODE;
794 ViewerRoot.autoRefreshDefault = ViewerRoot.iterRootIsAutoRefreshArr[min];
796 ViewerRoot.rootReq(ViewerRoot.iterRootObjNameArr[min]);
799 ViewerRoot.iterRootObjNameArr.splice(min,1);
800 ViewerRoot.iterRootPosArr.splice(min,1);
801 ViewerRoot.iterRootIsTransparentArr.splice(min,1);
802 ViewerRoot.iterRootIsAutoRefreshArr.splice(min,1);
810 ViewerRoot.getRootDataHandler =
function(req, refreshIndex)
815 var rootType = DesktopContent.getXMLValue(req,
"rootType");
816 var rootStr = DesktopContent.getXMLValue(req,
"rootData");
817 var rootName = DesktopContent.getXMLValue(req,
"path");
821 var rootJSON = DesktopContent.getXMLValue(req,
"rootJSON");
825 var
object = JSROOT.parse(rootJSON);
827 if(!
object || !rootType || !rootName)
829 Debug.log(
"Pausing auto-refresh! \n\nPlease resolve the errors before resuming refreshes.", Debug.HIGH_PRIORITY);
831 var chk = document.getElementById(
"hudCheckbox" + 2);
833 ViewerRoot.pauseRefresh =
true;
835 Debug.log(
"Error reading Root object from server - Name: " + rootName, Debug.HIGH_PRIORITY);
836 ViewerRoot.autoRefreshMatchArr = [];
840 var rootTitle =
object.fTitle;
841 object.JSON = rootJSON;
843 if(refreshIndex === undefined) refreshIndex = -1;
845 if(ViewerRoot.autoRefreshMatchArr.length &&
848 for(var i=0;i<ViewerRoot.autoRefreshMatchArr.length;++i)
850 if(refreshIndex == ViewerRoot.autoRefreshMatchArr[i][0])
852 Debug.log(
"ViewerRoot handling refresh " +
853 refreshIndex +
" " + rootName);
856 ViewerRoot.autoRefreshMatchArr[i] = 0;
857 ViewerRoot.autoRefreshMatchArr.splice(i,1);
861 if(refreshIndex >= ViewerRoot.rootObjNameArr.length ||
862 ViewerRoot.rootObjNameArr[refreshIndex] != rootName)
864 Debug.log(
"ViewerRoot getRootDataHandler weird unmatch!?#$@%");
868 if(ViewerRoot.autoRefreshMatchArr.length == 0)
871 window.clearInterval(ViewerRoot.autoRefreshTimer);
872 ViewerRoot.autoRefreshTimer = window.setInterval(
873 ViewerRoot.autoRefreshTick,
874 ViewerRoot.autoRefreshPeriod);
883 console.log(
"refreshIndex=" + refreshIndex +
884 " ViewerRoot.rootTargetIndex=" + ViewerRoot.rootTargetIndex);
886 if(refreshIndex < 0) ViewerRoot.prepareNextLocation(rootName, rootTitle);
926 ViewerRoot.interpretObjectJSON(
object,rootType,rootName,refreshIndex);
927 if(ViewerRoot.iterLoading) ViewerRoot.iterativeConfigLoader();
934 ViewerRoot.interpretObjectJSON =
function(object,rootType,objName,refreshIndex)
937 if(refreshIndex == undefined) refreshIndex = -1;
940 if(ViewerRoot.hardRefresh)
944 ViewerRoot.rootObjArr.push(
object);
945 ViewerRoot.rootObjIndexArr.push(ViewerRoot.objIndex);
949 delete ViewerRoot.rootObjArr[refreshIndex]; ViewerRoot.rootObjArr[refreshIndex] = null;
950 ViewerRoot.rootObjArr[refreshIndex] = object;
951 ViewerRoot.rootObjTitleArr[refreshIndex] =
object.fTitle;
952 ViewerRoot.rootObjIndexArr[refreshIndex] = ViewerRoot.objIndex;
955 ViewerRoot.rootElArr[refreshIndex].innerHTML =
"";
956 var tmpdiv = document.createElement(
'div');
957 tmpdiv.setAttribute(
"id",
"histogram"+ViewerRoot.objIndex);
958 tmpdiv.setAttribute(
"class",
"rootObjectContainerTarget");
959 ViewerRoot.rootElArr[refreshIndex].appendChild(tmpdiv);
963 var targetEl = document.getElementById(
"histogram" + ViewerRoot.objIndex);
967 if(rootType ==
"JSON")
968 throw "Doing JSON only";
970 var isFirstTime = targetEl.innerHTML ==
"";
971 JSROOT.redraw(
'histogram'+
972 (ViewerRoot.objIndex),
977 if(targetEl.innerHTML ==
"")
979 Debug.log(
"Empty first time handling!");
982 function localMakeAsyncCheckerFunction(obji, type, obj)
984 Debug.log(
"Async Empty first time handling for histogram" +
985 obji +
" type=" + type);
989 Debug.log(
"Async Empty first time handling for histogram" +
991 if(targetEl.innerHTML !=
"")
993 Debug.log(
"histogram" +
994 obji +
" is OK, must have just taken a while");
1000 JSROOT.redraw(
"histogram" +
1006 Debug.log(
"ROOT Object type '" + type +
1007 "' failed to draw histogram" +
1009 targetEl.textContent = obj.JSON;
1014 window.setTimeout(localMakeAsyncCheckerFunction(
1015 ViewerRoot.objIndex,
1025 Debug.log(
"ROOT Object type '" +
object._typename +
1026 "' failed to draw: " + e);
1027 targetEl.textContent =
object.JSON;
1030 ViewerRoot.objIndex++;
1037 JSROOT.redraw(
'histogram'+
1038 (refreshIndex<0?ViewerRoot.objIndex:
1039 ViewerRoot.rootObjIndexArr[refreshIndex]),
1044 Debug.log(
"ROOT Object type '" +
object._typename +
1045 "' failed to draw: " + e, Debug.HIGH_PRIORITY);
1048 if(refreshIndex < 0)
1050 ViewerRoot.rootObjArr.push(
object);
1051 ViewerRoot.rootObjIndexArr.push(ViewerRoot.objIndex);
1052 ViewerRoot.objIndex++;
1056 delete ViewerRoot.rootObjArr[refreshIndex]; ViewerRoot.rootObjArr[refreshIndex] = null;
1057 ViewerRoot.rootObjArr[refreshIndex] = object;
1058 ViewerRoot.rootObjTitleArr[refreshIndex] =
object.fTitle;
1062 ViewerRoot.refreshTransparency(refreshIndex<0?(ViewerRoot.rootObjArr.length-1):refreshIndex);
1063 ViewerRoot.manageRootHeaders();
1068 function loadScript(url, callback)
1072 var script = document.createElement(
"script")
1073 script.type =
"text/javascript";
1074 if (script.readyState) {
1075 script.onreadystatechange =
function() {
1076 if (script.readyState ==
"loaded" ||
1077 script.readyState ==
"complete") {
1078 script.onreadystatechange = null;
1083 script.onload =
function(){
1087 var rnd = Math.floor(Math.random()*80000);
1089 document.getElementsByTagName(
"head")[0].appendChild(script);