Rev 343 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 343 | Rev 344 | ||
|---|---|---|---|
| 1 | <!DOCTYPE html> |
1 | <!DOCTYPE html> |
| 2 | <html> |
2 | <html> |
| 3 | <head> |
3 | <head> |
| 4 | <meta charset="utf-8"> |
4 | <meta charset="utf-8"> |
| 5 | <title>Belle II Particle Discovery</title> |
5 | <title>Belle II Particle Discovery</title> |
| 6 | <link rel="stylesheet" type="text/css" href="masterclass.css"> |
6 | <link rel="stylesheet" type="text/css" href="masterclass.css"> |
| 7 | <script src="js/blockly_compressed.js"></script> |
7 | <script src="js/blockly_compressed.js"></script> |
| 8 | <script src="js/blocks_compressed.js"></script> |
8 | <script src="js/blocks_compressed.js"></script> |
| 9 | <script src="js/javascript_compressed.js"></script> |
9 | <script src="js/javascript_compressed.js"></script> |
| 10 | <script src="js/en.js"></script> |
10 | <script src="js/en.js"></script> |
| 11 | <script src="js/belle2_def.js"></script> |
11 | <script src="js/belle2_def.js"></script> |
| 12 | <script src="js/belle2_gen.js"></script> |
12 | <script src="js/belle2_gen.js"></script> |
| 13 | <script src="js/workspace.js"></script> |
13 | <script src="js/workspace.js"></script> |
| 14 | <script src="js/FileSaver.min.js"></script> |
14 | <script src="js/FileSaver.min.js"></script> |
| - | 15 | ||
| - | 16 | <link rel="shortcut icon" href="https://root.cern/js/latest/img/RootIcon.ico"/> |
|
| - | 17 | <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> |
|
| - | 18 | <link rel="stylesheet" type="text/css" href="style.css"> |
|
| - | 19 | ||
| - | 20 | <script src="JSRootExtend.js"></script> |
|
| - | 21 | <script src="https://code.jquery.com/jquery-1.12.4.js"></script> |
|
| - | 22 | <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> |
|
| - | 23 | <script src="polFitPanel.js"></script> |
|
| - | 24 | <script src="fminsearch.js"></script> |
|
| - | 25 | <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"></script> |
|
| - | 26 | <script type="text/javascript" src="displayFormula.js"></script> |
|
| - | 27 | <script type="text/x-mathjax-config"> |
|
| - | 28 | MathJax.Hub.Config({ |
|
| - | 29 | tex2jax: { |
|
| - | 30 | inlineMath: [["$","$"],["\\(","\\)"]] |
|
| - | 31 | } |
|
| - | 32 | }); |
|
| - | 33 | </script> |
|
| - | 34 | ||
| 15 | 35 | ||
| 16 | <style> |
36 | <style> |
| 17 | table { |
37 | table { |
| 18 | border-collapse: collapse; |
38 | border-collapse: collapse; |
| 19 | width: 100%; |
39 | width: 100%; |
| 20 | } |
40 | } |
| 21 | 41 | ||
| 22 | th, td { |
42 | th, td { |
| 23 | padding: 0px; |
43 | padding: 0px; |
| 24 | text |
44 | /*text-align: right;*/ |
| 25 | } |
45 | } |
| 26 | 46 | ||
| 27 | tr:hover{background-color:#ffffff} |
47 | tr:hover{background-color:#ffffff} |
| 28 | </style> |
48 | </style> |
| 29 | 49 | ||
| 30 | <script src="js/Blob.js"></script> |
50 | <script src="js/Blob.js"></script> |
| 31 | 51 | ||
| 32 | 52 | ||
| 33 | <!-- <script type="text/javascript" src="js/JSRootCore.js?2d&onload=startGUI""></script> --> |
53 | <!-- <script type="text/javascript" src="js/JSRootCore.js?2d&onload=startGUI""></script> --> |
| 34 | <script type="text/javascript" src="https://root.cern/js/latest/scripts/JSRootCore.js?2d&onload=startGUI"></script> |
54 | <script type="text/javascript" src="https://root.cern/js/latest/scripts/JSRootCore.js?2d&onload=startGUI"></script> |
| 35 | <script type = "text/javascript" language = "javascript"> |
55 | <script type = "text/javascript" language = "javascript"> |
| 36 | 56 | ||
| 37 | var es; |
57 | var es; |
| 38 | function addLog(message) { |
58 | function addLog(message) { |
| 39 | var r = document.getElementById('results'); |
59 | var r = document.getElementById('results'); |
| 40 | r.insertAdjacentHTML('beforeend', message +'<br/>'); |
60 | r.insertAdjacentHTML('beforeend', message +'<br/>'); |
| 41 | } |
61 | } |
| 42 | 62 | ||
| 43 | function showStat(message) { |
63 | function showStat(message) { |
| 44 | var r = document.getElementById('sbar'); |
64 | var r = document.getElementById('sbar'); |
| 45 | r.innerHTML = message ; |
65 | r.innerHTML = message ; |
| 46 | } |
66 | } |
| 47 | 67 | ||
| 48 | 68 | ||
| 49 | 69 | ||
| 50 | function startGUI() { |
70 | function startGUI() { |
| 51 | // d3.select('html').style('height','100%'); |
71 | // d3.select('html').style('height','100%'); |
| 52 | // d3.select('body').style({'min-height':'100%', 'margin':'0px', "overflow" :"hidden"}); |
72 | // d3.select('body').style({'min-height':'100%', 'margin':'0px', "overflow" :"hidden"}); |
| 53 | // var r = document.getElementById('results'); |
73 | // var r = document.getElementById('results'); |
| 54 | // r.style.display = 'none'; |
74 | // r.style.display = 'none'; |
| 55 | var r0 = document.getElementById('sbar'); |
75 | var r0 = document.getElementById('sbar'); |
| 56 | r0.style.display = 'none'; |
76 | r0.style.display = 'none'; |
| 57 | JSROOT.gStyle.fOptFit = 1111; |
77 | JSROOT.gStyle.fOptFit = 1111; |
| 58 | 78 | ||
| 59 | } |
79 | } |
| 60 | 80 | ||
| 61 | 81 | ||
| 62 | function fitpanel(oFormElement) |
82 | function fitpanel(oFormElement) |
| 63 | { |
83 | { |
| 64 | var xhr = new XMLHttpRequest(); |
84 | var xhr = new XMLHttpRequest(); |
| 65 | xhr.onreadystatechange = function() { |
85 | xhr.onreadystatechange = function() { |
| 66 | if(xhr.readyState == 4 && xhr.status == 200) { |
86 | if(xhr.readyState == 4 && xhr.status == 200) { |
| 67 | var event = JSON.parse(xhr.responseText); |
87 | var event = JSON.parse(xhr.responseText); |
| 68 | var result = event.data; |
88 | var result = event.data; |
| 69 | var th1 = JSROOT.parse(result.message); |
89 | var th1 = JSROOT.parse(result.message); |
| 70 | var hname = th1.fName; |
90 | var hname = th1.fName; |
| 71 | var r = document.getElementById('drawing'); |
91 | var r = document.getElementById('drawing'); |
| 72 | if (document.getElementById(hname) == null ){ |
92 | if (document.getElementById(hname) == null ){ |
| 73 | r.insertAdjacentHTML('beforeend', '<div id="' + hname +'" style="width:80%; height:80%;"></div><br/>'); |
93 | r.insertAdjacentHTML('beforeend', '<div id="' + hname +'" style="width:80%; height:80%;"></div><br/>'); |
| 74 | } |
94 | } |
| 75 | var hframe = document.getElementById(hname); |
95 | var hframe = document.getElementById(hname); |
| 76 | hframe.innerHTML = ''; |
96 | hframe.innerHTML = ''; |
| 77 | // https://github.com/root-project/jsroot/issues/42 |
97 | // https://github.com/root-project/jsroot/issues/42 |
| 78 | 98 | ||
| 79 | JSROOT.draw(hname, th1, "hist"); |
99 | JSROOT.draw(hname, th1, "hist"); |
| 80 | JSROOT.gStyle.fOptFit = 1111; |
100 | JSROOT.gStyle.fOptFit = 1111; |
| 81 | JSROOT.draw(hname, th1, "func"); |
101 | JSROOT.draw(hname, th1, "func"); |
| 82 | 102 | ||
| 83 | 103 | ||
| 84 | document.getElementById('data'+ hname).value=result.message; |
104 | document.getElementById('data'+ hname).value=result.message; |
| 85 | //frame.scrollIntoView(); |
105 | //frame.scrollIntoView(); |
| 86 | } |
106 | } |
| 87 | } |
107 | } |
| 88 | xhr.open (oFormElement.method, oFormElement.action, true); |
108 | xhr.open (oFormElement.method, oFormElement.action, true); |
| 89 | 109 | ||
| 90 | var data = new FormData (oFormElement); |
110 | var data = new FormData (oFormElement); |
| 91 | xhr.send (data); |
111 | xhr.send (data); |
| 92 | 112 | ||
| 93 | return false; // Markus had to return true |
113 | return false; // Markus had to return true |
| 94 | } |
114 | } |
| 95 | 115 | ||
| 96 | 116 | ||
| 97 | 117 | ||
| 98 | function startTask() { |
118 | function startTask() { |
| 99 | 119 | ||
| 100 | var r = document.getElementById('results'); |
120 | var r = document.getElementById('results'); |
| 101 | //if ( r.style.display == 'none' ) switchTask(); |
121 | //if ( r.style.display == 'none' ) switchTask(); |
| 102 | r.innerHTML = ''; |
122 | r.innerHTML = ''; |
| 103 | var btnstart = document.getElementById('btnstart'); |
123 | var btnstart = document.getElementById('btnstart'); |
| 104 | btnstart.value= "Stop Analysis"; |
124 | btnstart.value= "Stop Analysis"; |
| 105 | 125 | ||
| 106 | 126 | ||
| 107 | document.getElementById('drawing').innerHTML = ''; |
127 | document.getElementById('drawing').innerHTML = ''; |
| 108 | 128 | ||
| 109 | Blockly.JavaScript.INFINITE_LOOP_TRAP = null; |
129 | Blockly.JavaScript.INFINITE_LOOP_TRAP = null; |
| 110 | var code = Blockly.JavaScript.workspaceToCode(workspace); |
130 | var code = Blockly.JavaScript.workspaceToCode(workspace); |
| 111 | code = code.replace(/\(|\)/gi, ''); |
131 | code = code.replace(/\(|\)/gi, ''); |
| 112 | 132 | ||
| 113 | addLog(code + '<br>'); |
133 | addLog(code + '<br>'); |
| 114 | //addLog(JSON.stringify(code)+ '<br>'); |
134 | //addLog(JSON.stringify(code)+ '<br>'); |
| 115 | es = new EventSource('runscript.php?code=' + code ); |
135 | es = new EventSource('runscript.php?code=' + code ); |
| 116 | 136 | ||
| 117 | //a message is received |
137 | //a message is received |
| 118 | es.addEventListener('message',EventListener); |
138 | es.addEventListener('message',EventListener); |
| 119 | es.addEventListener('error', function(e) { |
139 | es.addEventListener('error', function(e) { |
| 120 | //addLog('Error occurred'); |
140 | //addLog('Error occurred'); |
| 121 | stopTask(); |
141 | stopTask(); |
| 122 | //es.close(); |
142 | //es.close(); |
| 123 | }); |
143 | }); |
| 124 | } |
144 | } |
| 125 | 145 | ||
| 126 | function startAction() { |
146 | function startAction() { |
| 127 | var btnstart = document.getElementById('btnstart'); |
147 | var btnstart = document.getElementById('btnstart'); |
| - | 148 | first = 0; |
|
| 128 | if (btnstart.value=== "Stop Analysis"){ |
149 | if (btnstart.value=== "Stop Analysis"){ |
| 129 | stopTask(); |
150 | stopTask(); |
| 130 | } else { |
151 | } else { |
| 131 | startTask(); |
152 | startTask(); |
| 132 | } |
153 | } |
| 133 | } |
154 | } |
| 134 | 155 | ||
| 135 | function toProcess() { |
156 | function toProcess() { |
| 136 | window.location.hash='#btnstart'; |
157 | window.location.hash='#btnstart'; |
| 137 | //window.location.hash='#blocklyDiv'; |
158 | //window.location.hash='#blocklyDiv'; |
| 138 | } |
159 | } |
| 139 | 160 | ||
| 140 | function showDebug() { |
161 | function showDebug() { |
| 141 | var btnstart = document.getElementById('btndebug'); |
162 | var btnstart = document.getElementById('btndebug'); |
| 142 | var div = document.getElementById('results'); |
163 | var div = document.getElementById('results'); |
| 143 | 164 | ||
| 144 | if (btnstart.value=== "Show Text"){ |
165 | if (btnstart.value=== "Show Text"){ |
| 145 | btnstart.value = "Hide Text"; |
166 | btnstart.value = "Hide Text"; |
| 146 | div.style.display = 'block'; |
167 | div.style.display = 'block'; |
| 147 | } else { |
168 | } else { |
| 148 | btnstart.value = "Show Text"; |
169 | btnstart.value = "Show Text"; |
| 149 | div.style.display = 'none'; |
170 | div.style.display = 'none'; |
| 150 | } |
171 | } |
| 151 | } |
172 | } |
| 152 | 173 | ||
| 153 | function showLicense() { |
174 | function showLicense() { |
| 154 | window.location.href="license.html"; |
175 | window.location.href="license.html"; |
| 155 | } |
176 | } |
| 156 | 177 | ||
| 157 | 178 | ||
| 158 | function EventListener(e) { |
179 | function EventListener(e) { |
| 159 | //addLog(JSON.stringify(e) ); |
180 | //addLog(JSON.stringify(e) ); |
| 160 | 181 | ||
| 161 | var result = JSON.parse( e.data ); |
182 | var result = JSON.parse( e.data ); |
| 162 | 183 | ||
| 163 | if(e.lastEventId == 'CLOSE') { |
184 | if(e.lastEventId == 'CLOSE') { |
| 164 | //addLog('Received CLOSE closing'); |
185 | //addLog('Received CLOSE closing'); |
| 165 | stopTask(); |
186 | stopTask(); |
| 166 | // es.close(); |
187 | // es.close(); |
| 167 | 188 | ||
| 168 | var pBar = document.getElementById('progressor'); |
189 | var pBar = document.getElementById('progressor'); |
| 169 | pBar.value = pBar.max; //max out the progress bar |
190 | pBar.value = pBar.max; //max out the progress bar |
| 170 | var perc = document.getElementById('percentage'); |
191 | var perc = document.getElementById('percentage'); |
| 171 | perc.innerHTML = "100%"; |
192 | perc.innerHTML = "100%"; |
| 172 | perc.style.width = (Math.floor(pBar.clientWidth * (0.5)) + 15) + 'px'; |
193 | perc.style.width = (Math.floor(pBar.clientWidth * (0.5)) + 15) + 'px'; |
| 173 | } else { |
194 | } else { |
| 174 | if(e.lastEventId == '0' ) { |
195 | if(e.lastEventId == '0' ) { |
| 175 | addLog(result.message); |
196 | addLog(result.message); |
| 176 | } else { |
197 | } else { |
| 177 | if(e.lastEventId == '2' ) { |
198 | if(e.lastEventId == '2' ) { |
| 178 | showStat(result.message); |
199 | showStat(result.message); |
| 179 | } else { |
200 | } else { |
| 180 | var jsonobj = JSROOT.parse(result.message); |
201 | var jsonobj = JSROOT.parse(result.message); |
| 181 | var sframe = jsonobj.fName; |
202 | var sframe = jsonobj.fName; |
| 182 | 203 | ||
| 183 | 204 | ||
| 184 | //addLog('Histogram :'+ sframe ); |
205 | //addLog('Histogram :'+ sframe ); |
| 185 | //var r = document.getElementById('results'); |
206 | //var r = document.getElementById('results'); |
| 186 | var r = document.getElementById('drawing'); |
207 | var r = document.getElementById('drawing'); |
| 187 | if (document.getElementById(sframe) == null ){ |
208 | if (document.getElementById(sframe) == null ){ |
| - | 209 | //console.log('insert HTML for', sframe) |
|
| 188 | r.insertAdjacentHTML('beforeend', '<div id="' + sframe +'" style="width: |
210 | r.insertAdjacentHTML('beforeend', '<div id="' + sframe +'" style="width:800px; height:500px"></div><br/>');//narise histogram |
| - | 211 | ||
| 189 | r.insertAdjacentHTML('beforeend', '<div id="fit' + sframe +'" style="display: none"></div><br/>'); |
212 | r.insertAdjacentHTML('beforeend', '<div id="fit' + sframe +'" style="display: none"></div><br/>'); |
| 190 | var fit = document.getElementById('fit'+ sframe); |
- | |
| 191 | mform ='<form method="post" action="th1fit.php" onsubmit="return fitpanel(this);">'; |
- | |
| 192 | mform += ' Function:<input type="text" size="20" value="gaus" name="fitfun" /><br/>'; |
- | |
| 193 | mform += ' Range: min=<input type="text" size="2" value="0" name="min" />'; |
- | |
| 194 | mform += ' max=<input type="text" size="2" value="20" name="max" /><br/>'; |
- | |
| 195 | mform += ' Initial parameters (separated by ,)<input type="text" size="20" value="" name="prm" /><br/>'; |
- | |
| 196 | mform += ' <input id="data'+ sframe +'" type="hidden" value="'+ result.message +'" name="data" />'; |
- | |
| 197 | mform += ' <input type="hidden" value="'+ sframe +'" name="name" />'; |
- | |
| 198 | mform += ' <input class="mybutton" type="submit" value=" Fit "/>'; |
- | |
| 199 | mform += '</form>'; |
- | |
| 200 | fit.insertAdjacentHTML('beforeend', '<div id="param' + sframe +'"></div><br/>'); |
- | |
| 201 |
|
213 | insertHTML(sframe); |
| 202 | r.insertAdjacentHTML('beforeend','<input type="button" onclick="togglevisibility(\'fit'+sframe+'\');" class="mybutton" value="Show/Hide Fit Panel" />' ); |
214 | r.insertAdjacentHTML('beforeend','<input type="button" onclick="togglevisibility(\'fit'+sframe+'\');" class="mybutton" value="Show/Hide Fit Panel" />' ); |
| 203 | r.insertAdjacentHTML('beforeend',' <input type="button" onclick="toProcess();" class="mybutton" value="To Process" /><hr/>' ); |
215 | r.insertAdjacentHTML('beforeend',' <input type="button" onclick="toProcess();" class="mybutton" value="To Process" /><hr/>' ); |
| 204 |
|
216 | |
| 205 | //r.insertAdjacentHTML('beforeend', JSON.stringify(result.message)); |
217 | //r.insertAdjacentHTML('beforeend', JSON.stringify(result.message)); |
| 206 | } |
218 | } |
| 207 | var frame = document.getElementById(sframe); |
219 | var frame = document.getElementById(sframe); |
| - | 220 | JSROOT.redraw(sframe, jsonobj, "hist", function(){ |
|
| - | 221 | initSliders(sframe); |
|
| 208 | 222 | }); |
|
| 209 |
|
223 | |
| 210 | 224 | ||
| 211 | 225 | ||
| 212 | frame.scrollIntoView(); |
226 | frame.scrollIntoView(); |
| 213 | } |
227 | } |
| 214 | } |
228 | } |
| 215 | var pBar = document.getElementById('progressor'); |
229 | var pBar = document.getElementById('progressor'); |
| 216 | pBar.value = result.progress; |
230 | pBar.value = result.progress; |
| 217 | var perc = document.getElementById('percentage'); |
231 | var perc = document.getElementById('percentage'); |
| 218 | perc.innerHTML = result.progress + "%"; |
232 | perc.innerHTML = result.progress + "%"; |
| 219 | perc.style.width = (Math.floor(pBar.clientWidth * (result.progress/100)) + 15) + 'px'; |
233 | perc.style.width = (Math.floor(pBar.clientWidth * (result.progress/100)) + 15) + 'px'; |
| 220 | } |
234 | } |
| 221 | } |
235 | } |
| 222 | 236 | ||
| 223 | 237 | ||
| 224 | 238 | ||
| 225 | function stopTask() { |
239 | function stopTask() { |
| 226 | es.close(); |
240 | es.close(); |
| 227 | //addLog('Task end'); |
241 | //addLog('Task end'); |
| 228 | var btnstart = document.getElementById('btnstart'); |
242 | var btnstart = document.getElementById('btnstart'); |
| 229 | 243 | ||
| 230 | btnstart.value= "Run Analysis"; |
244 | btnstart.value= "Run Analysis"; |
| 231 | 245 | ||
| 232 | } |
246 | } |
| 233 | 247 | ||
| 234 | 248 | ||
| 235 | /* |
249 | /* |
| 236 | function switchTask() { |
250 | function switchTask() { |
| 237 | var div = document.getElementById('results'); |
251 | var div = document.getElementById('results'); |
| 238 | var divs = document.getElementById('sbar'); |
252 | var divs = document.getElementById('sbar'); |
| 239 | var div0 = document.getElementById('blocklyDiv'); |
253 | var div0 = document.getElementById('blocklyDiv'); |
| 240 | 254 | ||
| 241 | if (div.style.display !== 'none') { |
255 | if (div.style.display !== 'none') { |
| 242 | div.style.display = 'none'; |
256 | div.style.display = 'none'; |
| 243 | divs.style.display = 'none'; |
257 | divs.style.display = 'none'; |
| 244 | div0.style.display = 'block'; |
258 | div0.style.display = 'block'; |
| 245 | } |
259 | } |
| 246 | else { |
260 | else { |
| 247 | div.style.display = 'block'; |
261 | div.style.display = 'block'; |
| 248 | divs.style.display = 'block'; |
262 | divs.style.display = 'block'; |
| 249 | div0.style.display = 'none'; |
263 | div0.style.display = 'none'; |
| 250 | } |
264 | } |
| 251 | 265 | ||
| 252 | } |
266 | } |
| 253 | */ |
267 | */ |
| 254 | 268 | ||
| 255 | 269 | ||
| 256 | function togglevisibility( name ) { |
270 | function togglevisibility( name ) { |
| 257 | var div = document.getElementById(name); |
271 | var div = document.getElementById(name); |
| 258 | if (div.style.display !== 'none') { |
272 | if (div.style.display !== 'none') { |
| 259 | div.style.display = 'none'; |
273 | div.style.display = 'none'; |
| 260 | } |
274 | } |
| 261 | else { |
275 | else { |
| 262 | div.style.display = 'block'; |
276 | div.style.display = 'block'; |
| 263 | } |
277 | } |
| 264 | } |
278 | } |
| 265 | 279 | ||
| 266 | 280 | ||
| 267 | function readSingleFile(e) { |
281 | function readSingleFile(e) { |
| 268 | 282 | ||
| 269 | var div0 = document.getElementById('blocklyDiv'); |
283 | var div0 = document.getElementById('blocklyDiv'); |
| 270 | //if (div0.style.display === 'none') switchTask(); |
284 | //if (div0.style.display === 'none') switchTask(); |
| 271 | 285 | ||
| 272 | var file = e.target.files[0]; |
286 | var file = e.target.files[0]; |
| 273 | if (!file) { |
287 | if (!file) { |
| 274 | return; |
288 | return; |
| 275 | } |
289 | } |
| 276 | var reader = new FileReader(); |
290 | var reader = new FileReader(); |
| 277 | reader.onload = function(e) { |
291 | reader.onload = function(e) { |
| 278 | var contents = e.target.result; |
292 | var contents = e.target.result; |
| 279 | displayContents(contents); |
293 | displayContents(contents); |
| 280 | 294 | ||
| 281 | }; |
295 | }; |
| 282 | reader.readAsText(file); |
296 | reader.readAsText(file); |
| 283 | 297 | ||
| 284 | } |
298 | } |
| 285 | 299 | ||
| 286 | function displayContents(contents) { |
300 | function displayContents(contents) { |
| 287 | 301 | ||
| 288 | workspace.clear(); |
302 | workspace.clear(); |
| 289 | var xml = Blockly.Xml.textToDom(contents); |
303 | var xml = Blockly.Xml.textToDom(contents); |
| 290 | Blockly.Xml.domToWorkspace(xml, workspace); |
304 | Blockly.Xml.domToWorkspace(xml, workspace); |
| 291 | 305 | ||
| 292 | } |
306 | } |
| 293 | 307 | ||
| 294 | 308 | ||
| 295 | function loadDoc( url ) { |
309 | function loadDoc( url ) { |
| 296 | var xhttp = new XMLHttpRequest(); |
310 | var xhttp = new XMLHttpRequest(); |
| 297 | xhttp.onreadystatechange = function () { |
311 | xhttp.onreadystatechange = function () { |
| 298 | if (xhttp.readyState == 4 && xhttp.status == 200) { |
312 | if (xhttp.readyState == 4 && xhttp.status == 200) { |
| 299 | return xhttp.responseText; |
313 | return xhttp.responseText; |
| 300 | } |
314 | } |
| 301 | } |
315 | } |
| 302 | xhttp.open("GET", url, false); // !!! should be in synchronous mode |
316 | xhttp.open("GET", url, false); // !!! should be in synchronous mode |
| 303 | xhttp.send(); |
317 | xhttp.send(); |
| 304 | return xhttp.onreadystatechange(); |
318 | return xhttp.onreadystatechange(); |
| 305 | } |
319 | } |
| 306 | 320 | ||
| 307 | function showCode() { |
321 | function showCode() { |
| 308 | // Generate JavaScript code and display it. |
322 | // Generate JavaScript code and display it. |
| 309 | Blockly.JavaScript.INFINITE_LOOP_TRAP = null; |
323 | Blockly.JavaScript.INFINITE_LOOP_TRAP = null; |
| 310 | var code = Blockly.JavaScript.workspaceToCode(workspace); |
324 | var code = Blockly.JavaScript.workspaceToCode(workspace); |
| 311 | //var code = Blockly.JSON.fromWorkspace( workspace ); |
325 | //var code = Blockly.JSON.fromWorkspace( workspace ); |
| 312 | //var code = Blockly.Xml.domToPrettyText(workspace ); |
326 | //var code = Blockly.Xml.domToPrettyText(workspace ); |
| 313 | code = code.replace(/\(|\)/gi, ''); |
327 | code = code.replace(/\(|\)/gi, ''); |
| 314 | console.log(code); |
328 | console.log(code); |
| 315 | console.log(code.length); |
329 | console.log(code.length); |
| 316 | alert(code); |
330 | alert(code); |
| 317 | 331 | ||
| 318 | } |
332 | } |
| 319 | 333 | ||
| 320 | 334 | ||
| 321 | function saveBlockly(){ |
335 | function saveBlockly(){ |
| 322 | // https://eligrey.com/blog/saving-generated-files-on-the-client-side/ |
336 | // https://eligrey.com/blog/saving-generated-files-on-the-client-side/ |
| 323 | 337 | ||
| 324 | var xml = Blockly.Xml.workspaceToDom(workspace); |
338 | var xml = Blockly.Xml.workspaceToDom(workspace); |
| 325 | var txt = Blockly.Xml.domToText(xml); |
339 | var txt = Blockly.Xml.domToText(xml); |
| 326 | 340 | ||
| 327 | // var txt=Blockly.Xml.domToPrettyText(Blockly.Xml.workspaceToDom(Blockly.mainWorkspace)); // exports workspace as pretty xml |
341 | // var txt=Blockly.Xml.domToPrettyText(Blockly.Xml.workspaceToDom(Blockly.mainWorkspace)); // exports workspace as pretty xml |
| 328 | console.log(txt); |
342 | console.log(txt); |
| 329 | var blob = new Blob([txt], {type: "text/xml"}); |
343 | var blob = new Blob([txt], {type: "text/xml"}); |
| 330 | saveAs(blob, "test.blab2"); |
344 | saveAs(blob, "test.blab2"); |
| 331 | } |
345 | } |
| 332 | 346 | ||
| 333 | function loadBlockly(){ |
347 | function loadBlockly(){ |
| 334 | Blockly.Xml.domToWorkspace(Blockly.mainWorkspace,$("#hiBlocks")[0]); // loads xml from dom into workspace |
348 | Blockly.Xml.domToWorkspace(Blockly.mainWorkspace,$("#hiBlocks")[0]); // loads xml from dom into workspace |
| 335 | } |
349 | } |
| 336 | 350 | ||
| 337 | function runCode() { |
351 | function runCode() { |
| 338 | // Generate JavaScript code and run it. |
352 | // Generate JavaScript code and run it. |
| 339 | window.LoopTrap = 1000; |
353 | window.LoopTrap = 1000; |
| 340 | Blockly.JavaScript.INFINITE_LOOP_TRAP = |
354 | Blockly.JavaScript.INFINITE_LOOP_TRAP = |
| 341 | 'if (--window.LoopTrap == 0) throw "Infinite loop.";\n'; |
355 | 'if (--window.LoopTrap == 0) throw "Infinite loop.";\n'; |
| 342 | var code = Blockly.JavaScript.workspaceToCode(workspace); |
356 | var code = Blockly.JavaScript.workspaceToCode(workspace); |
| 343 | Blockly.JavaScript.INFINITE_LOOP_TRAP = null; |
357 | Blockly.JavaScript.INFINITE_LOOP_TRAP = null; |
| 344 | try { |
358 | try { |
| 345 | eval(code); |
359 | eval(code); |
| 346 | } catch (e) { |
360 | } catch (e) { |
| 347 | alert(e); |
361 | alert(e); |
| 348 | } |
362 | } |
| 349 | } |
363 | } |
| - | 364 | ||
| - | 365 | Blockly.Blocks['simple_analysis'] = { |
|
| - | 366 | init: function() { |
|
| - | 367 | this.appendDummyInput() |
|
| - | 368 | .appendField("Belle II Masterclass"); |
|
| - | 369 | this.appendDummyInput() |
|
| - | 370 | .appendField("Number of events: ") |
|
| - | 371 | .appendField(new Blockly.FieldNumber(5000, 0), "neve"); |
|
| - | 372 | this.appendDummyInput() |
|
| - | 373 | .appendField("First event: ") |
|
| - | 374 | .appendField(new Blockly.FieldNumber(0, 0), "first"); |
|
| - | 375 | this.appendDummyInput() |
|
| - | 376 | .appendField("Data Source") |
|
| - | 377 | .appendField(new Blockly.FieldDropdown([ |
|
| - | 378 | <?php |
|
| - | 379 | $files = array_slice(scandir('../data/'), 2); |
|
| - | 380 | $cnt=0; |
|
| - | 381 | foreach($files as $f){ |
|
| - | 382 | echo "[\"$f\",\"$f\"],"; |
|
| - | 383 | $cnt++; |
|
| - | 384 | } |
|
| - | 385 | ?>]), "datasource"); |
|
| - | 386 | this.appendDummyInput() |
|
| - | 387 | .appendField("Print particle list?") |
|
| - | 388 | .appendField(new Blockly.FieldDropdown([["No", "0"], ["Yes", "1"]]), "print"); |
|
| - | 389 | this.appendValueInput("list") |
|
| - | 390 | .setCheck("particle list") |
|
| - | 391 | .appendField("Particle List"); |
|
| - | 392 | this.setColour(230); |
|
| - | 393 | this.setTooltip('Run the analysis, specify data source, number of events, first event and a list of particles to process.'); |
|
| - | 394 | this.setHelpUrl('http://belle2.jp/'); |
|
| 350 | 395 | } |
|
| - | 396 | }; |
|
| - | 397 | ||
| 351 | 398 | ||
| 352 | </script> |
399 | </script> |
| 353 | 400 | ||
| 354 | </head> |
401 | </head> |
| 355 | <body> |
402 | <body> |
| - | 403 | ||
| 356 | <h1>Belle II Particle Discovery: Describe process →Analyse →Fit results →Discover</h1> |
404 | <h1>Belle II Particle Discovery: Describe process →Analyse →Fit results →Discover</h1> |
| 357 | <!-- <input type="button" onclick="showCode();" class="mybutton" value="Show JavaScript" /> --> |
405 | <!-- <input type="button" onclick="showCode();" class="mybutton" value="Show JavaScript" /> --> |
| 358 | <input type="button" id="btnstart" onclick="startAction();" class="mybutton" value="Run Analysis" /> |
406 | <input type="button" id="btnstart" onclick="startAction();" class="mybutton" value="Run Analysis" /> |
| 359 | 407 | ||
| 360 | <input type="button" onclick="saveBlockly();" class="mybutton" value="Save Diagram" /> |
408 | <input type="button" onclick="saveBlockly();" class="mybutton" value="Save Diagram" /> |
| 361 | <form style="display:inline;"><label for="file-input" class="mybutton" style="">Load Diagram</label> |
409 | <form style="display:inline;"><label for="file-input" class="mybutton" style="">Load Diagram</label> |
| 362 | <input type="button" id="btndebug" onclick="showDebug();" class="mybutton" value="Hide Text" /> |
410 | <input type="button" id="btndebug" onclick="showDebug();" class="mybutton" value="Hide Text" /> |
| 363 | <input type="button" id="btnhelp" onclick="window.location.href='BelleIILabManual.pdf';" class="mybutton" value="Help" /> |
411 | <input type="button" id="btnhelp" onclick="window.location.href='BelleIILabManual.pdf';" class="mybutton" value="Help" /> |
| 364 | <input type="button" id="btnabout" onclick="showLicense();" class="mybutton" value="About" /> |
412 | <input type="button" id="btnabout" onclick="showLicense();" class="mybutton" value="About" /> |
| 365 | <input type="file" style="visibility:hidden;" id="file-input" onClick="this.form.reset()" data-buttonText="Load Diagram"/></form> |
413 | <input type="file" style="visibility:hidden;" id="file-input" onClick="this.form.reset()" data-buttonText="Load Diagram"/></form> |
| 366 | <br/> |
414 | <br/> |
| 367 | <progress id='progressor' value="0" max='100' style="width:95%"></progress> |
415 | <progress id='progressor' value="0" max='100' style="width:95%"></progress> |
| 368 | <span id="percentage" style="text-align:right; display:block; margin-top:5px;">0</span> |
416 | <span id="percentage" style="text-align:right; display:block; margin-top:5px;">0</span> |
| 369 | <p id="sbar" ></div> |
417 | <p id="sbar" ></div> |
| 370 | 418 | ||
| 371 | <br /> |
419 | <br /> |
| 372 | 420 | ||
| 373 | <div id="results" style="border:1px solid #000; padding:10px; width:95%; height:80% ; overflow:auto; background:#eee;"></div> |
421 | <div id="results" style="border:1px solid #000; padding:10px; width:95%; height:80% ; overflow:auto; background:#eee;"></div> |
| 374 | <br /> |
422 | <br /> |
| 375 | <div id="blocklyDiv" style="height:900px; width:95%"></div><br /> |
423 | <div id="blocklyDiv" style="height:900px; width:95%"></div><br /> |
| 376 | 424 | ||
| 377 | <script> |
425 | <script> |
| 378 | 426 | ||
| 379 | document.getElementById('file-input').addEventListener('change', readSingleFile, false); |
427 | document.getElementById('file-input').addEventListener('change', readSingleFile, false); |
| 380 | 428 | ||
| 381 | var toolbox = loadDoc("toolbox.xml"); |
429 | var toolbox = loadDoc("toolbox.xml"); |
| 382 | 430 | ||
| 383 | var options = { |
431 | var options = { |
| 384 | toolbox : toolbox, |
432 | toolbox : toolbox, |
| 385 | collapse : true, |
433 | collapse : true, |
| 386 | comments : true, |
434 | comments : true, |
| 387 | disable : true, |
435 | disable : true, |
| 388 | maxBlocks : Infinity, |
436 | maxBlocks : Infinity, |
| 389 | trashcan : true, |
437 | trashcan : true, |
| 390 | horizontalLayout : false, |
438 | horizontalLayout : false, |
| 391 | toolboxPosition : 'start', |
439 | toolboxPosition : 'start', |
| 392 | css : true, |
440 | css : true, |
| 393 | /* media : '../media/', */ |
441 | /* media : '../media/', */ |
| 394 | rtl : false, |
442 | rtl : false, |
| 395 | scrollbars : true, |
443 | scrollbars : true, |
| 396 | sounds : true, |
444 | sounds : true, |
| 397 | oneBasedIndex : true, |
445 | oneBasedIndex : true, |
| 398 | zoom : { |
446 | zoom : { |
| 399 | controls : true, |
447 | controls : true, |
| 400 | wheel : true, |
448 | wheel : true, |
| 401 | startScale : 1, |
449 | startScale : 1, |
| 402 | maxcale : 3, |
450 | maxcale : 3, |
| 403 | minScale : 0.3 |
451 | minScale : 0.3 |
| 404 | }, |
452 | }, |
| 405 | grid: |
453 | grid: |
| 406 | {spacing: 20, |
454 | {spacing: 20, |
| 407 | length: 3, |
455 | length: 3, |
| 408 | colour: '#ccc', |
456 | colour: '#ccc', |
| 409 | snap: true} |
457 | snap: true} |
| 410 | }; |
458 | }; |
| 411 | 459 | ||
| 412 | var workspace = Blockly.inject('blocklyDiv', options); |
460 | var workspace = Blockly.inject('blocklyDiv', options); |
| 413 | 461 | ||
| 414 | <?php |
462 | <?php |
| 415 | 463 | ||
| 416 | if (isset($_GET["decay"])){ |
464 | if (isset($_GET["decay"])){ |
| 417 | $decay = $_GET["decay"]; |
465 | $decay = $_GET["decay"]; |
| 418 | } else { |
466 | } else { |
| 419 | $decay = "data/sample.blab2"; |
467 | $decay = "data/sample.blab2"; |
| 420 | } |
468 | } |
| 421 | // echo "var workspaceBlocks = loadDoc( \"$decay\");" |
469 | // echo "var workspaceBlocks = loadDoc( \"$decay\");" |
| 422 | /* Load blocks to workspace. */ |
470 | /* Load blocks to workspace. */ |
| 423 | echo "displayContents( loadDoc( \"$decay\"));" |
471 | echo "displayContents( loadDoc( \"$decay\"));" |
| 424 | 472 | ||
| 425 | ?> |
473 | ?> |
| 426 | 474 | ||
| 427 | //displayContents(workspaceBlocks); |
475 | //displayContents(workspaceBlocks); |
| 428 | </script> |
476 | </script> |
| 429 | <div id="drawing"></div> |
477 | <div id="drawing"></div> |
| 430 | <?php |
478 | <?php |
| 431 | $hostname = gethostname(); |
479 | $hostname = gethostname(); |
| 432 | if ($hostname != "belle2.ijs.si") { |
480 | if ($hostname != "belle2.ijs.si") { |
| 433 | echo "<a href='update.php'>Update code from the central server</a>"; |
481 | echo "<a href='update.php'>Update code from the central server</a>"; |
| 434 | } |
482 | } |
| 435 | ?> |
483 | ?> |
| 436 | </body> |
484 | </body> |
| 437 | </html> |
485 | </html> |
| 438 | 486 | ||