| Total Complexity | 13 |
| Complexity/F | 2.6 |
| Lines of Code | 79 |
| Function Count | 5 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | var deptData = null; |
||
| 2 | |||
| 3 | function getRoleDone(jqXHR) |
||
| 4 | { |
||
| 5 | if(jqXHR.status !== 200 || jqXHR.responseJSON === undefined) |
||
| 6 | { |
||
| 7 | alert('Unable to obtain roles!'); |
||
| 8 | return; |
||
| 9 | } |
||
| 10 | console.log(jqXHR); |
||
|
|
|||
| 11 | } |
||
| 12 | |||
| 13 | function getDepartmentDone(jqXHR) |
||
| 14 | { |
||
| 15 | if(jqXHR.status !== 200 || jqXHR.responseJSON === undefined) |
||
| 16 | { |
||
| 17 | alert('Unable to obtain department!'); |
||
| 18 | return; |
||
| 19 | } |
||
| 20 | var data = jqXHR.responseJSON; |
||
| 21 | deptData = data[0]; |
||
| 22 | $('#departmentNameRO').append(deptData.departmentName); |
||
| 23 | $('#departmentName').val(deptData.departmentName); |
||
| 24 | if(deptData.description !== undefined) |
||
| 25 | { |
||
| 26 | $('#description').val(deptData.description); |
||
| 27 | } |
||
| 28 | if(deptData.public) |
||
| 29 | { |
||
| 30 | $('#public').prop('checked', true); |
||
| 31 | $('#privateDept').hide(); |
||
| 32 | } |
||
| 33 | $.ajax({ |
||
| 34 | url: 'api/v1/departments/'+deptData.departmentID+'/roles', |
||
| 35 | type: 'GET', |
||
| 36 | dataType: 'json', |
||
| 37 | complete: getRoleDone}); |
||
| 38 | } |
||
| 39 | |||
| 40 | function publicChanged() |
||
| 41 | { |
||
| 42 | if($('#public').prop('checked')) |
||
| 43 | { |
||
| 44 | $('#privateDept').hide(); |
||
| 45 | } |
||
| 46 | else |
||
| 47 | { |
||
| 48 | $('#privateDept').show(); |
||
| 49 | } |
||
| 50 | } |
||
| 51 | |||
| 52 | function viewShifts() |
||
| 53 | { |
||
| 54 | window.location = 'shifts.php?id='+deptData.departmentID; |
||
| 55 | return false; |
||
| 56 | } |
||
| 57 | |||
| 58 | function initPage() |
||
| 59 | { |
||
| 60 | var id = getParameterByName('id'); |
||
| 61 | if(id === null) |
||
| 62 | { |
||
| 63 | $.ajax({ |
||
| 64 | url: 'api/v1/departments?$top=1', |
||
| 65 | type: 'GET', |
||
| 66 | dataType: 'json', |
||
| 67 | complete: getDepartmentDone}); |
||
| 68 | } |
||
| 69 | else |
||
| 70 | { |
||
| 71 | $.ajax({ |
||
| 72 | url: 'api/v1/departments/'+id, |
||
| 73 | type: 'GET', |
||
| 74 | dataType: 'json', |
||
| 75 | complete: getDepartmentDone}); |
||
| 76 | } |
||
| 77 | } |
||
| 78 | |||
| 79 | $(initPage); |
||
| 80 |