summaryrefslogtreecommitdiff
blob: 609a53b02a70acc8a1f18ee102f0dc065e3fb0f1 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<h1>CVE List</h1>

<script language="JavaScript" type="text/javascript">

var view = 1; // NEW by default

// formatter for highlighted strings
var hlt = '';
function formatHlted (t) {
    return hlt ? (t || '').replace(hlt, '<strong>' + hlt + '</strong>') : t;
}

<%= render :partial => 'toolbar.js' %>

uki(
  { view: 'HSplitPane', rect: '1000 1000', anchors: 'left top right bottom', handleWidth: 1, handlePosition: 199, leftMin: 199, rightMin: 400,
      leftPane: { background: '#D3CFE5', childViews: toolbar() },
      rightChildViews: [
        { view: 'Table', rect: '0 0 800 1000', minSize: '0 200', anchors: 'left top right bottom', columns: [
          { view: 'table.NumberColumn', label: 'ID', width: 50 },
          { view: 'table.CustomColumn', label: 'CVE ID', width: 150, formatter: formatHlted, sort: 'DESC' },
          { view: 'table.CustomColumn', label: 'Summary', resizable: true, minWidth: 300, width: (window.innerWidth - 200 - 50 - 150 - 80 - 15), formatter: formatHlted },
          { view: 'table.CustomColumn', label: 'State', width: 80, formatter: formatHlted },
        ], multiselect: true, style: {fontSize: '12px', lineHeight: '12px'} }
      ]
  }
).attachTo(window, '1000 1000');

uki(
  { view: 'Popup', rect: '100 20', id: 'loading', anchors: '', relativeTo: uki('#logo'), hideOnClick: false, childViews: [
      { view: 'Label', rect: '20 2 98 18', anchors: 'top', text: 'LOADING...', textAlign: 'center', id: 'loading-text'},
    ]
  }
).show();

<%= render :partial => 'key_events.js' %>

<%= render :partial => 'ui_misc.js' %>

<%= render :partial => 'filing.js' %>

<%= render :partial => 'assigning.js' %>

<%= render :partial => 'nfu.js' %>

<%= render :partial => 'later.js' %>

<%= render :partial => 'invalidate.js' %>

// searchable model
window.DummyModel = uki.newClass(Searchable, new function() {
    this.init = function(data) {
        this.items = data;
        uki.each(this.items, function(i, row) {
            row.searchIndex = escapeHTML(row[1].toLowerCase()) + ' ' + row[2].toLowerCase();
        })
    };

    this.matchRow = function(row, iterator) {
        return row.searchIndex.indexOf(iterator.query) > -1;
    };
});

// dinamicly load library json
initCVETable = function(data) {
    uki('#loading').visible(false);
    var model = new DummyModel(data),
        lastQuery = '',
        table = uki('Table');

    model.bind('search.foundInChunk', function(chunk) {
        table.data(table.data().concat(chunk)).layout();
    });

    table.find('Header').bind('columnClick', function(e) {
        var header = this;

        if (e.column.sort() == 'ASC') e.column.sort('DESC');
        else e.column.sort('ASC');

        header.redrawColumn(e.columnIndex);
        uki.each(header.columns(), function(i, col) {
            if (col != e.column && col.sort()) {
                col.sort('');
                header.redrawColumn(i);
            }
        });
        model.items = e.column.sortData(model.items);
        table.data(model.items);
    });

    table.data(model.items);

    uki('#quicksearch').unbind('keyup click');

    uki('#quicksearch').bind('keyup click', function() {
        if (this.value().toLowerCase() == lastQuery) return;
        lastQuery = this.value().toLowerCase();
        if (lastQuery.match(/\S/)) {
            hlt = lastQuery;
            table.data([]);
            model.search(lastQuery);
        } else {
            hlt = '';
            table.data(model.items);
        }
    });
    document.body.className += '';
};

function reloadTable() {
  uki('#loading').visible(true);
  new Ajax.Request('/cve/list.json', {
    parameters: { view_map: view, year: uki('#year-select').value() },
    onSuccess: function(response) {
      initCVETable(response.responseJSON);
    },
    onFailure: function(response) {
      alert("Could not load CVE data.");
      uki('#loading').text("Loading CVE data failed. Please try again later.");
    }
  });
  uki('#quicksearch').click();
}

function disableMainView() {
}

function enableMainView() {
}

reloadTable();
</script>