Total Complexity | 5 |
Complexity/F | 2.5 |
Lines of Code | 38 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | /** |
||
5 | Amarkal.settings.search = { |
||
|
|||
6 | $input: null, |
||
7 | activeSection: null, |
||
8 | init: function() { |
||
9 | this.$input = $('#settings-search'); |
||
10 | this.$input.on('keyup',this.onKeyup.bind(this)); |
||
11 | }, |
||
12 | onKeyup: function(e) { |
||
13 | var query = this.$input.val().toLowerCase().replace(/[^\w\d\s]/g,''); |
||
14 | |||
15 | // The user's search query is longer than 0 characters |
||
16 | if(query.length > 0) { |
||
17 | |||
18 | var $matches = Amarkal.settings.fields.search(query); |
||
19 | |||
20 | // Store a copy of the active section before it is deactivated |
||
21 | if(null === this.activeSection) { |
||
22 | this.activeSection = Amarkal.settings.sections.activeSection; |
||
23 | } |
||
24 | |||
25 | Amarkal.settings.sections.deactivate(); |
||
26 | Amarkal.settings.header.setSectionTitle('Field Search Results'); |
||
27 | Amarkal.settings.header.setSectionSubtitle(''); |
||
28 | Amarkal.settings.fields.hideAll(); |
||
29 | Amarkal.settings.fields.show($matches); |
||
30 | |||
31 | // Textual user feedback |
||
32 | $('#settings-search-results').addClass('visible').text($matches.length ? $matches.length+' settings found' : 'Nothing found'); |
||
33 | } |
||
34 | |||
35 | // The user's search query is not longer than 0 character |
||
36 | else { |
||
37 | $('#settings-search-results').removeClass('visible').text(''); |
||
38 | Amarkal.settings.sections.activate(this.activeSection); |
||
39 | this.activeSection = null; |
||
40 | } |
||
41 | } |
||
42 | }; |
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.