Rev 267 | Rev 269 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 267 | Rev 268 | ||
|---|---|---|---|
| 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 Masterclass</title> |
5 | <title>Belle II Masterclass</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 | 15 | ||
| 16 | <style> |
16 | <style> |
| 17 | table { |
17 | table { |
| 18 | border-collapse: collapse; |
18 | border-collapse: collapse; |
| 19 | width: 100%; |
19 | width: 100%; |
| 20 | } |
20 | } |
| 21 | 21 | ||
| 22 | th, td { |
22 | th, td { |
| 23 | padding: 0px; |
23 | padding: 0px; |
| 24 | text-align: right; |
24 | text-align: right; |
| 25 | } |
25 | } |
| 26 | 26 | ||
| 27 | tr:hover{background-color:#ffffff} |
27 | tr:hover{background-color:#ffffff} |
| 28 | </style> |
28 | </style> |
| 29 | 29 | ||
| 30 | <script src="js/Blob.js"></script> |
30 | <script src="js/Blob.js"></script> |
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | <!-- <script type="text/javascript" src="js/JSRootCore.js?2d&onload=startGUI""></script> --> |
33 | <!-- <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? |
34 | <script type="text/javascript" src="https://root.cern/js/latest/scripts/JSRootCore.js?more2d&math&onload=startGUI"></script> |
| 35 | <script type = "text/javascript" language = "javascript"> |
35 | <script type = "text/javascript" language = "javascript"> |
| 36 | 36 | ||
| 37 | var es; |
37 | var es; |
| 38 | function addLog(message) { |
38 | function addLog(message) { |
| 39 | var r = document.getElementById('results'); |
39 | var r = document.getElementById('results'); |
| 40 | //r.innerHTML += message + '<br>'; |
40 | //r.innerHTML += message + '<br>'; |
| 41 | r.insertAdjacentHTML('beforeend', message +'<br/>'); |
41 | r.insertAdjacentHTML('beforeend', message +'<br/>'); |
| 42 | // r.scrollTop = r.scrollHeight; |
42 | // r.scrollTop = r.scrollHeight; |
| 43 | } |
43 | } |
| 44 | 44 | ||
| 45 | function showStat(message) { |
45 | function showStat(message) { |
| 46 | var r = document.getElementById('sbar'); |
46 | var r = document.getElementById('sbar'); |
| 47 | r.innerHTML = message ; |
47 | r.innerHTML = message ; |
| 48 | } |
48 | } |
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | 51 | ||
| 52 | function startGUI() { |
52 | function startGUI() { |
| 53 | // d3.select('html').style('height','100%'); |
53 | // d3.select('html').style('height','100%'); |
| 54 | // d3.select('body').style({'min-height':'100%', 'margin':'0px', "overflow" :"hidden"}); |
54 | // d3.select('body').style({'min-height':'100%', 'margin':'0px', "overflow" :"hidden"}); |
| 55 |
|
55 | // var r = document.getElementById('results'); |
| 56 |
|
56 | // r.style.display = 'none'; |
| 57 | var r0 = document.getElementById('sbar'); |
57 | var r0 = document.getElementById('sbar'); |
| 58 | r0.style.display = 'none'; |
58 | r0.style.display = 'none'; |
| 59 | 59 | ||
| 60 | } |
60 | } |
| 61 | 61 | ||
| 62 | 62 | ||
| - | 63 | function fitpanel(oFormElement) |
|
| - | 64 | { |
|
| - | 65 | var xhr = new XMLHttpRequest(); |
|
| - | 66 | xhr.onreadystatechange = function() { |
|
| - | 67 | if(xhr.readyState == 4 && xhr.status == 200) { |
|
| - | 68 | ||
| - | 69 | var event = JSON.parse(xhr.responseText); |
|
| - | 70 | var result =event.data; |
|
| - | 71 | var jsonobj = JSROOT.parse(result.message); |
|
| - | 72 | var sframe = jsonobj.fName; |
|
| - | 73 | var tf1 = jsonobj.fFunctions.arr[0]; |
|
| - | 74 | var tformula = tf1.fFormula; |
|
| - | 75 | var len = tf1.fNpar; |
|
| - | 76 | // addLog('#TF1 ' +JSON.stringify(tf1, null, '\t')+ '$$$<br>'); |
|
| - | 77 | mtext = '<br/>' + "Fit Function: " + tformula.fFormula+ '<br/>'; |
|
| - | 78 | mtext +="Chi2/NDF: " + tf1.fChisquare.toPrecision(2) + " / "+ tf1.fNDF+ '<br/>'; |
|
| - | 79 | mtext +='<table border="0" >'; |
|
| - | 80 | for ( var i = 0;i <len;i++){ |
|
| - | 81 | var name = tformula.fParams[i].first; |
|
| - | 82 | var val = tformula.fClingParameters[i]; |
|
| - | 83 | var err = tf1.fParErrors[i]; |
|
| - | 84 | mtext += "<tr><td>" + name + " <td> " + val.toPrecision(4) + " <td>+-<td>" + err.toPrecision(2) + '<br/>'; |
|
| 63 |
|
85 | } |
| - | 86 | mtext +="</table><br/>"; |
|
| - | 87 | var mdiv = document.getElementById('param' + sframe); |
|
| - | 88 | mdiv.innerHTML = mtext; |
|
| - | 89 | ||
| - | 90 | var r = document.getElementById('drawing'); |
|
| - | 91 | if (document.getElementById(sframe) == null ){ |
|
| - | 92 | r.insertAdjacentHTML('beforeend', '<div id="' + sframe +'" style="width:80%; height:80%;"></div><br/>'); |
|
| - | 93 | } |
|
| - | 94 | var frame = document.getElementById(sframe); |
|
| - | 95 | frame.innerHTML = ''; |
|
| - | 96 | JSROOT.draw(sframe, jsonobj, "hist"); |
|
| - | 97 | JSROOT.draw(sframe, jsonobj, "func"); |
|
| - | 98 | document.getElementById('data'+ sframe).value=result.message; |
|
| - | 99 | frame.scrollIntoView(); |
|
| - | 100 | } |
|
| - | 101 | } |
|
| - | 102 | xhr.open (oFormElement.method, oFormElement.action, true); |
|
| - | 103 | ||
| - | 104 | var data = new FormData (oFormElement); |
|
| - | 105 | xhr.send (data); |
|
| - | 106 | ||
| - | 107 | return false; // Markus had to return true |
|
| - | 108 | } |
|
| - | 109 | ||
| - | 110 | ||
| - | 111 | ||
| 64 | function startTask() { |
112 | function startTask() { |
| 65 | 113 | ||
| 66 | var r = document.getElementById('results'); |
114 | var r = document.getElementById('results'); |
| 67 | if ( r.style.display == 'none' ) switchTask(); |
115 | if ( r.style.display == 'none' ) switchTask(); |
| 68 | r.innerHTML = ''; |
116 | r.innerHTML = ''; |
| 69 | document.getElementById('drawing').innerHTML = ''; |
117 | document.getElementById('drawing').innerHTML = ''; |
| 70 | 118 | ||
| 71 | 119 | ||
| 72 | Blockly.JavaScript.INFINITE_LOOP_TRAP = null; |
120 | Blockly.JavaScript.INFINITE_LOOP_TRAP = null; |
| 73 | var code = Blockly.JavaScript.workspaceToCode(workspace); |
121 | var code = Blockly.JavaScript.workspaceToCode(workspace); |
| 74 | code = code.replace(/\(|\)/gi, ''); |
122 | code = code.replace(/\(|\)/gi, ''); |
| 75 | 123 | ||
| 76 | addLog(code + '<br>'); |
124 | addLog(code + '<br>'); |
| 77 | //addLog(JSON.stringify(code)+ '<br>'); |
125 | //addLog(JSON.stringify(code)+ '<br>'); |
| 78 | es = new EventSource('runscript.php?code=' + code ); |
126 | es = new EventSource('runscript.php?code=' + code ); |
| 79 | 127 | ||
| 80 | //a message is received |
128 | //a message is received |
| 81 | es.addEventListener('message',EventListener); |
129 | es.addEventListener('message',EventListener); |
| 82 | es.addEventListener('error', function(e) { |
130 | es.addEventListener('error', function(e) { |
| 83 | addLog('Error occurred'); |
131 | addLog('Error occurred'); |
| 84 | es.close(); |
132 | es.close(); |
| 85 | }); |
133 | }); |
| 86 | } |
134 | } |
| 87 | 135 | ||
| 88 | function EventListener(e) { |
136 | function EventListener(e) { |
| - | 137 | //addLog(JSON.stringify(e) ); |
|
| - | 138 | ||
| 89 | var result = JSON.parse( e.data ); |
139 | var result = JSON.parse( e.data ); |
| 90 | 140 | ||
| 91 | if(e.lastEventId == 'CLOSE') { |
141 | if(e.lastEventId == 'CLOSE') { |
| 92 | addLog('Received CLOSE closing'); |
142 | addLog('Received CLOSE closing'); |
| 93 | es.close(); |
143 | es.close(); |
| 94 | var pBar = document.getElementById('progressor'); |
144 | var pBar = document.getElementById('progressor'); |
| 95 | pBar.value = pBar.max; //max out the progress bar |
145 | pBar.value = pBar.max; //max out the progress bar |
| 96 | var perc = document.getElementById('percentage'); |
146 | var perc = document.getElementById('percentage'); |
| 97 | perc.innerHTML = "100%"; |
147 | perc.innerHTML = "100%"; |
| 98 | perc.style.width = (Math.floor(pBar.clientWidth * (0.5)) + 15) + 'px'; |
148 | perc.style.width = (Math.floor(pBar.clientWidth * (0.5)) + 15) + 'px'; |
| 99 | } else { |
149 | } else { |
| 100 | if(e.lastEventId == '0' ) { |
150 | if(e.lastEventId == '0' ) { |
| 101 | addLog(result.message); |
151 | addLog(result.message); |
| 102 | } else { |
152 | } else { |
| 103 | if(e.lastEventId == '2' ) { |
153 | if(e.lastEventId == '2' ) { |
| 104 | showStat(result.message); |
154 | showStat(result.message); |
| 105 | } else { |
155 | } else { |
| 106 | var jsonobj = JSROOT.parse(result.message); |
156 | var jsonobj = JSROOT.parse(result.message); |
| 107 | var sframe = |
157 | var sframe = jsonobj.fName; |
| - | 158 | ||
| - | 159 | ||
| 108 | addLog( |
160 | addLog('Histogram :'+ sframe ); |
| 109 |
|
161 | var r = document.getElementById('results'); |
| 110 |
|
162 | //var r = document.getElementById('drawing'); |
| - | 163 | if (document.getElementById(sframe) == null ){ |
|
| 111 | r.insertAdjacentHTML('beforeend' |
164 | r.insertAdjacentHTML('beforeend', '<div id="' + sframe +'" style="width:1000px; height:600px"></div><br/>'); |
| - | 165 | r.insertAdjacentHTML('beforeend', '<div id="fit' + sframe +'" style="display: none"></div><br/>'); |
|
| - | 166 | var fit = document.getElementById('fit'+ sframe); |
|
| - | 167 | mform ='<form method="post" action="th1fit.php" onsubmit="return fitpanel(this);">'; |
|
| - | 168 | mform += ' <input class="mybutton" type="submit" value=" Fit "/>'; |
|
| - | 169 | mform += ' Range: min=<input type="text" size="2" value="0" name="min" />'; |
|
| - | 170 | mform += ' max:<input type="text" size="2" value="10" name="max" />'; |
|
| - | 171 | mform += ' Function:<input type="text" size="5" value="gaus" name="fitfun" />'; |
|
| - | 172 | mform += ' Initial parameters<input type="text" size="5" value="1;2;3" name="prm" />'; |
|
| - | 173 | mform += ' <input id="data'+ sframe +'" type="hidden" value="'+ result.message +'" name="data" />'; |
|
| - | 174 | mform += ' <input type="hidden" value="'+ sframe +'" name="name" />'; |
|
| - | 175 | mform += '</form>'; |
|
| - | 176 | ||
| - | 177 | fit.insertAdjacentHTML('beforeend', mform); |
|
| - | 178 | fit.insertAdjacentHTML('beforeend', '<div id="param' + sframe +'"></div><br/>'); |
|
| - | 179 | r.insertAdjacentHTML('beforeend','<input type="button" onclick="togglevisibility(\'fit'+sframe+'\');" class="mybutton" value="Show/Hide Fit Panel" /><hr/>' ); |
|
| - | 180 | document.getElementById('data'+ sframe).value=result.message; |
|
| - | 181 | //r.insertAdjacentHTML('beforeend', JSON.stringify(result.message)); |
|
| 112 | 182 | } |
|
| 113 | var frame = document.getElementById(sframe); |
183 | var frame = document.getElementById(sframe); |
| 114 |
|
184 | |
| 115 | JSROOT. |
185 | JSROOT.redraw(sframe, jsonobj, "hist"); |
| 116 |
|
186 | |
| 117 | 187 | ||
| 118 | frame.scrollIntoView(); |
188 | frame.scrollIntoView(); |
| 119 | } |
189 | } |
| 120 | } |
190 | } |
| 121 | var pBar = document.getElementById('progressor'); |
191 | var pBar = document.getElementById('progressor'); |
| 122 | pBar.value = result.progress; |
192 | pBar.value = result.progress; |
| 123 | var perc = document.getElementById('percentage'); |
193 | var perc = document.getElementById('percentage'); |
| 124 | perc.innerHTML = result.progress + "%"; |
194 | perc.innerHTML = result.progress + "%"; |
| 125 | perc.style.width = (Math.floor(pBar.clientWidth * (result.progress/100)) + 15) + 'px'; |
195 | perc.style.width = (Math.floor(pBar.clientWidth * (result.progress/100)) + 15) + 'px'; |
| 126 | } |
196 | } |
| 127 | } |
197 | } |
| 128 | 198 | ||
| 129 | 199 | ||
| 130 | 200 | ||
| 131 | function stopTask() { |
201 | function stopTask() { |
| 132 | es.close(); |
202 | es.close(); |
| 133 | addLog('Interrupted'); |
203 | addLog('Interrupted'); |
| 134 | } |
204 | } |
| 135 | 205 | ||
| 136 | 206 | ||
| 137 | 207 | /* |
|
| 138 | function switchTask() { |
208 | function switchTask() { |
| 139 | var div = document.getElementById('results'); |
209 | var div = document.getElementById('results'); |
| 140 | var divs = document.getElementById('sbar'); |
210 | var divs = document.getElementById('sbar'); |
| 141 | var div0 = document.getElementById('blocklyDiv'); |
211 | var div0 = document.getElementById('blocklyDiv'); |
| 142 | 212 | ||
| 143 |
|
213 | if (div.style.display !== 'none') { |
| 144 | div.style.display = 'none'; |
214 | div.style.display = 'none'; |
| 145 | divs.style.display = 'none'; |
215 | divs.style.display = 'none'; |
| 146 | div0.style.display = 'block'; |
216 | div0.style.display = 'block'; |
| 147 |
|
217 | } |
| 148 |
|
218 | else { |
| 149 | div |
219 | div.style.display = 'block'; |
| 150 | divs.style.display = 'block'; |
220 | divs.style.display = 'block'; |
| 151 | div0.style.display = 'none'; |
221 | div0.style.display = 'none'; |
| 152 |
|
222 | } |
| 153 | 223 | ||
| 154 | } |
224 | } |
| - | 225 | */ |
|
| - | 226 | ||
| - | 227 | ||
| - | 228 | function togglevisibility( name ) { |
|
| - | 229 | var div = document.getElementById(name); |
|
| - | 230 | if (div.style.display !== 'none') { |
|
| - | 231 | div.style.display = 'none'; |
|
| - | 232 | } |
|
| - | 233 | else { |
|
| - | 234 | div.style.display = 'block'; |
|
| - | 235 | } |
|
| - | 236 | } |
|
| 155 | 237 | ||
| 156 | 238 | ||
| 157 | function readSingleFile(e) { |
239 | function readSingleFile(e) { |
| 158 | 240 | ||
| 159 | var div0 = document.getElementById('blocklyDiv'); |
241 | var div0 = document.getElementById('blocklyDiv'); |
| 160 |
|
242 | //if (div0.style.display === 'none') switchTask(); |
| 161 | 243 | ||
| 162 | var file = e.target.files[0]; |
244 | var file = e.target.files[0]; |
| 163 | if (!file) { |
245 | if (!file) { |
| 164 | return; |
246 | return; |
| 165 | } |
247 | } |
| 166 | var reader = new FileReader(); |
248 | var reader = new FileReader(); |
| 167 | reader.onload = function(e) { |
249 | reader.onload = function(e) { |
| 168 | var contents = e.target.result; |
250 | var contents = e.target.result; |
| 169 | displayContents(contents); |
251 | displayContents(contents); |
| 170 | 252 | ||
| 171 | }; |
253 | }; |
| 172 | reader.readAsText(file); |
254 | reader.readAsText(file); |
| 173 | 255 | ||
| 174 | } |
256 | } |
| 175 | 257 | ||
| 176 | function displayContents(contents) { |
258 | function displayContents(contents) { |
| 177 | 259 | ||
| 178 | workspace.clear(); |
260 | workspace.clear(); |
| 179 | var xml = Blockly.Xml.textToDom(contents); |
261 | var xml = Blockly.Xml.textToDom(contents); |
| 180 | Blockly.Xml.domToWorkspace(xml, workspace); |
262 | Blockly.Xml.domToWorkspace(xml, workspace); |
| 181 | 263 | ||
| 182 | } |
264 | } |
| 183 | 265 | ||
| 184 | 266 | ||
| 185 | function loadDoc( url ) { |
267 | function loadDoc( url ) { |
| 186 | var xhttp = new XMLHttpRequest(); |
268 | var xhttp = new XMLHttpRequest(); |
| 187 | xhttp.onreadystatechange = function () { |
269 | xhttp.onreadystatechange = function () { |
| 188 | if (xhttp.readyState == 4 && xhttp.status == 200) { |
270 | if (xhttp.readyState == 4 && xhttp.status == 200) { |
| 189 | return xhttp.responseText; |
271 | return xhttp.responseText; |
| 190 | } |
272 | } |
| 191 | } |
273 | } |
| 192 | xhttp.open("GET", url, false); // !!! should be in synchronous mode |
274 | xhttp.open("GET", url, false); // !!! should be in synchronous mode |
| 193 | xhttp.send(); |
275 | xhttp.send(); |
| 194 | return xhttp.onreadystatechange(); |
276 | return xhttp.onreadystatechange(); |
| 195 | } |
277 | } |
| 196 | 278 | ||
| 197 | function showCode() { |
279 | function showCode() { |
| 198 | // Generate JavaScript code and display it. |
280 | // Generate JavaScript code and display it. |
| 199 | Blockly.JavaScript.INFINITE_LOOP_TRAP = null; |
281 | Blockly.JavaScript.INFINITE_LOOP_TRAP = null; |
| 200 | var code = Blockly.JavaScript.workspaceToCode(workspace); |
282 | var code = Blockly.JavaScript.workspaceToCode(workspace); |
| 201 | //var code = Blockly.JSON.fromWorkspace( workspace ); |
283 | //var code = Blockly.JSON.fromWorkspace( workspace ); |
| 202 | //var code = Blockly.Xml.domToPrettyText(workspace ); |
284 | //var code = Blockly.Xml.domToPrettyText(workspace ); |
| 203 | code = code.replace(/\(|\)/gi, ''); |
285 | code = code.replace(/\(|\)/gi, ''); |
| 204 | console.log(code); |
286 | console.log(code); |
| 205 | console.log(code.length); |
287 | console.log(code.length); |
| 206 | alert(code); |
288 | alert(code); |
| 207 | 289 | ||
| 208 | } |
290 | } |
| 209 | 291 | ||
| 210 | 292 | ||
| 211 | function saveBlockly(){ |
293 | function saveBlockly(){ |
| 212 | // https://eligrey.com/blog/saving-generated-files-on-the-client-side/ |
294 | // https://eligrey.com/blog/saving-generated-files-on-the-client-side/ |
| 213 | 295 | ||
| 214 | var xml = Blockly.Xml.workspaceToDom(workspace); |
296 | var xml = Blockly.Xml.workspaceToDom(workspace); |
| 215 | var txt = Blockly.Xml.domToText(xml); |
297 | var txt = Blockly.Xml.domToText(xml); |
| 216 | 298 | ||
| 217 | // var txt=Blockly.Xml.domToPrettyText(Blockly.Xml.workspaceToDom(Blockly.mainWorkspace)); // exports workspace as pretty xml |
299 | // var txt=Blockly.Xml.domToPrettyText(Blockly.Xml.workspaceToDom(Blockly.mainWorkspace)); // exports workspace as pretty xml |
| 218 | console.log(txt); |
300 | console.log(txt); |
| 219 | var blob = new Blob([txt], {type: "text/xml"}); |
301 | var blob = new Blob([txt], {type: "text/xml"}); |
| 220 | saveAs(blob, "test.blab2"); |
302 | saveAs(blob, "test.blab2"); |
| 221 | } |
303 | } |
| 222 | 304 | ||
| 223 | function loadBlockly(){ |
305 | function loadBlockly(){ |
| 224 | Blockly.Xml.domToWorkspace(Blockly.mainWorkspace,$("#hiBlocks")[0]); // loads xml from dom into workspace |
306 | Blockly.Xml.domToWorkspace(Blockly.mainWorkspace,$("#hiBlocks")[0]); // loads xml from dom into workspace |
| 225 | } |
307 | } |
| 226 | 308 | ||
| 227 | function runCode() { |
309 | function runCode() { |
| 228 | // Generate JavaScript code and run it. |
310 | // Generate JavaScript code and run it. |
| 229 | window.LoopTrap = 1000; |
311 | window.LoopTrap = 1000; |
| 230 | Blockly.JavaScript.INFINITE_LOOP_TRAP = |
312 | Blockly.JavaScript.INFINITE_LOOP_TRAP = |
| 231 | 'if (--window.LoopTrap == 0) throw "Infinite loop.";\n'; |
313 | 'if (--window.LoopTrap == 0) throw "Infinite loop.";\n'; |
| 232 | var code = Blockly.JavaScript.workspaceToCode(workspace); |
314 | var code = Blockly.JavaScript.workspaceToCode(workspace); |
| 233 | Blockly.JavaScript.INFINITE_LOOP_TRAP = null; |
315 | Blockly.JavaScript.INFINITE_LOOP_TRAP = null; |
| 234 | try { |
316 | try { |
| 235 | eval(code); |
317 | eval(code); |
| 236 | } catch (e) { |
318 | } catch (e) { |
| 237 | alert(e); |
319 | alert(e); |
| 238 | } |
320 | } |
| 239 | } |
321 | } |
| 240 | 322 | ||
| 241 | - | ||
| 242 | - | ||
| 243 | - | ||
| 244 | - | ||
| 245 | 323 | ||
| 246 | </script> |
324 | </script> |
| 247 | 325 | ||
| 248 | </head> |
326 | </head> |
| 249 | <body> |
327 | <body> |
| 250 | <h1>Belle II Masterclass: |
328 | <h1>Belle II Masterclass: Describe process →Run analysis →Fit results →Save/load process locally</h1> |
| 251 | <!-- <input type="button" onclick="showCode();" class="mybutton" value="Show JavaScript" /> --> |
329 | <!-- <input type="button" onclick="showCode();" class="mybutton" value="Show JavaScript" /> --> |
| 252 | <input type="button" onclick="startTask();" class="mybutton" value="Run Analysis" /> |
330 | <input type="button" onclick="startTask();" class="mybutton" value="Run Analysis" /> |
| 253 | <input type="button" onclick="stopTask();" class="mybutton" value="Interrupt" /> |
331 | <input type="button" onclick="stopTask();" class="mybutton" value="Interrupt" /> |
| 254 |
|
332 | <!-- <input type="button" onclick="switchTask();" class="mybutton" value="Switch between Diagram and Results" /> --> |
| 255 | <input type="button" onclick="saveBlockly();" class="mybutton" value="Save Diagram" /> |
333 | <input type="button" onclick="saveBlockly();" class="mybutton" value="Save Diagram" /> |
| 256 | <form style="display:inline;"><label for="file-input" class="mybutton" style="">Load Diagram</label> |
334 | <form style="display:inline;"><label for="file-input" class="mybutton" style="">Load Diagram</label> |
| 257 |
|
335 | <input type="file" style="visibility:hidden;" id="file-input" onClick="this.form.reset()" data-buttonText="Load Diagram"/></form> |
| 258 | <br |
336 | <br/> |
| 259 | - | ||
| 260 | - | ||
| 261 | - | ||
| 262 | <progress id='progressor' value="0" max='100' style="width:95%"></progress> |
337 | <progress id='progressor' value="0" max='100' style="width:95%"></progress> |
| 263 | <span id="percentage" style="text-align:right; display:block; margin-top:5px;">0</span> |
338 | <span id="percentage" style="text-align:right; display:block; margin-top:5px;">0</span> |
| 264 | <p id="sbar" ></div> |
339 | <p id="sbar" ></div> |
| 265 | 340 | ||
| 266 | - | ||
| 267 | <br /> |
341 | <br /> |
| 268 | 342 | ||
| 269 | <div id="blocklyDiv" style="height:500px; width:95%"></div><br /> |
343 | <div id="blocklyDiv" style="height:500px; width:95%"></div><br /> |
| 270 | <div id="results" style="border:1px solid #000; padding:10px; width:95%; height:80% ; overflow:auto; background:#eee;"></div> |
344 | <div id="results" style="border:1px solid #000; padding:10px; width:95%; height:80% ; overflow:auto; background:#eee;"></div> |
| 271 | <br /> |
345 | <br /> |
| 272 | 346 | ||
| 273 | <script> |
347 | <script> |
| 274 | 348 | ||
| 275 | document.getElementById('file-input').addEventListener('change', readSingleFile, false); |
349 | document.getElementById('file-input').addEventListener('change', readSingleFile, false); |
| 276 | 350 | ||
| 277 | // var toolbox = document.getElementById("toolbox"); |
351 | // var toolbox = document.getElementById("toolbox"); |
| 278 | var toolbox = loadDoc("toolbox.xml"); |
352 | var toolbox = loadDoc("toolbox.xml"); |
| 279 | 353 | ||
| 280 | var options = { |
354 | var options = { |
| 281 | toolbox : toolbox, |
355 | toolbox : toolbox, |
| 282 | collapse : true, |
356 | collapse : true, |
| 283 | comments : true, |
357 | comments : true, |
| 284 | disable : true, |
358 | disable : true, |
| 285 | maxBlocks : Infinity, |
359 | maxBlocks : Infinity, |
| 286 | trashcan : true, |
360 | trashcan : true, |
| 287 | horizontalLayout : false, |
361 | horizontalLayout : false, |
| 288 | toolboxPosition : 'start', |
362 | toolboxPosition : 'start', |
| 289 | css : true, |
363 | css : true, |
| 290 | /* media : '../media/', */ |
364 | /* media : '../media/', */ |
| 291 | rtl : false, |
365 | rtl : false, |
| 292 | scrollbars : true, |
366 | scrollbars : true, |
| 293 | sounds : true, |
367 | sounds : true, |
| 294 | oneBasedIndex : true, |
368 | oneBasedIndex : true, |
| 295 | zoom : { |
369 | zoom : { |
| 296 | controls : true, |
370 | controls : true, |
| 297 | wheel : true, |
371 | wheel : true, |
| 298 | startScale : 1, |
372 | startScale : 1, |
| 299 | maxcale : 3, |
373 | maxcale : 3, |
| 300 | minScale : 0.3 |
374 | minScale : 0.3 |
| 301 | }, |
375 | }, |
| 302 | grid: |
376 | grid: |
| 303 | {spacing: 20, |
377 | {spacing: 20, |
| 304 | length: 3, |
378 | length: 3, |
| 305 | colour: '#ccc', |
379 | colour: '#ccc', |
| 306 | snap: true} |
380 | snap: true} |
| 307 | }; |
381 | }; |
| 308 | 382 | ||
| 309 | /* Inject your workspace */ |
383 | /* Inject your workspace */ |
| 310 | var workspace = Blockly.inject('blocklyDiv', options); |
384 | var workspace = Blockly.inject('blocklyDiv', options); |
| 311 | 385 | ||
| 312 | /* Load Workspace Blocks from XML to workspace. Remove all code below if no blocks to load */ |
386 | /* Load Workspace Blocks from XML to workspace. Remove all code below if no blocks to load */ |
| 313 | 387 | ||
| 314 | /* TODO: Change workspace blocks XML ID if necessary. Can export workspace blocks XML from Workspace Factory. */ |
388 | /* TODO: Change workspace blocks XML ID if necessary. Can export workspace blocks XML from Workspace Factory. */ |
| 315 | //var workspaceBlocks = document.getElementById("workspaceBlocks"); |
389 | //var workspaceBlocks = document.getElementById("workspaceBlocks"); |
| 316 | /* Load blocks to workspace. */ |
390 | /* Load blocks to workspace. */ |
| 317 | // Blockly.Xml.domToWorkspace(workspaceBlocks, workspace); |
391 | // Blockly.Xml.domToWorkspace(workspaceBlocks, workspace); |
| 318 | 392 | ||
| 319 | <?php |
393 | <?php |
| 320 | 394 | ||
| 321 | if (isset($_GET["decay"])){ |
395 | if (isset($_GET["decay"])){ |
| 322 | $decay = $_GET["decay"]; |
396 | $decay = $_GET["decay"]; |
| 323 | } else { |
397 | } else { |
| 324 | $decay = "data/sample.blab2"; |
398 | $decay = "data/sample.blab2"; |
| 325 | } |
399 | } |
| 326 | // echo "var workspaceBlocks = loadDoc( \"$decay\");" |
400 | // echo "var workspaceBlocks = loadDoc( \"$decay\");" |
| 327 | /* Load blocks to workspace. */ |
401 | /* Load blocks to workspace. */ |
| 328 | echo "displayContents( loadDoc( \"$decay\"));" |
402 | echo "displayContents( loadDoc( \"$decay\"));" |
| 329 | 403 | ||
| 330 | ?> |
404 | ?> |
| 331 | 405 | ||
| 332 | //displayContents(workspaceBlocks); |
406 | //displayContents(workspaceBlocks); |
| 333 | 407 | ||
| 334 | 408 | ||
| 335 | 409 | ||
| 336 | </script> |
410 | </script> |
| 337 | <div id="drawing |
411 | <div id="drawing"></div> |
| 338 | </body> |
412 | </body> |
| 339 | </html> |
413 | </html> |
| 340 | 414 | ||