-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathupdate_draw.htm
67 lines (50 loc) · 2.08 KB
/
update_draw.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Demonstrator of online usage of JSROOT</title>
<link rel="shortcut icon" href="../img/RootIcon.ico"/>
<style>
html {
height: 100%;
}
body {
min-height: 100%;
margin: 0px;
overflow: hidden;
}
</style>
</head>
<body>
<div id="drawing" style="position: absolute; inset: 1px;"></div>
</body>
<script type='module'>
import { httpRequest, redraw, decodeUrl, registerForResize, GridDisplay } from '../modules/main.mjs';
let mdi = null, cnt = 0, drawopt = null, addr = null;
function updateGUI() {
// here set of generated json files are used
// One could specify addres of running THttpServer like http://localhost:8080/Canvases/c1/root.json.gz?compact=23
// Or one can create root.json file in the application and place it on the webserver
// To run demo, one should generate rootXX.json files using demo.C macro
let request_addr = addr || `root${cnt % 20}.json`,
request_count = cnt++;
httpRequest(request_addr, 'object').then(histo => {
// when use grid layout, use counter value stored in request itself
let frame = mdi ? mdi.findFrame(`item${request_count % mdi.numGridFrames()}`, true) : 'drawing';
// redraw histogram at specified frame
redraw(frame, histo, drawopt).then(() => {
// let adjust drawing when browser will be resized
if (!request_count) registerForResize('drawing');
});
}).catch(() => { document.getElementById('drawing').innerHTML = `"<h3>Can not get ${request_addr} from the server</h3>`;});
}
let d = decodeUrl();
let monitor = parseInt(d.get('monitoring') || '1000');
drawopt = d.get('opt');
addr = d.get('addr');
let layout = d.get('layout');
if (layout)
mdi = new GridDisplay('drawing', layout);
setInterval(updateGUI, monitor);
</script>
</html>