assets/js/app.js   A
last analyzed

Complexity

Total Complexity 7
Complexity/F 1.4

Size

Lines of Code 45
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 31
mnd 2
bc 2
fnc 5
dl 0
loc 45
rs 10
bpm 0.4
cpm 1.4
noi 0
c 0
b 0
f 0
1
const $ = require('jquery');
2
3
$(() => {
4
    $('form').on('submit', e => {
5
        $(e.target).find('input').prop('readonly', true);
6
        $(e.target).find('button').prop('disabled', true);
7
    });
8
9
    $('.btn-reset-form').on('click', e => {
10
        $('.results').hide();
11
        $('input').val('').prop('checked', false);
12
        $('#searchQuery').focus();
13
        $(e.target).remove();
14
        history.pushState({}, document.title, window.location.pathname);
15
    });
16
17
    if (!$('#searchQuery').val()) {
18
        $('#searchQuery').focus();
19
    }
20
21
    $('#regexCheckbox').on('change', e => {
22
        $('.form-group--ingorecase').toggleClass('hidden', !e.target.checked);
23
    });
24
25
    $('[data-toggle="tooltip"]').tooltip();
26
27
    $('.preset-link').on('click', e => {
28
        e.preventDefault();
29
30
        switch (e.target.dataset.value) {
31
            case 'js':
32
                $('#namespaceIds').val('2,4,8');
33
                $('#titlePattern').val('(Gadgets-definition|.*\\.(js|css|json))');
34
                break;
35
            case 'subject':
36
                $('#namespaceIds').val('0,2,4,6,8,10,12,14');
37
                $('#titlePattern').val('');
38
                break;
39
            case 'talk':
40
                $('#namespaceIds').val('1,3,5,7,9,11,13,15');
41
                $('#titlePattern').val('');
42
                break;
43
        }
44
    });
45
});
46