Passed
Push — master ( e44814...88e81d )
by Andreas
21:13
created

static/midcom.admin.rcs/rcs.js   A

Complexity

Total Complexity 6
Complexity/F 2

Size

Lines of Code 25
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 13
mnd 3
bc 3
fnc 3
dl 0
loc 25
rs 10
bpm 1
cpm 2
noi 0
c 0
b 0
f 0
1
function init_controls() 
2
{
3
    const form = $('form[name="midcom_admin_rcs_history"]');
4
    
5
    if (form.find('tbody').children().length < 2) {
6
        form.find('[name="first"], [name="last"], [name="f_compare"]').css('visibility', 'hidden');
7
        return;
8
    }
9
    
10
    if (form.find('[name="first"]:checked').length === 0) {
11
        form.find('[name="first"]').eq(0).trigger('click');
12
    }
13
    
14
    if (form.find('[name="last"]:checked').length === 0) {
15
        form.find('[name="last"]').eq(1).trigger('click');
16
    }
17
18
    form.on('change', '[name="first"]', function() {
19
        $('[name="f_compare"]').prop('disabled', $(this).val() == $('[name="last"]:checked').val());
20
    });
21
    
22
    form.on('change', '[name="last"]', function() {
23
        $('[name="f_compare"]').prop('disabled', $(this).val() == $('[name="first"]:checked').val());
24
    });
25
}