summaryrefslogtreecommitdiff
blob: 7f8c49bffea0f11023ec7c4d81726867033686fc (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
72
73
74
75
/** New CVE **/
uki(
  { view: 'Popup', rect: '650 300', anchors: 'left top', id: 'new-popup', hideOnClick: false, relativeTo: uki('#popup'), childViews: [
      { view: 'Label', rect: '10 10 630 20', anchors: 'top', text: '', id: 'cve-new-title' },
      { view: 'ScrollPane', rect: '10 30 635 220', anchors: 'top left right bottom', id: 'cve-new-scroll', scrollableV: true, scrollableH: false, childViews: [
        { view: 'Label', rect: '10 20 600 100', anchors: 'top', text: '', id: 'cve-new-text', textSelectable: true, multiline: true },
      ] },
      { view: 'Button', rect: '495 265 70 24', anchors: 'bottom right', id: 'cve-new-cancel', text: 'Cancel' },
      { view: 'Button', rect: '570 265 70 24', anchors: 'bottom right', id: 'cve-new-go', text: 'Create' }
    ]
  }
);

uki("#cve-new").click(
  function() {
    var popup = uki('#new-popup');

    new Ajax.Request('/cve/new_preview', {
      onSuccess: function(response) {
        uki('#cve-new-text').html(response.responseText);
        uki('#cve-new-text').resizeToContents('height');

        uki('#cve-new-title').html("<strong>Please provide the following CVE information:</strong>");
        popup.show();
        uki('#cve-new-go').disabled(false);
        uki('#cve-new-go').focus();
      },
      onFailure: function(response) {
        alert("Could not process your request:\n\n" + response.response.Text);
        return false;
      }
    });
  }
);

uki('#cve-new-cancel').click(
  function() {
    uki('#new-popup').hide(); 
    enableMainView();
  }
);

uki('#cve-new-go').click(
  function() {
    if ($('cve_id').value.length < 13) {
      alert("Please enter a valid 13 digit CVE identifier.");
      return false;
    }
    if ($('summary').value.length < 1) {
      alert("Please enter a CVE summary.");
      return false;
    }

    uki('#cve-new-go').disabled(true);
    var params = {
      cve_id:     $('cve_id').value,
      summary: $('summary').value
    };

    new Ajax.Request('new', {
      parameters: params,
      onSuccess: function(message) {
        uki('#new-popup').hide();
        uki('#cve-new-go').disabled(false);
        reloadTable();
      },
      onFailure: function(request, textStatus, errorThrown) {
        var message = (request.status == 403) ? request.responseText : "Filing the CVE failed. Is this a duplicate?";
        alert(message);
        uki('#cve-new-go').disabled(false);
      }
    });
  }
);
/** New CVE end **/