|
3 | 3 | <head> |
4 | 4 | <meta charset="utf-8"> |
5 | 5 | <title>RWebWindow latency test</title> |
6 | | - <script src="jsrootsys/scripts/JSRoot.core.js" type="text/javascript"></script> |
7 | 6 | </head> |
8 | 7 |
|
9 | 8 | <body> |
10 | | - <button onclick="SendMsg('halt')">Halt</button> |
11 | | - <button onclick="ToggleDrawing()">Draw</button> |
| 9 | + <button id="halt_btn">Halt</button> |
| 10 | + <button id="toggle_btn">Draw</button> |
12 | 11 | <p>Main: <b id="output">Msg</b></p> |
13 | 12 | <div id="clients"></div> |
14 | 13 | <div id="draw" style="position: absolute; left: 0px; right: 0px; bottom: 0px; height: 50%; overflow:hidden"></div> |
15 | 14 | </body> |
16 | 15 |
|
17 | | - <script> |
| 16 | + <script type="module"> |
| 17 | + |
| 18 | + import { connectWebWindow } from '/jsrootsys/modules/webwindow.mjs'; |
| 19 | + |
| 20 | + import { redraw, cleanup } from '/jsrootsys/modules/draw.mjs'; |
| 21 | + |
| 22 | + import { createHistogram } from '/jsrootsys/modules/core.mjs'; |
18 | 23 |
|
19 | 24 | class PingPongHandler { |
20 | 25 | constructor(is_main, out_id) { |
|
83 | 88 | } |
84 | 89 |
|
85 | 90 | if (this.is_main && this.hist) |
86 | | - JSROOT.redraw("draw", this.hist); |
| 91 | + redraw("draw", this.hist); |
87 | 92 |
|
88 | 93 | }, msec); |
89 | 94 | } |
|
157 | 162 | for (let n = 0; n < nclients; ++n) { |
158 | 163 | let sub_handler = new PingPongHandler(false, "out" + n); |
159 | 164 | sub_handler.cnt = 10000*(n+1); |
160 | | - JSROOT.connectWebWindow( { receiver: sub_handler, socket_kind: this.handle.kind } ); |
| 165 | + connectWebWindow( { receiver: sub_handler, socket_kind: this.handle.kind } ); |
161 | 166 | this.clients.push(sub_handler); |
162 | 167 | } |
163 | 168 | } |
164 | 169 |
|
165 | 170 | createHistogram() { |
166 | 171 | let mean = this.sum[0] > 10 ? this.sum[1] / this.sum[0] : 50; |
167 | 172 |
|
168 | | - this.hist = JSROOT.createHistogram("TH1I", 100); |
| 173 | + this.hist = createHistogram("TH1I", 100); |
169 | 174 | this.hist.fTitle = "Roundtrip time"; |
170 | 175 | this.hist.fXaxis.fTitle = "ms"; |
171 | 176 | this.hist.fXaxis.fXmax = 100; |
|
183 | 188 |
|
184 | 189 | let main_handler = new PingPongHandler(true); |
185 | 190 |
|
186 | | - function SendMsg(txt) { |
| 191 | + document.getElementById('halt_btn').onclick = () => { |
187 | 192 | if (main_handler && main_handler.handle) |
188 | | - main_handler.handle.send(txt); |
189 | | - } |
| 193 | + main_handler.handle.send('halt'); |
| 194 | + }; |
| 195 | + |
| 196 | + document.getElementById('toggle_btn').onclick = () => { |
190 | 197 |
|
191 | | - function ToggleDrawing() { |
192 | 198 | let draw = document.getElementById("draw"); |
193 | 199 | if (!draw) return; |
194 | 200 |
|
195 | 201 | if (main_handler.hist) { |
196 | | - JSROOT.cleanup(draw); |
| 202 | + cleanup(draw); |
197 | 203 | main_handler.clearHistogram(); |
198 | 204 | draw.style.display = "none"; |
199 | 205 | return; |
200 | 206 | } |
201 | 207 |
|
202 | 208 | main_handler.createHistogram(); |
203 | 209 | draw.style.display = ""; |
204 | | - } |
| 210 | + }; |
205 | 211 |
|
206 | 212 | // important this line, which need to be specially handled |
207 | 213 | // line MUST always end with "({" symbols |
208 | | - JSROOT.connectWebWindow({ |
| 214 | + connectWebWindow({ |
209 | 215 | receiver: main_handler |
210 | 216 | }); |
211 | 217 |
|
|
0 commit comments