Completed
Pull Request — master (#48)
by Patrick
02:22
created

js/viewAll.js   A

Complexity

Total Complexity 5
Complexity/F 2.5

Size

Lines of Code 25
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 25
rs 10
wmc 5
mnd 1
bc 4
fnc 2
bpm 2
cpm 2.5
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A viewAll.js ➔ initPage 0 8 1
1
function getDepartmentsDone(jqXHR)
2
{
3
    if(jqXHR.status !== 200 || jqXHR.responseJSON === undefined)
4
    {
5
        alert('Unable to obtain departments!');
6
        return;
7
    }
8
    var div = $('#departments');
9
    var data = jqXHR.responseJSON;
10
    for(var i = 0; i < data.length; i++)
11
    {
12
         div.prepend('<a href="viewDept.php?id='+data[i].departmentID+'" class="list-group-item">'+data[i].departmentName+'<span class="label label-success pull-right">0</span><span class="label label-danger pull-right">0</span></a>');
13
    }
14
}
15
16
function initPage()
17
{
18
    $.ajax({
19
        url: 'api/v1/departments',
20
        type: 'GET',
21
        dataType: 'json',
22
        complete: getDepartmentsDone});
23
}
24
25
$(initPage);
26