aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/cmd/tools/fast/fast_main.js
blob: d6b2d19461bef108faa5aaf41a998b3121a6e9d7 (plain)
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
const delta = 18;

(function () {
    var table = document.querySelector("table");
    var isTbody = table.children[0].nodeName == "TBODY";
    var trs = isTbody
        ? table.children[0].querySelectorAll("tr")
        : table.querySelectorAll("tr");
    trs.forEach(function (tr, idx) {
        if (idx != 0 && idx + 1 < trs.length) {
            var vc = 3, vv = 4, vf = 5, vh = 6;
            var textContent = {
                vc: tr.children[vc].textContent,
                vv: tr.children[vv].textContent,
                vf: tr.children[vf].textContent,
                vh: tr.children[vh].textContent
            };
            var currentData = {
                vc: int(textContent.vc.slice(0, -2)),
                vv: int(textContent.vv.slice(0, -2)),
                vf: int(textContent.vf.slice(0, -2)),
                vh: int(textContent.vh.slice(0, -2))
            };
            var prevData = {
                vc: int(trs[idx + 1].children[vc].textContent.slice(0, -2)),
                vv: int(trs[idx + 1].children[vv].textContent.slice(0, -2)),
                vf: int(trs[idx + 1].children[vf].textContent.slice(0, -2)),
                vh: int(trs[idx + 1].children[vh].textContent.slice(0, -2))
            };
            var result = {
                vc: currentData.vc - prevData.vc,
                vv: currentData.vv - prevData.vv,
                vf: currentData.vf - prevData.vf,
                vh: currentData.vh - prevData.vh
            };
            if (Math.abs(result.vc) > delta)
                tr.children[vc].appendChild(createElement(result.vc));
            if (Math.abs(result.vv) > delta * 2)
                tr.children[vv].appendChild(createElement(result.vv));
            if (Math.abs(result.vf) > delta * 2)
                tr.children[vf].appendChild(createElement(result.vf));
            if (Math.abs(result.vh) > delta * 2)
                tr.children[vh].appendChild(createElement(result.vh));
        }
    });
    function int(src) {
        return src - 0;
    }
    function getClassName(x) {
        if (x == 0)
            return "equal";
        return x < 0 ? "plus" : "minus";
    }
    function createElement(result) {
        var el = document.createElement("span");
        var parsedResult = parseResult(result);
        el.classList.add("diff");
        el.classList.add(getClassName(result));
        el.textContent = parsedResult;
        return el;
    }
    function parseResult(x) {
        if (x == 0)
            return "0";
        return x > 0 ? "+" + x : x;
    }
})();