Code
·
75 lines
·
1352 bytes
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
var arr = [
"algorithm",
"bandwidth",
"cache",
"database",
"encryption",
"firewall",
"gateway",
"hash",
"interface",
"kernel",
"latency",
"metadata",
"network",
"packet",
"protocol",
"query",
"runtime",
"server",
"throughput",
"virtualization",
"authentication",
"bitrate",
"cloud",
"compression",
"container",
"cpu",
"datagram",
"endpoint",
"firmware",
"frame",
"hashrate",
"hypervisor",
"index",
"jitter",
"load",
"middleware",
"port",
"queue",
"socket",
"thread"
];
arr.forEach((woord, index) =>
{
if (Math.random() < 0.5)
addMeter(50.0, woord, 0.0, 100.0);
else
addMeter(0.0, woord, -1.0, 1.0);
});
function randomUpdateMeter(meterId)
{
if (Math.random() < 0.01)
{ // 10% chance
const canvas = document.getElementById(meterId);
if (!canvas) return;
const currentValue = parseFloat(canvas.dataset.currentValue) || 0;
const minValue = parseFloat(canvas.dataset.minValue);
const maxValue = parseFloat(canvas.dataset.maxValue);
const change = (Math.random() - 0.5) * (maxValue / 2.0);
const newValue = Math.max(minValue, Math.min(maxValue, currentValue + change));
updateMeter(meterId, newValue);
}
}
function startRandomUpdateTimers()
{
for (let i = 0; i < arr.length; i++)
{
setInterval(() => { randomUpdateMeter(`meter${1 + i}`); }, 100);
}
}
startRandomUpdateTimers();