summaryrefslogtreecommitdiff
blob: 6cb031dc708924573cbfa916015a226d9db57271 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/** Invalidating **/
uki(
  { view: 'Popup', rect: '500 300', anchors: 'left top', id: 'inva-popup', hideOnClick: false, relativeTo: uki('#popup'), childViews: [
      { view: 'Label', rect: '10 10 480 20', anchors: 'top', html: '<strong>The following CVEs will be marked as INVALID:</strong>', id: 'cve-inva-title'},
      { view: 'ScrollableList', rect: '10 35 480 190', anchors: 'top left right bottom', id: 'cve-inva-list' },
      { view: 'TextField', rect: '10 235 480 22', anchors: 'left top right', id: 'inva-comment' },
      { view: 'Button', rect: '345 265 70 24', anchors: 'bottom right', id: 'cve-inva-cancel', text: 'Cancel' },
      { view: 'Button', rect: '420 265 70 24', anchors: 'bottom right', id: 'cve-inva-go', text: 'Commit' }
    ]
  }
);

uki("#cve-mark-invalid").click(
  function() {
    var sel = uki('Table').selectedRows();

    if (sel.length < 1) {
      alert("Please select at least one CVE.");
      return false;
    }

    var data = new Array();
    cve_inva_data = new Array();

    for (var i = 0; i < sel.length; i++) {
      data.push("(" + sel[i][1] + ") " + sel[i][2]);
      cve_inva_data.push(sel[i][0]);
    }

    uki('#cve-inva-list').data(data);

    uki('#inva-comment').value('');
    uki('#inva-popup').show();

    uki('#cve-inva-go').focus();
  }
);

uki('#cve-inva-go').click(
  function() {
    if (cve_inva_data < 1) {
      alert("Error. Internal CVE list empty.");
      return;
      uki('#inva-popup').hide();
    }
    
    if (uki('#inva-comment').value() == "") {
      alert("You need to provide a reason.");
      uki('#inva-comment').focus();
      return;
    }
    
    new Ajax.Request('/cve/invalid', {
      parameters: { cves: cve_inva_data.join(','), reason: uki('#inva-comment').value() },
      onSuccess: function(response) {
        uki('#inva-popup').hide();
        reloadTable();
      },
      onFailure: function(response) {
        alert("Could not process your request:\n\n" + response.responseText);
      }
    });
  }
);

uki('#cve-inva-cancel').click(
  function() {
    uki('#inva-popup').hide();
  }
);
/** Invalidating end **/