summaryrefslogtreecommitdiffstats
path: root/web/changesummary/main.js
blob: 03f8c668def1bb946b53e75e9bef88cec650d91c (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
function updateMainTable() {
    var pctTag = $("#primary_change_type option:selected").attr("tag");
    var sctTag = $("#secondary_change_type option:selected").attr("tag");
    var pmtTag =
        ($("#incl_premature_changes:checked").length == 1) ? "_pmt" : "";
    var divName = "div_mt_" + pctTag + "_" + sctTag + pmtTag;

    // Hide all main tables but the current one:
    $('div[id^="div_mt_"]').css("display", "none");
    $("#" + divName).css("display", "block");
}

function updateRankingTarget() {
    var pctName =
        $("#primary_change_type option:selected").attr("singular_name");

    $("#last_change").text("Most recent " + pctName);
    $("#max_change_last_week").text("Strongest " + pctName + " last week");
    $("#max_change_last_month").text("Strongest " + pctName + " last month");
    $("#max_change_last_6_months").text(
        "Strongest " + pctName + " last six months");
    $("#max_change_ever").text("Strongest " + pctName + " ever");

    $("#incl_premature_changes_label").text(
        "Include premature " + pctName + "s");

    updateMainTable();
}

function initMainTable(tableSel) {

    $(tableSel).tablesorter({
        headers: {
            3: { sorter: "mixed_numeric_desc_before_missing" }, // rank pos 0
            4: { sorter: false }, // 1
            5: { sorter: false }, // 2
            6: { sorter: false }, // 3
            7: { sorter: false }, // 4
            8: { sorter: false }, // 5
            9: { sorter: false }, // 6
            10: { sorter: false }, // 7
            11: { sorter: false }, // 8
            12: { sorter: false } // 9
        }
    });

    // // Note: The nth-child selector below uses 1-based indexing!
    // setTooltip($(tableSel).find("th:nth-child(2)"), tooltipText_ms());
    // setTooltip($(tableSel).find("th:nth-child(3)"), tooltipText_lsd());
    // setTooltip($(tableSel).find("th:nth-child(4)"), tooltipText_ni());
    // setTooltip($(tableSel).find("th:nth-child(5)"), tooltipText_nz());
    // setTooltip($(tableSel).find("th:nth-child(6)"), tooltipText_nc());
    // setTooltip($(tableSel).find("th:nth-child(7)"), tooltipText_mdrse());
    // setTooltip($(tableSel).find("th:nth-child(8)"), tooltipText_rsemd());
    // setTooltip($(tableSel).find("th:nth-child(9)"), tooltipText_qs());
    // setTooltip($(tableSel).find("th:nth-child(10)"), tooltipText_lc());
    // setTooltip($(tableSel).find("th:nth-child(11)"), tooltipText_lcda());
    // setTooltip($(tableSel).find("th:nth-child(12)"), tooltipText_lcms());
    // setTooltip($(tableSel).find("th:nth-child(13)"), tooltipText_lcss());
    // setTooltip($(tableSel).find("th:nth-child(14)"), tooltipText_lcss1());
    // setTooltip($(tableSel).find("th:nth-child(15)"), tooltipText_lcgss());
    // setTooltip($(tableSel).find("th:nth-child(16)"), tooltipText_lclss());
    // setTooltip($(tableSel).find("th:nth-child(17)"), tooltipText_lcds1());
    // setTooltip($(tableSel).find("th:nth-child(18)"), tooltipText_lcds2());

    // $(tableSel).bind("sortStart",function() {
    //     $("#pbmTable_sortInProgress").show();
    // }).bind("sortEnd",function() {
    //     $("#pbmTable_sortInProgress").hide();
    // });
}

$(document).ready(function() {

    initTablesorter();

    // Initialize all main tables:
    $('table[id^="mt_"]').each(function() {
        initMainTable("#" + $(this).attr("id"));
    });

    // Initialize ranking target:
    $("#primary_change_type option[singular_name='regression']").attr(
        "selected", true);
    $("#incl_premature_changes").attr("checked", false)
    updateRankingTarget();

    fetchContexts();
});