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

shifts.js ➔ polyfillerLoaded   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 9.4285
1
function getDepartmentDone(jqXHR)
2
{
3
    if(jqXHR.status !== 200 || jqXHR.responseJSON === undefined)
4
    {
5
        alert('Unable to obtain departments!');
6
        return;
7
    }
8
    var data = jqXHR.responseJSON; 
9
    var list = $('#departmentName');
10
    for(var i = 0; i < data.length; i++)
11
    {
12
        list.append('<option value="'+data[i].departmentID+'">'+data[i].departmentName+'</option>');
13
    }
14
    if(data.length === 1)
15
    {
16
        list.attr('disabled', true);
17
    }
18
}
19
20
function addNewShift()
21
{
22
    $('#roles').empty();
23
    $('#addShiftModal').modal('show');
24
}
25
26
function polyfillerLoaded()
27
{
28
    webshim.setOptions('basePath', '/js/common/js-webshim/minified/shims/'); 
0 ignored issues
show
Bug introduced by
The variable webshim seems to be never declared. If this is a global, consider adding a /** global: webshim */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
29
    webshim.polyfill();
30
}
31
32
function initPage()
33
{
34
    $('#addShiftModal').modal({show: false});
35
    $.ajax({
36
            url: 'api/v1/departments?$filter=lead eq me',
37
            type: 'GET',
38
            dataType: 'json',
39
            complete: getDepartmentDone});
40
    if(!browser_supports_input_type('datetime-local'))
41
    {
42
        $.getScript('/js/common/js-webshim/minified/polyfiller.js', polyfillerLoaded);
43
    }
44
}
45
46
$(initPage);
47