summaryrefslogtreecommitdiffstats
path: root/modules-available/sysconfig/clientscript.js
blob: c86b8148f8f156a7d9a2532f15e5a187238bba1d (plain) (blame)
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

// Mouseover and clicking

var boldItem = false;

function showmod(e, action) {
    var list = $(e).attr('data-modlist');
    list = list.split(',');
    if (action === 'bold') {
        $(boldItem).removeClass("slx-bold");
        if (boldItem === e) {
            action = 'fade';
            boldItem = false;
        }
    } else if (boldItem !== false) {
        return;
    }
    $('.modrow').each(function () {
        var elem = $(this);
        elem.removeClass("slx-fade slx-bold");
        if (action === 'reset')
            return;
        if (action === 'bold' && list.indexOf(elem.attr('data-id')) !== -1)
            elem.addClass("slx-bold");
        if (list.indexOf(elem.attr('data-id')) === -1)
            elem.addClass("slx-fade");
    });
    if (action === 'bold') {
        boldItem = e;
        $(e).addClass("slx-bold");
    }
}

// Polling for updated status (outdated, missing, ok)

var statusChecks = 0;

function checkBuildStatus() {
    var mods = [];
    var confs = [];
    $(".refmod.btn-primary").each(function (index) {
        mods.push($(this).val());
    });
    $(".refconf.btn-primary").each(function (index) {
        confs.push($(this).val());
    });
    if (mods.length === 0 && confs.length === 0) return;
    if (++statusChecks < 10) setTimeout(checkBuildStatus, 200 + 50 * statusChecks);
    $.post('?do=SysConfig', { mods: mods.join(), confs: confs.join(), token: TOKEN, action: 'status' }, function (data) {
        if (typeof data === 'undefined') return;
        if (typeof data.mods === 'object') updateButtonColor($(".refmod.btn-primary"), data.mods);
        if (typeof data.confs === 'object') updateButtonColor($(".refconf.btn-primary"), data.confs);
    }, 'json');
}

function updateButtonColor(list,ids) {
    list.each(function() {
        if (ids.indexOf($(this).val()) >= 0) $(this).removeClass('btn-primary').addClass('btn-default');
    });
}