Total Complexity | 6 |
Complexity/F | 2 |
Lines of Code | 47 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | function post_done(jqXHR) |
||
2 | { |
||
3 | if(jqXHR.status === 200) |
||
4 | { |
||
5 | alert('Success!'); |
||
6 | location = 'index.php'; |
||
7 | } |
||
8 | else |
||
9 | { |
||
10 | alert('Error! '+jqXHR.responseText); |
||
11 | } |
||
12 | } |
||
13 | |||
14 | function submit_page(e) |
||
|
|||
15 | { |
||
16 | var obj = {}; |
||
17 | obj.name = $('#name').val(); |
||
18 | if(obj.name.length === 0) |
||
19 | { |
||
20 | $('#name').parent().addClass('has-error') |
||
21 | return; |
||
22 | } |
||
23 | $('#name').parent().removeClass('has-error') |
||
24 | if($('#presenting:checked').length > 0) |
||
25 | { |
||
26 | obj.presenting = true; |
||
27 | } |
||
28 | else |
||
29 | { |
||
30 | obj.presenting = false; |
||
31 | } |
||
32 | $.ajax({ |
||
33 | url: 'api/v1/themes', |
||
34 | type: 'post', |
||
35 | dataType: 'json', |
||
36 | data: JSON.stringify(obj), |
||
37 | processData: false, |
||
38 | complete: post_done |
||
39 | }); |
||
40 | } |
||
41 | |||
42 | function init_page() |
||
43 | { |
||
44 | $('[name=submit]').on('click', submit_page); |
||
45 | } |
||
46 | |||
47 | $(init_page); |
||
48 |
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.