public/menus.js   A
last analyzed

Complexity

Total Complexity 6
Complexity/F 1.5

Size

Lines of Code 27
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 18
c 0
b 0
f 0
dl 0
loc 27
rs 10
wmc 6
mnd 2
bc 2
fnc 4
bpm 0.5
cpm 1.5
noi 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A menus.js ➔ menus 0 13 3
1
let except = $('#js-response').data('except'),
2
    ancestors = JSON.parse("[" + $('#js-response').data('ancestors') + "]");
3
4
function menus(element) {
5
    let parent_id = element.val() || 0,
6
        parentCount = $('select.parent').length,
7
        target = element.data('target'),
8
        url = baseUrl() + 'filter-menus?p_id=' + parent_id + '&e_id=' + except + '&pCount=' + parentCount;
9
    $.get(url, function(data, status){
0 ignored issues
show
Unused Code introduced by
The parameter status is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
10
        $(document).find('#child-of-parent-' + target).html(data);
11
        if(ancestors.length > 0)
12
        {
13
            $(document).find('select.parent:last').val(ancestors.shift()).change();
14
        }
15
    });
16
}
17
18
$(function () {
19
    $(document).on('change', '.parent', function (e) {
0 ignored issues
show
Unused Code introduced by
The parameter e is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
20
        menus($(this));
21
    });
22
23
    if(ancestors.length > 0)
24
    {
25
        $(document).find('select.parent:last').val(ancestors.shift()).change();
26
    }
27
});