32 'Ext.layout.container.Border'
38 var getLocalURN =
function(index,name)
40 var params = (window.location.search.substr(1)).split(
'&');
44 for(index=0;index<params.length;++index)
46 splitted = params[index].indexOf(
'=');
47 if(splitted < 0)
continue;
48 vs = [params[index].substr(0,splitted),params[index].substr(splitted+1)];
49 if(decodeURIComponent(vs[0]) == name)
return decodeURIComponent(vs[1]);
54 if(index >= params.length)
return;
56 splitted = params[index].indexOf(
'=');
57 if(splitted < 0)
return;
58 vs = [params[index].substr(0,splitted),params[index].substr(splitted+1)];
59 return decodeURIComponent(vs[1]);
64 function generateDIVPlaceholder(
id,top,left)
66 var div = document.createElement(
"div");
68 div.style.position =
"absolute";
69 div.style.top = top +
"px";
70 div.style.left = left +
"px";
72 document.getElementsByTagName(
"BODY")[0].appendChild(div);
75 function generateDIVPlaceholderUnder(
id,idUnder,top,left,width,height)
77 var div = document.createElement(
"div");
79 div.style.position =
"absolute";
80 div.style.top = top +
"px";
81 div.style.left = left +
"px";
82 div.style.width = width +
"px";
83 div.style.height = height +
"px";
85 document.getElementById(idUnder).appendChild(div);
90 function repositionDiv(
id,top,left)
92 var div = document.getElementById(
id);
93 if( top !=
"" ) div.style.top = top +
"px";
94 if( left !=
"" ) div.style.left = left +
"px";
97 Ext.onReady(
function()
99 function xmlKeysPrintout(fromWhere)
101 const e =
new Error();
102 const a = e.stack.split(
"\n")[1] ;
103 const w = a.split(
"/") ;
104 const s = w.length -1 ;
105 const l = w[s].split(
":")[1] ;
106 STDLINE(
"----------- Line: " + l +
"-----------") ;
107 STDLINE(
"From: '"+fromWhere+
"'" ) ;
108 STDLINE(
" --> fSystemPath_ : "+fSystemPath_ ) ;
109 STDLINE(
" --> fRootPath_ : "+fRootPath_ ) ;
110 STDLINE(
" --> fFoldersPath_ : "+fFoldersPath_ ) ;
111 STDLINE(
" --> fFileName_ : "+fFileName_ ) ;
112 STDLINE(
" --> fRFoldersPath_: "+fRFoldersPath_) ;
113 STDLINE(
" --> fHistName_ : "+fHistName_ ) ;
114 STDLINE(
"--------------------------------------") ;
117 var currentDirectory_ =
"" ;
118 var currentRootObject_ =
"" ;
119 var currentTree_ =
"" ;
121 var selectedItem_ =
"getDirectories"; ;
123 var theCanvas_ =
"" ;
124 var fSystemPath_ =
"" ;
125 var fRootPath_ =
"" ;
126 var fFoldersPath_ =
"" ;
127 var fFileName_ =
"" ;
128 var fRFoldersPath_ =
"" ;
129 var fHistName_ =
"" ;
130 var fRFoldersPath =
"" ;
131 var theSources_ =
"" ;
132 var theControls_ =
"" ;
133 var thetheSourcesCB__ =
"" ;
134 var dataModel_ =
"" ;
135 var displayPlot_ =
"" ;
136 var periodicPlotID_ =
"" ;
138 var treeDisplayField_ =
"fDisplayName" ;
139 var doReset_ = true ;
140 var _cookieCodeMailbox = 0;
142 var _theWindow = self ;
145 var _requestURL =
self.parent.window.location.origin +
146 "/urn:xdaq-application:lid=" +
147 getLocalURN(0,
"urn") +
149 var viewportW = window.innerWidth ;
150 var viewportH = window.innerHeight ;
153 var bottomMargin_ = 5 ;
154 var decorationH = 0 ;
159 var navigatorT = topMargin_ ;
161 var navigatorW = 200 ;
162 var navigatorH = viewportH - (topMargin_ + bottomMargin_) - decorationH ;
163 var controlsT = 460 ;
164 var controlsL = navigatorW + 5 ;
165 var controlsW = viewportW - navigatorW - 20 ;
167 var canvasT = navigatorT ;
168 var canvasL = navigatorW + 5 ;
169 var canvasW = viewportW - navigatorW - 20 ;
170 var canvasH = viewportH - (topMargin_ + bottomMargin_) - decorationH - controlsH ;
173 generateDIVPlaceholder (
"sourceDiv" , 0 , 0 ) ;
174 generateDIVPlaceholder (
"navigatorDiv" , navigatorT, navigatorL ) ;
175 generateDIVPlaceholder (
"histogramDiv" , topMargin_, navigatorW + 5 ) ;
176 generateDIVPlaceholderUnder(
"histogram1" ,
"histogramDiv", 0 , 0 , 400, 400) ;
177 generateDIVPlaceholder (
"controlsDiv" , controlsT , controlsL ) ;
180 function STDLINE(str)
182 const e =
new Error() ;
183 const a = e.stack.split(
"\n")[1] ;
184 const w = a.split(
"/") ;
185 const s = w.length -1 ;
186 const l = w[s].split(
":")[1] ;
187 const n = w[s].split(
":")[0] ;
188 const m = l+
"] ["+n+
"] "+str ;
192 getXMLValue =
function(req, name)
194 if(!name)
return req.getAttribute(
"value");
195 return getXMLAttributeValue(req,name,
"value");
199 getXMLAttributeValue =
function(req, name, attribute)
202 if(el = getXMLNode(req,name))
return el.getAttribute(attribute);
203 else if((name ==
"Error" )&& (!req || !req.responseXML))
204 return "Unknown error occured " +
205 "(XML response may have been illegal)!";
211 getXMLNode =
function(req, name)
214 if(req && req.responseXML)
215 req = req.responseXML;
219 els = req.getElementsByTagName(name);
220 if(els.length)
return els[0];
227 getXMLNodes =
function(req, name)
230 if(req && req.responseXML)
231 req = req.responseXML;
234 return req.getElementsByTagName(name);
241 dataModel_ = Ext.define(
242 'DirectoriesDataModel',
244 extend:
'Ext.data.Model',
246 {name:
'nChilds' , type:
'int' , convert: null},
247 {name:
'fSystemPath' , type:
'string', convert: null},
248 {name:
'fRootPath' , type:
'string', convert: null},
249 {name:
'fFoldersPath' , type:
'string', convert: null},
250 {name:
'fFileName' , type:
'string', convert: null},
251 {name:
'fHistName' , type:
'string', convert: null},
252 {name:
'fRFoldersPath', type:
'string', convert: null},
253 {name:
'fDisplayName' , type:
'string', convert: null}
259 theCanvas_ = Ext.create(
262 renderTo :
'histogramDiv',
268 styleHtmlContent:
true
272 style :
'background-color: #5E99CC' ,
284 function createSources(dirs)
286 theSources_ = Ext.create (
289 fields: [
'abbr',
'dir'],
293 theSourcesCB_ = Ext.create(
297 fieldLabel :
'Source:' ,
302 queryMode :
'local' ,
303 displayField:
'dir' ,
304 valueField :
'abbr' ,
305 renderTo :
'sourceDiv',
307 select :
function(thisCombo, record, eOpts)
309 fRootPath_ = record.data.dir ;
310 STDLINE(
"fRootPath_: "+fRootPath_) ;
311 makeStore(fRootPath_,
'RequestType=getMeDirs') ;
312 makeGrid (fRootPath_,
'Directories and files') ;
314 focusleave:
function (thisCombo)
316 STDLINE(
'remove selection listener') ;
317 thisCombo.suspendEvent(
'select') ;
318 STDLINE(
'removed selection listener') ;
320 focusenter:
function (thisCombo)
322 STDLINE(
'reinstate selection listener') ;
323 thisCombo.resumeEvent(
'select') ;
324 STDLINE(
'reinstated selection listener') ;
328 ).setPosition(sourceT,sourceL);
329 theSourcesCB_.setRawValue(dirs[0].dir) ;
333 var resetCanvasB = Ext.create (
336 cls :
'controlButtons',
338 renderTo:
'controlsDiv' ,
347 JSROOT.cleanup(
'histogram1');
348 mdi_ =
new JSROOT.GridDisplay(
'histogram1',
'');
352 var clearCanvasB = Ext.create (
356 renderTo:
'controlsDiv' ,
367 clearInterval(periodicPlotID_) ;
368 JSROOT.cleanup(
'histogram1');
369 mdi_ =
new JSROOT.GridDisplay(
'histogram1',
'');
373 var freezeCanvasB = Ext.create(
377 renderTo:
'controlsDiv' ,
386 clearInterval(periodicPlotID_) ;
390 timeoutInterval = Ext.create (
391 'Ext.form.field.Number',
395 fieldLabel :
'Refresh interval',
403 theControls_ = Ext.create (
406 title :
'Canvas controls' ,
409 renderTo :
'controlsDiv' ,
420 function makeGrid(where,what)
422 if( grid_ ) grid_.destroy() ;
423 theStore_.sort(treeDisplayField_,
'ASC');
425 mdi_ =
new JSROOT.GridDisplay(
'histogram1',
'');
436 renderTo :
"navigatorDiv",
440 height : navigatorH ,
450 borderColor:
'blue' ,
459 if( currentTree_ =
'fileContent' )
461 selectedItem_ =
"getDirectories" ;
462 makeStore(fRootPath_,
'RequestType=getMeDirs') ;
463 makeGrid (fRootPath_,
'Directories and files') ;
471 xtype :
'treecolumn' ,
475 dataIndex:
'fDisplayName'
478 xtype :
'treecolumn' ,
485 xtype :
'treecolumn' ,
487 text :
'fSystemPath' ,
489 dataIndex:
'fSystemPath'
492 xtype :
'treecolumn' ,
496 dataIndex:
'fRootPath'
499 xtype :
'treecolumn' ,
501 text :
'fFoldersPath',
503 dataIndex:
'fFoldersPath'
506 xtype :
'treecolumn' ,
510 dataIndex:
'fFileName'
513 xtype :
'treecolumn' ,
517 dataIndex:
'fHistName'
521 expand :
function(expandedItem, options)
523 STDLINE(
"expanded") ;
525 itemclick :
function(thisItem, record, item, index, e, eOpts)
527 var selection = this.getSelection() ;
528 STDLINE(
"Selected "+selection.length+
" items") ;
529 for(var i=0; i<selection.length; i++)
531 fSystemPath_ = selection[i].data.fSystemPath ;
532 fFoldersPath_ = selection[i].data.fFoldersPath ;
533 fRootPath_ = selection[i].data.fRootPath ;
534 fHistName_ = selection[i].data.fHistName ;
535 fFileName_ = selection[i].data.fFileName ;
536 if( typeof fFoldersPath_ ===
"undefined" ) fFoldersPath_ =
"" ;
537 xmlKeysPrintout(
"Clicked on a tree item")
539 STDLINE(
"Selected "+selection.length+
" items") ;
541 var itemSplit = item.innerText.split(
"\n\t\n") ;
542 var isLeaf = itemSplit[1].replace(
"\n",
"").replace(
"\t",
"") ;
543 if( isLeaf ==
"true" )
545 if( selectedItem_ ==
"getDirectories" )
547 treeDisplayField_ =
'fDisplayName' ;
548 selectedItem_ =
"getRootObject" ;
549 currentTree_ =
'fileContent' ;
550 currentDirectory_ = fSystemPath_ +
557 STDLINE(
'RequestType : getMeRootFile' ) ;
558 xmlKeysPrintout(
"Getting directories in particular")
559 STDLINE('currentDirectory_: '+currentDirectory_) ;
560 makeStore(currentDirectory_,'RequestType=getMeRootFile');
561 makeGrid (currentDirectory_,'ROOT file content' );
563 else if( selectedItem_ == "getRootObject" )
565 xmlKeysPrintout(
"Getting the content of a root file in particular (getRootObject)")
566 currentRootObject_ = "/" +
573 STDLINE('RequestType : getRootObject' ) ;
574 STDLINE('currentRootObject_: '+currentRootObject_) ;
576 _requestURL+"RequestType=getRoot",
578 CookieCode: _cookieCode,
579 RootPath : currentRootObject_
583 var tOut = Math.round(timeoutInterval.getValue() * 1000);
602 headerclick:
function(ct, column, e, t, eOpts)
605 STDLINE(
"header clicked") ;
611 var objectProvenance = Ext.create(
614 target:
'provenance',
615 html :
'Object provenance: ' + where
620 function makeStore(path, reqType)
622 xmlKeysPrintout(
"Sending parameters block to server")
623 theStore_ = Ext.create(
624 'Ext.data.TreeStore',
626 model :
'DirectoriesDataModel',
638 "CookieCode" : _cookieCode ,
640 "fRootPath" : fRootPath_ ,
641 "fFoldersPath": fFoldersPath_ ,
642 "fHistName" : fHistName_ ,
643 "fFileName" : fFileName_
645 url : _requestURL + reqType,
653 beforeload :
function(thisStore, operation, eOpts)
655 STDLINE(
"Request: "+_requestURL + reqType) ;
657 load :
function( thisStore, records, successful, operation, node, eOpts )
659 STDLINE(
"Load was succesful? "+successful) ;
673 function theAjaxRequest(theRequestURL,theParams,theRawData)
675 var today =
new Date();
676 var time = today.getHours() +
":" + today.getMinutes() +
":" + today.getSeconds();
677 STDLINE(
"Ajax request issued to "+theRequestURL+
" at " + time) ;
683 'Content-Type':
'text/plain;charset=UTF-8'
686 rawData: theRawData ,
688 success:
function(response, request)
690 STDLINE(
"Successful") ;
691 if(getXMLValue(response,
"headOfSearch") ==
'located')
694 var theNodes = getXMLNodes(response,
'dir') ;
695 for(var i=0; i<theNodes.length; ++i)
697 var theDir = theNodes[i].getAttribute(
"value")
698 STDLINE(
"Adding "+theDir+
" to the list of enty points") ;
699 dirs.push({
"abbr": theDir,
"dir": theDir}) ;
702 createSources(dirs) ;
705 else if(!(typeof getXMLValue(response,
"rootType") ==
'undefined'))
714 var rootName = getXMLValue (response,
"path" );
715 var rootJSON = getXMLValue (response,
"rootJSON");
716 var
object = JSROOT.parse(rootJSON );
717 STDLINE(
"Launchin displayPlot") ;
718 displayPlot_(
object) ;
732 failure:
function(response, options)
735 Ext.MessageBox.alert(
736 'Something went wrong:',
737 'Response: ' + response.responseText
744 displayPlot_ =
function(object)
746 var index = canvasPos % mdi_.NumGridFrames() ;
751 theFrame =
'histogram1' ;
752 var rootTitle =
object.fTitle ;
755 STDLINE(
"-------> Resetting " + rootTitle);
765 STDLINE(
"-------> Updating " + rootTitle) ;
774 self.onresize =
function()
776 var w = window.innerWidth;
777 var h = window.innerHeight;
778 theCanvas_.setSize(w,h) ;
779 theCanvas_.width = w - navigatorW - 20 ;
780 theCanvas_.height = h - (topMargin_ + bottomMargin_) - decorationH - controlsH ;
781 theCanvas_.items.items[0].width = theCanvas_.width ;
782 theCanvas_.items.items[0].height = theCanvas_.height ;
785 theCanvas_.height + topMargin_,
788 theCanvas_.update() ;
789 if( currentRootObject_ ==
"" ) return ;
791 _requestURL+
"RequestType=getRoot",
793 CookieCode: _cookieCode,
803 currentTree_ =
'files' ;
804 STDLINE(
"The job begins") ;
806 _requestURL+
"RequestType=getDirectoryContents",
808 CookieCode: _cookieCode,