GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 37b02e...ebbbe1 )
by James
08:59
created

public/js/ff/rules/index.js (1 issue)

1
/*
2
 * index.js
3
 * Copyright (c) 2017 [email protected]
4
 *
5
 * This file is part of Firefly III.
6
 *
7
 * Firefly III is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * Firefly III is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
19
 */
20
/** global: token */
21
var fixHelper = function (e, tr) {
22
    "use strict";
23
    var $originals = tr.children();
24
    var $helper = tr.clone();
25
    $helper.children().each(function (index) {
26
        // Set helper cell sizes to match the original sizes
27
        $(this).width($originals.eq(index).width());
28
    });
29
    return $helper;
30
};
31
32
$(function () {
33
      "use strict";
34
      $('.rule-triggers').sortable(
35
          {
36
              helper: fixHelper,
37
              stop: sortStop,
38
              cursor: "move"
39
          }
40
      );
41
42
      $('.rule-actions').sortable(
43
          {
44
              helper: fixHelper,
45
              stop: sortStop,
46
              cursor: "move"
47
48
          }
49
      );
50
51
      // test rule triggers button:
52
      $('.test_rule_triggers').click(testRuleTriggers);
53
  }
54
);
55
56
function testRuleTriggers(e) {
57
58
    var obj = $(e.target);
59
    var ruleId = parseInt(obj.data('id'));
60
    var icon = obj;
61
    if (obj.prop("tagName") === 'A') {
62
        icon = $('i', obj);
63
    }
64
    // change icon:
65
    icon.addClass('fa-spinner fa-spin').removeClass('fa-flask');
66
67
    var modal = $("#testTriggerModal");
68
    // respond to modal:
69
    modal.on('hide.bs.modal', function (e) {
0 ignored issues
show
The parameter e is not used and could be removed.

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.

Loading history...
70
        disableRuleSpinners();
71
    });
72
73
    // Find a list of existing transactions that match these triggers
74
    $.get('rules/test-rule/' + ruleId).done(function (data) {
75
76
77
        // Set title and body
78
        modal.find(".transactions-list").html(data.html);
79
80
        // Show warning if appropriate
81
        if (data.warning) {
82
            modal.find(".transaction-warning .warning-contents").text(data.warning);
83
            modal.find(".transaction-warning").show();
84
        } else {
85
            modal.find(".transaction-warning").hide();
86
        }
87
88
        // Show the modal dialog
89
        modal.modal();
90
    }).fail(function () {
91
        alert('Cannot get transactions for given triggers.');
92
        disableRuleSpinners();
93
    });
94
95
    return false;
96
}
97
98
function disableRuleSpinners() {
99
    $('i.test_rule_triggers').removeClass('fa-spin fa-spinner').addClass('fa-flask');
100
}
101
102
103
function sortStop(event, ui) {
104
    "use strict";
105
    var current = $(ui.item);
106
    var parent = current.parent();
107
    var ruleId = current.parent().data('id');
108
    var entries = [];
109
    // who am i?
110
111
    $.each(parent.children(), function (i, v) {
112
        var trigger = $(v);
113
        var id = trigger.data('id');
114
        entries.push(id);
115
116
    });
117
    if (parent.hasClass('rule-triggers')) {
118
        $.post('rules/trigger/order/' + ruleId, {triggers: entries, _token: token}).fail(function () {
119
            alert('Could not re-order rule triggers. Please refresh the page.');
120
        });
121
    } else {
122
        $.post('rules/action/order/' + ruleId, {actions: entries, _token: token}).fail(function () {
123
            alert('Could not re-order rule actions. Please refresh the page.');
124
        });
125
126
    }
127
128
}
129