1<table id="data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
2  <thead>
3    <tr>
4      <th>IP Address</th>
5      <th>MAC Address</th>
6      <th>Vendor</th>
7      <th class="nd_center-cell">DNS</th>
8      <th>Last Used</th>
9    </tr>
10  </thead>
11</table>
12
13<script type="text/javascript">
14$(document).ready(function() {
15  var table = $('#data-table').dataTable({
16    "deferRender": true,
17    "data": [% results | none %],
18    "columns": [
19      {
20        "data": 'ip',
21        "render": function(data, type, row, meta) {
22          var cell_str = he.encode(data);
23          if (type == 'display') {
24            if (row.time_last && row.node) {
25              cell_str = '<a href="[% search_node | none %]&q=' + encodeURIComponent(data)
26                + (row.active ? '' : '&archived=on') + '">' + he.encode(data)
27                + (row.active ? '' : '&nbsp;<i class="icon-book text-warning"></i>&nbsp;') + '</a>';
28            }
29            else if (row.time_last) {
30              cell_str = '<a href="[% search_device | none %]&q=' + encodeURIComponent(data) + '">' + he.encode(data) + '</a>';
31            }
32          }
33          return cell_str;
34        }
35      }, {
36        "data": 'mac',
37        "render": function(data, type, row, meta) {
38          var cell_str = he.encode(data || '');
39          if (type == 'display' && data && row.time_last) {
40            cell_str = '<a href="[% search_node | none %]&q=' + encodeURIComponent(data)
41              + (row.active ? '' : '&archived=on') + '">' + he.encode(data)
42              + (row.active ? '' : '&nbsp;<i class="icon-book text-warning"></i>&nbsp;') + '</a>';
43          }
44          return cell_str;
45        }
46      }, {
47        "data": 'vendor',
48        "className": "nd_nowrap nd_center-cell",
49        "render": function(data, type, row, meta) {
50          return he.encode(data || '');
51        }
52      }, {
53        "data": 'dns',
54        "className": "nd_nowrap nd_center-cell",
55        "render": function(data, type, row, meta) {
56          return he.encode(data || '');
57        }
58      }, {
59        "data": 'age',
60        "render": function(data, type, row, meta) {
61          if (type == 'display') {
62            return he.encode(data || 'Never');
63          }
64          else {
65            // so that sorting works correctly on this column
66            return row.time_last;
67          }
68        }
69      }
70    ],
71[% INCLUDE 'ajax/datatabledefaults.tt' -%]
72  });
73});
74</script>
75