7 if ( typeof define ===
"function" && define.amd ) {
9 define( [
'jquery',
'jquery-ui',
'd3',
'JSRootPainter'], factory );
12 if (typeof jQuery ==
'undefined')
13 throw new Error(
'jQuery not defined',
'JSRootPainter.jquery.js');
15 if (typeof jQuery.ui ==
'undefined')
16 throw new Error(
'jQuery-ui not defined',
'JSRootPainter.jquery.js');
18 if (typeof d3 !=
'object')
19 throw new Error(
'This extension requires d3.v3.js',
'JSRootPainter.jquery.js');
21 if (typeof JSROOT ==
'undefined')
22 throw new Error(
'JSROOT is not defined',
'JSRootPainter.jquery.js');
24 if (typeof JSROOT.Painter !=
'object')
25 throw new Error(
'JSROOT.Painter not defined',
'JSRootPainter.jquery.js');
28 factory(jQuery, jQuery.ui, d3, JSROOT);
30 } (
function($, myui, d3, JSROOT) {
34 if ( typeof define ===
"function" && define.amd )
35 JSROOT.loadScript(
'$$$style/JSRootInterface.css');
37 ResetUI =
function() {
38 if (hpainter) hpainter.clear(
true);
41 guiLayout =
function() {
42 var res =
'collapsible';
43 var selects = document.getElementById(
"layout");
45 res = selects.options[selects.selectedIndex].text;
49 setGuiLayout =
function(value) {
50 var selects = document.getElementById(
"layout");
53 for (var i in selects.options) {
54 var s = selects.options[i].text;
55 if (typeof s ==
'undefined')
continue;
56 if ((s == value) || (s.replace(/ /g,
"") == value)) {
57 selects.selectedIndex = i;
63 ReadFile =
function() {
64 var filename = $(
"#urlToLoad").val();
66 if (filename.length == 0)
return;
68 if (hpainter==null) alert(
"Hierarchy painter not initialized");
69 if ((filename.lastIndexOf(
".json") == filename.length-5) ||
70 (filename.lastIndexOf(
".JSON") == filename.length-5))
71 hpainter.OpenJsonFile(filename);
73 hpainter.OpenRootFile(filename);
76 BuildSimpleGUI =
function() {
78 if (JSROOT.GetUrlOption(
"nobrowser")!=null)
79 return JSROOT.BuildNobrowserGUI();
81 var myDiv = $(
'#simpleGUI');
84 if (myDiv.length==0) {
85 myDiv = $(
'#onlineGUI');
86 if (myDiv.length==0)
return alert(
'no div for simple gui found');
90 JSROOT.Painter.readStyleFromURL();
92 var guiCode =
"<div id='left-div' class='column' style='top:1px; bottom:1px'>";
95 guiCode +=
'<h1><font face="Verdana" size="4"><div id="toptitle">ROOT online server</div></font></h1>'
96 +
"<p><font face='Verdana' size='1px'><a href='https://github.com/linev/jsroot'>JSROOT</a> version <span style='color:green'><b>" + JSROOT.version +
"</b></span></font></p>"
97 +
'<p> Hierarchy in <a href="h.json">json</a> and <a href="h.xml">xml</a> format</p>'
98 +
' <input type="checkbox" name="monitoring" id="monitoring"/> Monitoring '
99 +
' <select style="padding:2px; margin-left:10px; margin-top:5px;" id="layout">'
100 +
' <option>simple</option><option>collapsible</option><option>flex</option><option>tabs</option><option>grid 1x2</option><option>grid 2x2</option><option>grid 1x3</option><option>grid 2x3</option><option>grid 3x3</option><option>grid 4x4</option>'
104 var files = myDiv.attr(
"files");
105 var path = JSROOT.GetUrlOption(
"path");
106 if (path==null) path = myDiv.attr(
"path");
107 if (path==null) path =
"";
109 if (files==null) files =
"../files/hsimple.root";
110 var arrFiles = files.split(
';');
112 guiCode +=
"<h1><font face='Verdana' size='4'>Read a ROOT file</font></h1>"
113 +
"<p><font face='Verdana' size='1px'><a href='https://root.cern.ch/js/'>JSROOT</a> version <span style='color:green'><b>" + JSROOT.version +
"</b></span></font></p>";
115 if (JSROOT.GetUrlOption(
"noselect")==null) {
116 guiCode +=
'<form name="ex">'
117 +
'<input type="text" name="state" value="" style="width:95%; margin-top:5px;" id="urlToLoad"/>'
118 +
'<select name="s" style="width:65%; margin-top:5px;" '
119 +
'onchange="document.ex.state.value = document.ex.s.options[document.ex.s.selectedIndex].value;document.ex.s.selectedIndex=0;document.ex.s.value=\'\'">'
120 +
'<option value=" " selected="selected"> </option>';
121 for (var i in arrFiles)
122 guiCode +=
'<option value = "' + path + arrFiles[i] +
'">' + arrFiles[i] +
'</option>';
123 guiCode +=
'</select><br/>'
124 +
'<p><small><a href="https://github.com/linev/jsroot/blob/master/docs/JSROOT.md#reading-root-files-from-other-servers">Read docu</a>'
125 +
' how to open files from other servers.</small></p>'
126 +
'<input style="padding:2px; margin-top:5px;"'
127 +
' onclick="ReadFile()" type="button" title="Read the Selected File" value="Load"/>'
128 +
'<input style="padding:2px; margin-left:10px;"'
129 +
' onclick="ResetUI()" type="button" title="Clear All" value="Reset"/>'
130 +
'<select style="padding:2px; margin-left:10px; margin-top:5px;" title="layout kind" id="layout">'
131 +
' <option>simple</option><option>collapsible</option><option>flex</option><option>tabs</option><option>grid 1x2</option><option>grid 2x2</option><option>grid 1x3</option><option>grid 2x3</option><option>grid 3x3</option><option>grid 4x4</option>'
137 guiCode +=
'<div id="browser"></div>'
139 +
'<div id="separator-div" style="top:1px; bottom:1px"></div>'
140 +
'<div id="right-div" class="column" style="top:1px; bottom:1px"></div>';
142 var drawDivId =
'right-div';
144 myDiv.empty().append(guiCode);
149 if (typeof GetCachedHierarchy ==
'function') h0 = GetCachedHierarchy();
150 if (typeof h0 !=
'object') h0 =
"";
153 hpainter =
new JSROOT.HierarchyPainter(
'root',
'browser');
155 hpainter.SetDisplay(null, drawDivId);
157 JSROOT.Painter.ConfigureVSeparator(hpainter);
161 hpainter.StartGUI(h0,
function() {
163 setGuiLayout(hpainter.GetLayout());
167 $(
"#layout").change(
function() {
168 if (hpainter) hpainter.SetDisplay(guiLayout(), drawDivId);
172 if ((hpainter.h!=null) && (
'_toptitle' in hpainter.h))
173 $(
"#toptitle").html(hpainter.h._toptitle);
175 .prop(
'checked', hpainter.IsMonitoring())
177 hpainter.EnableMonitoring(this.checked);
178 hpainter.updateAll(!this.checked);
182 hpainter.ForEachRootFile(
function(item) {
if (fname==
"") fname = item._fullurl; });
183 $(
"#urlToLoad").val(fname);