Rev 275 | Rev 318 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 275 | Rev 302 | ||
---|---|---|---|
Line 98... | Line 98... | ||
98 | function startTask() { |
98 | function startTask() { |
99 | 99 | ||
100 | var r = document.getElementById('results'); |
100 | var r = document.getElementById('results'); |
101 | if ( r.style.display == 'none' ) switchTask(); |
101 | if ( r.style.display == 'none' ) switchTask(); |
102 | r.innerHTML = ''; |
102 | r.innerHTML = ''; |
- | 103 | var btnstart = document.getElementById('btnstart'); |
|
- | 104 | btnstart.value= "Stop Analysis"; |
|
- | 105 | ||
- | 106 | ||
103 | document.getElementById('drawing').innerHTML = ''; |
107 | document.getElementById('drawing').innerHTML = ''; |
104 | - | ||
105 | 108 | ||
106 | Blockly.JavaScript.INFINITE_LOOP_TRAP = null; |
109 | Blockly.JavaScript.INFINITE_LOOP_TRAP = null; |
107 | var code = Blockly.JavaScript.workspaceToCode(workspace); |
110 | var code = Blockly.JavaScript.workspaceToCode(workspace); |
108 | code = code.replace(/\(|\)/gi, ''); |
111 | code = code.replace(/\(|\)/gi, ''); |
109 | 112 | ||
Line 113... | Line 116... | ||
113 | 116 | ||
114 | //a message is received |
117 | //a message is received |
115 | es.addEventListener('message',EventListener); |
118 | es.addEventListener('message',EventListener); |
116 | es.addEventListener('error', function(e) { |
119 | es.addEventListener('error', function(e) { |
117 | addLog('Error occurred'); |
120 | addLog('Error occurred'); |
- | 121 | stopTask(); |
|
118 | es |
122 | //es.close(); |
119 | }); |
123 | }); |
120 | } |
124 | } |
121 | 125 | ||
- | 126 | function startAction() { |
|
- | 127 | var btnstart = document.getElementById('btnstart'); |
|
- | 128 | if (btnstart.value=== "Stop Analysis"){ |
|
- | 129 | stopTask(); |
|
- | 130 | } else { |
|
- | 131 | startTask(); |
|
- | 132 | } |
|
- | 133 | } |
|
122 | function EventListener(e) { |
134 | function EventListener(e) { |
123 | //addLog(JSON.stringify(e) ); |
135 | //addLog(JSON.stringify(e) ); |
124 | 136 | ||
125 | var result = JSON.parse( e.data ); |
137 | var result = JSON.parse( e.data ); |
126 | 138 | ||
127 | if(e.lastEventId == 'CLOSE') { |
139 | if(e.lastEventId == 'CLOSE') { |
128 | addLog('Received CLOSE closing'); |
140 | addLog('Received CLOSE closing'); |
- | 141 | stopTask(); |
|
129 |
|
142 | // es.close(); |
- | 143 | ||
130 | var pBar = document.getElementById('progressor'); |
144 | var pBar = document.getElementById('progressor'); |
131 | pBar.value = pBar.max; //max out the progress bar |
145 | pBar.value = pBar.max; //max out the progress bar |
132 | var perc = document.getElementById('percentage'); |
146 | var perc = document.getElementById('percentage'); |
133 | perc.innerHTML = "100%"; |
147 | perc.innerHTML = "100%"; |
134 | perc.style.width = (Math.floor(pBar.clientWidth * (0.5)) + 15) + 'px'; |
148 | perc.style.width = (Math.floor(pBar.clientWidth * (0.5)) + 15) + 'px'; |
Line 183... | Line 197... | ||
183 | 197 | ||
184 | 198 | ||
185 | 199 | ||
186 | function stopTask() { |
200 | function stopTask() { |
187 | es.close(); |
201 | es.close(); |
188 | addLog( |
202 | addLog('Task end'); |
- | 203 | var btnstart = document.getElementById('btnstart'); |
|
- | 204 | ||
- | 205 | btnstart.value= "Run Analysis"; |
|
- | 206 | ||
189 | } |
207 | } |
190 | 208 | ||
191 | 209 | ||
192 | /* |
210 | /* |
193 | function switchTask() { |
211 | function switchTask() { |
Line 310... | Line 328... | ||
310 | 328 | ||
311 | </head> |
329 | </head> |
312 | <body> |
330 | <body> |
313 | <h1>Belle II Masterclass: Describe process →Run analysis →Fit results →Save/load process locally</h1> |
331 | <h1>Belle II Masterclass: Describe process →Run analysis →Fit results →Save/load process locally</h1> |
314 | <!-- <input type="button" onclick="showCode();" class="mybutton" value="Show JavaScript" /> --> |
332 | <!-- <input type="button" onclick="showCode();" class="mybutton" value="Show JavaScript" /> --> |
315 | <input type="button" onclick=" |
333 | <input type="button" id="btnstart" onclick="startAction();" class="mybutton" value="Run Analysis" /> |
316 | <input type="button" onclick="stopTask();" class="mybutton" value="Interrupt" /> |
- | |
- | 334 | ||
317 | <!-- <input type="button" onclick="switchTask();" class="mybutton" value="Switch between Diagram and Results" /> --> |
335 | <!-- <input type="button" onclick="switchTask();" class="mybutton" value="Switch between Diagram and Results" /> --> |
318 | <input type="button" onclick="saveBlockly();" class="mybutton" value="Save Diagram" /> |
336 | <input type="button" onclick="saveBlockly();" class="mybutton" value="Save Diagram" /> |
319 | <form style="display:inline;"><label for="file-input" class="mybutton" style="">Load Diagram</label> |
337 | <form style="display:inline;"><label for="file-input" class="mybutton" style="">Load Diagram</label> |
320 | <input type="file" style="visibility:hidden;" id="file-input" onClick="this.form.reset()" data-buttonText="Load Diagram"/></form> |
338 | <input type="file" style="visibility:hidden;" id="file-input" onClick="this.form.reset()" data-buttonText="Load Diagram"/></form> |
321 | <br/> |
339 | <br/> |