-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
80 lines (74 loc) · 3.04 KB
/
index.html
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
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
</head>
<body>
<div>
<label>
requestChunkSize <input type="text" id="requestChunkSize" value="1024"/>
</label>
</div>
<div>
<label>
LRUSize: <input type="text" id="LRUSize" value="100" />
</label>
</div>
<div>
<label>File URL:
<input type="text" id="file_url" style="width:60em;" value="https://ncnr.nist.gov/pub/ncnrdata/candor/201909/nonims1/data/encoder_check218.nxs.cdr?gzip=false" />
</label>
<button id="load">load</button>
</div>
<div>
<label>Path:
<input type="text" id="path" style="width:40em;" value="/">
<button id="get">get</button>
</label>
</div>
<pre id="results" style="overflow-y:scroll;"></pre>
<script type="module">
var worker;
if (window && window.Worker) {
// worker = new Worker("./dist/adv_worker.mjs", { type : 'module' } );
worker = new Worker("./dist/adv_worker.js");
worker.addEventListener("message", function(event) {
console.log("EVENT:", event);
let results_el = document.getElementById("results");
results_el.innerHTML = "";
const result_text = JSON.stringify(event.data, (k,v) => {
if (typeof v === 'bigint') {
return v.toString();
}
else if (ArrayBuffer.isView(v)) {
return [...v];
}
return v;
}, 2);
results_el.innerText = result_text;
})
} else {
console.log("Workers are not supported");
}
document.getElementById("load").onclick = function() {
let url = document.getElementById("file_url").value;
let LRUSize = parseInt(document.getElementById("LRUSize").value, 10);
let requestChunkSize = parseInt(document.getElementById("requestChunkSize").value, 10);
worker.postMessage({action: "load", payload: {url, LRUSize, requestChunkSize}});
}
function getter(payload={path: "entry"}) {
worker.postMessage({action: "get", payload});
}
document.getElementById("get").onclick = async function() {
let path = document.getElementById("path").value;
getter({path});
}
window.getter = getter;
</script>
</body>
</html>