| Total Complexity | 5 |
| Complexity/F | 2.5 |
| Lines of Code | 25 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 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 |