|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <!-- As template three.js web site was used --> |
| 5 | + <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 6 | + <meta charset="utf-8"> |
| 7 | + <title>JavaScript ROOT API examples</title> |
| 8 | + <link rel="shortcut icon" href="img/RootIcon.ico"> |
| 9 | + <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> |
| 10 | + <script type="text/javascript" src="scripts/JSRootCore.js"></script> |
| 11 | + <style> |
| 12 | + |
| 13 | + body { |
| 14 | + background-color: #ffffff; |
| 15 | + margin: 0px; |
| 16 | + font-family: 'Verdana, Geneva, sans-serif'; |
| 17 | + font-size: 15px; |
| 18 | +# line-height: 18px; |
| 19 | + color: #555; |
| 20 | + } |
| 21 | + |
| 22 | + h1 { |
| 23 | + margin-top: 20px; |
| 24 | + margin-bottom: 20px; |
| 25 | + margin-left: 20px; |
| 26 | + font-size: 25px; |
| 27 | + font-weight: normal; |
| 28 | + } |
| 29 | + |
| 30 | + h2 { |
| 31 | + color: #999; |
| 32 | + font-size: 18px; |
| 33 | + font-weight: normal; |
| 34 | + |
| 35 | + margin-top: 10px; |
| 36 | + margin-bottom: 5px; |
| 37 | + } |
| 38 | + |
| 39 | + hr { |
| 40 | + border: 0px; |
| 41 | + height: 1px; |
| 42 | + background-color: #ccc; |
| 43 | + margin: 30px 0px; |
| 44 | + } |
| 45 | + |
| 46 | + a { |
| 47 | + color: #2194CE; |
| 48 | + text-decoration: none; |
| 49 | + } |
| 50 | + |
| 51 | + a:hover { |
| 52 | + text-decoration: underline; |
| 53 | + } |
| 54 | + |
| 55 | + #panel { |
| 56 | + position: fixed; |
| 57 | + left: 0px; |
| 58 | + top: 0px; |
| 59 | + bottom: 0px; |
| 60 | + width: 240px; |
| 61 | + background: #ffffff; |
| 62 | + overflow: auto; |
| 63 | + } |
| 64 | + |
| 65 | + #panel #content { |
| 66 | + padding: 0px 20px; |
| 67 | + } |
| 68 | + |
| 69 | + #panel img { |
| 70 | + border: 1px solid #ccc; |
| 71 | + } |
| 72 | + |
| 73 | + |
| 74 | + #panel #book { |
| 75 | + text-align: center; |
| 76 | + margin-top: 15px; |
| 77 | + } |
| 78 | + |
| 79 | + #viewer { |
| 80 | + position: absolute; |
| 81 | + border: 0px; |
| 82 | + left: 240px; |
| 83 | + width: calc(100% - 240px); |
| 84 | + height: 100%; |
| 85 | + overflow: hidden; |
| 86 | + } |
| 87 | + |
| 88 | + .link:hover { |
| 89 | + text-decoration: underline; |
| 90 | + } |
| 91 | + |
| 92 | + </style> |
| 93 | + </head> |
| 94 | + <body> |
| 95 | + |
| 96 | + <div id="panel"> |
| 97 | + <h1 id="version"><a href=".." style="color:green">JSROOT</a></h1> |
| 98 | + <div id="content"></div> |
| 99 | + <br/> |
| 100 | + </div> |
| 101 | + |
| 102 | + <iframe id="viewer"> |
| 103 | + </iframe> |
| 104 | + |
| 105 | + <script> |
| 106 | + var jsroot_path = "./"; |
| 107 | + var filepath = "../files/"; |
| 108 | + |
| 109 | + document.getElementById( 'version' ).title = JSROOT.version + ", " + JSROOT.source_dir; |
| 110 | + |
| 111 | + if ((window.location.host.indexOf('jsroot.gsi.de') < 0) && |
| 112 | + (window.location.host.indexOf('root.cern.ch') < 0)) { |
| 113 | + filepath = "http://jsroot.gsi.de/files/"; |
| 114 | + } |
| 115 | + |
| 116 | + if (window.location.protocol == "file:") { |
| 117 | + jsroot_path = "http://jsroot.gsi.de/dev/"; |
| 118 | + filepath = "http://jsroot.gsi.de/files/"; |
| 119 | + } |
| 120 | + |
| 121 | + var examples = { |
| 122 | + 'URL syntax': [ |
| 123 | + { name: "Open file", url: "?file=" + filepath + "hsimple.root", title: "Open ROOT file with the JSROOT" }, |
| 124 | + { name: "Display item", url: "?file=" + filepath + "hsimple.root&item=hpxpy;1&opt=colz", title: "Open ROOT file and display item" }, |
| 125 | + { name: "Hide browser", url: "?nobrowser&file=" + filepath + "hsimple.root&item=hprof;1", title: "Do not show file hierarchy - only display item" }, |
| 126 | + { name: "Flexible layout", url: "?file=" + filepath + "hsimple.root&layout=flex&items=[hpx;1,hpxpy;1,hprof;1]&opts=[hist,colz,e1]", title: "Display several items with flexible layout" }, |
| 127 | + { name: "Grid layout", url: "?path=" + filepath + "&layout=grid2x2&files=[hsimple.root,glbox.root]&items=[hsimple.root/hpx;1,hsimple.root/hpxpy;1,hsimple.root/hprof;1,glbox.root/h31;1]&opt=[hist,lego,e1,box1]", title: "Example of grid layout with 2D and 3D drawings" }, |
| 128 | + { name: "Tabs layout", url: "?file=" + filepath + "hsimple.root&layout=tabs&items=[hpx;1,hpxpy;1,hprof;1]&opts=[hist,colz,e1]", title: "Example of tabs layout" }, |
| 129 | + { name: "Collapsible layout", url: "?file=" + filepath + "hsimple.root&layout=collapsible&items=[hpx;1,hpxpy;1,hprof;1]&opts=[hist,colz,e1]", title: "Example of collapsible layout (JSROOT roots)" }, |
| 130 | + { name: "Inspector", url: "?file=" + filepath + "hsimple.root&item=hpx;1&opt=inspect", title: "Show objects data memebers" }, |
| 131 | + { name: "Use JSON", url: "?nobrowser&json=" + filepath + "danilo6.json", title: "Read and display data from JSON file, produced with TBufferJSON class" }, |
| 132 | + { name: "Superimpose", url: "?file=" + filepath + "fillrandom.root&item=h1f;1+sqroot;1", title: "Superimpose histogram and function" }, |
| 133 | + { name: "Several files", url: "?layout=grid2x2&path=" + filepath + "&files=[hsimple.root,graph.root,ct.root]&items=[hsimple.root/[1],graph.root/[11],graph.root/[3],ct.root/[0]]&opts=[lego]", title: "Open several files simultaneusely" }, |
| 134 | + { name: "Superimpose 2 files", url: "?files=[" + filepath + "hsimple.root," + filepath + "graph.root]&item=graph.root/Graph;1+hsimple.root/hprof;1", title: "Superimpose items from two different files" }, |
| 135 | + { name: "Superimpose 3 files", url: "?path=" + filepath + "&files=[temp44.root,temp35.root,temp28.root]&item=temp44.root/Histograms/TDC_C100/Ch1/TDC_C100_Ch1_RisingCalibr;1+temp35.root/_same_+temp28.root/_same_&opt=autocol,nostat&tooltip=2", title: "Superimpose same item from three different files" }, |
| 136 | + { name: "Use autozoom", url: "?layout=grid1x3&path=" + filepath + "&files=[temp44.root,temp35.root,temp28.root]&items=[temp44.root/Histograms/TDC_C100/Ch3/TDC_C100_Ch3_RisingRef;1,temp35.root/_same_,temp28.root/_same_]&opts=[autozoom,autozoom,autozoom]", title: "Let display only non-empty bins of the histogram(s)" } |
| 137 | + ], |
| 138 | + 'Custom HTML' : [ |
| 139 | + { name: "Read JSON", url: "demo/example_json.htm", title : "Custom web page to read and display object from JSON file", src:true }, |
| 140 | + { name: "Read ROOT file", url: "demo/example_file.htm", title : "Read and display object from ROOT file", src: true }, |
| 141 | + { name: "Without id attr", url: "demo/example_element.htm", title : "Do not use explicit id attribute for traget HTML element", src:true }, |
| 142 | + { name: "With require.js", url: "demo/example_require.htm", title : "Load JSROOT libraries with require.js", src:true }, |
| 143 | + { name: "UI with require.js", url: "indexr.htm?file=" + filepath + "danilo5.root&item=canvas;1", title : "Load and use default JSROOT UI with require.js, show data from ROOT file", src:true }, |
| 144 | + { name: "Standalone", url: "demo/example.htm", title : "Produce and draw ROOT histogram in JavaScript", src:true }, |
| 145 | + { name: "TMultiGraph", url: "demo/multigraph.htm", title : "Produce and update TMultiGraph in JavaScript", src:true }, |
| 146 | + { name: "Tooltip hanlder", url: "demo/example_tooltip.htm", title: "User handler function called when tooltip is shown, let build custom UI", src:true }, |
| 147 | + { name: "Update drawing", url: "demo/demo.htm", title: "Update drawing, reading 20 histograms in loop", src:true }, |
| 148 | + { name: "Update in grid", url: "demo/demo.htm?layout=grid3x2", title: "Update drawing on the grid layout", src:true, oldnames: ["Update drawing 2"] }, |
| 149 | + { name: "File hierarchy", url: "demo/example_h.htm", title : "Use HierarchyPainter to display file objects hiararchy", src:true }, |
| 150 | + { name: "Zooming", url: "demo/example_zooming.htm", title : "Redefine Zoom function to make synchronous zooming in other histogram", src:true }, |
| 151 | + { name: "User IO", url: "index.htm?file=" + filepath + "amore.root&item=moH1F_0;1&load=demo/amore.js", title : "Example of custom streamer and custom draw function (AMORE)", src: "demo/amore.js" } |
| 152 | + ], |
| 153 | + 'httpserver.C' : [ |
| 154 | + { link: 'https://github.com/root-mirror/root/blob/master/tutorials/http/httpserver.C' }, |
| 155 | + { name: "Default page", url: "httpserver.C/", title : "Default HTML page of running httpserver.C macro (snapshot)" }, |
| 156 | + { name: "Sub-folder", url: "httpserver.C/Files/job1.root/", title : "Browse server objects from sub-folder" }, |
| 157 | + { name: "Display item", url: "httpserver.C/?item=Files/job1.root/hpxpy&opt=colz&monitoring=1000", title : "Display histogram and enable monitoring (not updating while snapshot is used)" }, |
| 158 | + { name: "No browser (1)", url: "httpserver.C/Files/job1.root/hpxpy/draw.htm?opt=colz", title : "Display item without browser, using provided draw.htm page" }, |
| 159 | + { name: "No browser (2)", url: "httpserver.C/?nobrowser&item=Files/job1.root/hpxpy&opt=colz", title : "Display item without browser, using nobrowser option and normal UI" }, |
| 160 | + { name: "Produce PNG", url: "httpserver.C/Files/job1.root/hpxpy/root.png", title : "Use normal ROOT drawing to produce PNG image" }, |
| 161 | + { name: "Access object members", url: "httpserver.C/?item=Canvases/c1/fPrimitives/hpx", title : "Show histogram from TCanvas lists of primitives (all other objects not cached in this example)" }, |
| 162 | + { name: "Get object title", url: "httpserver.C/Files/job1.root/hpxpy/exe.json?method=GetTitle", title : "Access object methods with exe.json request" }, |
| 163 | + { name: "Tree player", url: "httpserver.C/?item=Files/job1.root/ntuple", title : "Custom UI to execute TTree::Draw on running application" }, |
| 164 | + { name: "Read file", url: "httpserver.C/?file=../../files/hsimple.root&layout=grid2x2&items=[hsimple.root/hpx;1,hsimple.root/hpxpy;1,job1/Files/job1.root/hpx,job1/Files/job1.root/hpxpy]&opts=[hist,col,hist,col]", title : "Show histograms from ROOT file and THttpServer" }, |
| 165 | + { name: "Superimpose", url: "httpserver.C/?file=../../files/hsimple.root&item=[job1/Files/job1.root/hpx,hsimple.root/hpx;1]&opt=logy", title : "Superimpose objects from ROOT file and online server" } |
| 166 | + ], |
| 167 | + 'httpcontrol.C' : [ |
| 168 | + { link: 'https://github.com/root-mirror/root/blob/master/tutorials/http/httpcontrol.C' }, |
| 169 | + { name: "Default page", url: "httpcontrol.C/", title : "Default HTML page of running httpscontrol.C macro (snapshot)" }, |
| 170 | + { name: "Text output", url: "httpcontrol.C/?layout=simple&item=Debug&monitoring=0", title : "Custom text output, using MathJax.js; also disable default monitoring" }, |
| 171 | + { name: "Text output (2)", url: "httpcontrol.C/Debug/draw.htm", title : "Custom text output without browser" } |
| 172 | + ], |
| 173 | + 'Go4ExampleSimple' : [ |
| 174 | + { link: 'https://github.com/linev/go4/tree/master/Go4ExampleSimple' }, |
| 175 | + { name: "Main page", url: "Go4ExampleSimple/", title : "Main page of running Go4ExampleSimple example (snapshot)" }, |
| 176 | + { name: "Without status line", url: "Go4ExampleSimple/?nostatus", title : "Suppress output of status line" }, |
| 177 | + { name: "Draw condition", url: "Go4ExampleSimple/?nostatus&item=Conditions/cHis1", title : "Show TGo4Condition values correspondent histogram" }, |
| 178 | + { name: "Edit condition", url: "Go4ExampleSimple/?item=Conditions/cHis1&opt=editor", title : "Editing condition values" }, |
| 179 | + { name: "Edit parameter", url: "Go4ExampleSimple/?item=Parameters/Par1&opt=editor", title : "Editing parameter values" }, |
| 180 | + { name: "Debug output", url: "Go4ExampleSimple/?item=Status/Log", title : "Show analysis log output" }, |
| 181 | + { name: "Processing rate", url: "Go4ExampleSimple/?item=Status/EventsRate", title : "Show analysis events processing rate as TGraph" }, |
| 182 | + { name: "Analysis configuration", url: "Go4ExampleSimple/?item=Control/Analysis", title : "Change analysis configurations" }, |
| 183 | + { name: "Terminal", url: "Go4ExampleSimple/?item=Control/Terminal", title : "Analysis terminal output plus sveral control elements" } |
| 184 | + ] |
| 185 | + }; |
| 186 | + |
| 187 | + var content = document.getElementById('content'); |
| 188 | + |
| 189 | + function ProcessClick(durl) { |
| 190 | + var viewer = document.getElementById( 'viewer' ); |
| 191 | + if (durl.indexOf("http")==0) |
| 192 | + viewer.src = durl; |
| 193 | + else |
| 194 | + viewer.src = jsroot_path + durl; |
| 195 | + viewer.focus(); |
| 196 | + } |
| 197 | + |
| 198 | + function SetListener(elem, shortname, durl) { |
| 199 | + elem.addEventListener( 'click', function (event) { |
| 200 | + event.preventDefault(); |
| 201 | + window.location.hash = shortname; |
| 202 | + ProcessClick(durl); |
| 203 | + }); |
| 204 | + } |
| 205 | + |
| 206 | + function MakeShortName(name1, name2) { |
| 207 | + return name1.toLowerCase().replace(" ","_").replace(".","_") + "_" + |
| 208 | + name2.toLowerCase().replace(" (2)","_2").replace(" (1)","_1").replace("(","").replace(")","").replace(".","_").replace(" ","_").replace(" ","_"); |
| 209 | + } |
| 210 | + |
| 211 | + for (var key in examples) { |
| 212 | + |
| 213 | + var opts = examples[key]; |
| 214 | + |
| 215 | + var div = document.createElement( 'h2' ); |
| 216 | + if ('link' in opts[0]) { |
| 217 | + var ll = document.createElement( 'a' ); |
| 218 | + ll.textContent = key; |
| 219 | + ll.href = opts[0].link; |
| 220 | + ll.style.color = 'green'; |
| 221 | + div.appendChild(ll); |
| 222 | + } else { |
| 223 | + div.textContent = key; |
| 224 | + } |
| 225 | + |
| 226 | + content.appendChild( div ); |
| 227 | + |
| 228 | + for (var n=0; n<opts.length;++n) { |
| 229 | + var entry = opts[n]; |
| 230 | + |
| 231 | + if (!('name' in entry)) continue; |
| 232 | + |
| 233 | + var shortname = MakeShortName(key, entry.name); |
| 234 | + |
| 235 | + var url = entry.url; |
| 236 | + |
| 237 | + var aaa = document.createElement( 'a' ); |
| 238 | + aaa.textContent = entry.name; |
| 239 | + aaa.href = jsroot_path + url; |
| 240 | + if ('title' in entry) |
| 241 | + aaa.title = entry.title; |
| 242 | + content.appendChild( aaa ); |
| 243 | + SetListener(aaa, shortname, url); |
| 244 | + |
| 245 | + if ('src' in entry) |
| 246 | + if (JSROOT.browser.isOpera || JSROOT.browser.isFirefox || JSROOT.browser.isChrome) { |
| 247 | + aaa = document.createElement( 'a' ); |
| 248 | + aaa.textContent = " (src)"; |
| 249 | + |
| 250 | + if (typeof entry.src === 'string') |
| 251 | + aaa.href = "view-source:" + JSROOT.source_dir + entry.src; |
| 252 | + else |
| 253 | + aaa.href = "view-source:" + JSROOT.source_dir + url; |
| 254 | + aaa.title = "Click to see source of the example"; |
| 255 | + aaa.target = '_blank'; |
| 256 | + content.appendChild( aaa ); |
| 257 | + } |
| 258 | + |
| 259 | + content.appendChild(document.createElement('br')); |
| 260 | + |
| 261 | + if (window.location.hash == "#" + shortname) |
| 262 | + ProcessClick(url); |
| 263 | + else |
| 264 | + if ('oldnames' in entry) |
| 265 | + for (var t in entry.oldnames) |
| 266 | + if (window.location.hash == "#" + MakeShortName(key, entry.oldnames[t])) |
| 267 | + ProcessClick(url); |
| 268 | + } |
| 269 | + } |
| 270 | + |
| 271 | + |
| 272 | + </script> |
| 273 | + |
| 274 | + </body> |
| 275 | +</html> |
0 commit comments