Issues (81)

views/route/_script.js (2 issues)

Labels
Severity
1
$('i.glyphicon-refresh-animate').hide();
2
function updateRoutes(r) {
3
    _opts.routes.available = r.available;
0 ignored issues
show
The variable _opts seems to be never declared. If this is a global, consider adding a /** global: _opts */ comment.

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.

Loading history...
4
    _opts.routes.assigned = r.assigned;
5
    search('available');
6
    search('assigned');
7
}
8
9
$('#btn-new').click(function () {
10
    var $this = $(this);
11
    var route = $('#inp-route').val().trim();
12
    if (route != '') {
13
        $this.children('i.glyphicon-refresh-animate').show();
14
        $.post($this.attr('href'), {route: route}, function (r) {
15
            $('#inp-route').val('').focus();
16
            updateRoutes(r);
17
        }).always(function () {
18
            $this.children('i.glyphicon-refresh-animate').hide();
19
        });
20
    }
21
    return false;
22
});
23
24
$('.btn-assign').click(function () {
25
    var $this = $(this);
26
    var target = $this.data('target');
27
    var routes = $('select.list[data-target="' + target + '"]').val();
28
29
    if (routes && routes.length) {
30
        $this.children('i.glyphicon-refresh-animate').show();
31
        $.post($this.attr('href'), {routes: routes}, function (r) {
32
            updateRoutes(r);
33
        }).always(function () {
34
            $this.children('i.glyphicon-refresh-animate').hide();
35
        });
36
    }
37
    return false;
38
});
39
40
$('#btn-refresh').click(function () {
41
    var $icon = $(this).children('span.glyphicon');
42
    $icon.addClass('glyphicon-refresh-animate');
43
    $.post($(this).attr('href'), function (r) {
44
        updateRoutes(r);
45
    }).always(function () {
46
        $icon.removeClass('glyphicon-refresh-animate');
47
    });
48
    return false;
49
});
50
51
$('.search[data-target]').keyup(function () {
52
    search($(this).data('target'));
53
});
54
55
function search(target) {
56
    var $list = $('select.list[data-target="' + target + '"]');
57
    $list.html('');
58
    var q = $('.search[data-target="' + target + '"]').val();
59
    $.each(_opts.routes[target], function () {
0 ignored issues
show
The variable _opts seems to be never declared. If this is a global, consider adding a /** global: _opts */ comment.

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.

Loading history...
60
        var r = this;
61
        if (r.indexOf(q) >= 0) {
62
            $('<option>').text(r).val(r).appendTo($list);
63
        }
64
    });
65
}
66
67
// initial
68
search('available');
69
search('assigned');
70