1[% USE url %]
2[% IF opt %]
3  <table id="data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
4    <thead>
5      <tr>
6        <th>Domain</th>
7        <th>Node</th>
8        <th>Name</th>
9        <th>User</th>
10        <th>First Seen</th>
11        <th>Last Seen</th>
12      </tr>
13    </thead>
14  </table>
15[% ELSE %]
16  <table id="data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
17    <thead>
18      <tr>
19        <th>Domain</th>
20        <th>Count</th>
21      </tr>
22    </thead>
23  </table>
24[% END %]
25
26<script type="text/javascript">
27$(document).ready(function() {
28  var table = $('#data-table').dataTable({
29    [% IF opt %]
30    "serverSide": true,
31    "order": [[ 0, "desc" ]],
32    "ajax": "[% uri_for('/ajax/content/report/netbios/data') | none %]?[% url(params('query').hash) | none %]",
33    "columns": [
34      {
35        "data": 'domain',
36        "render": function(data, type, row, meta) {
37          return he.encode(data || '(Blank Domain)');
38        }
39      }, {
40        "data": 'mac',
41        "render": function(data, type, row, meta) {
42          return '<a href="[% search_node | none %]&q=' + encodeURIComponent(data) + '">' + he.encode(data.toUpperCase()) + '</a>';
43        }
44      }, {
45        "data": 'nbname',
46        "render": function(data, type, row, meta) {
47          var prefix = '';
48          if (row.domain) {
49            prefix = '\\\\' + row.domain + '\\';
50          }
51          return he.encode(prefix) + '<a href="[% search_node | none %]&q=' + encodeURIComponent(data) + '">' + he.encode(data) + '</a>';
52        }
53      }, {
54        "data": 'nbuser',
55        "render": function(data, type, row, meta) {
56          return he.encode(row.nbuser || '[No User]');
57        }
58      }, {
59        "data": 'time_first',
60        "render": function(data, type, row, meta) {
61          return moment(data).format('YYYY-MM-DD HH:mm');
62        }
63      }, {
64        "data": 'time_last',
65        "render": function(data, type, row, meta) {
66          return moment(data).format('YYYY-MM-DD HH:mm');
67        }
68      }
69    ],
70    "order": [[0, "asc"], [5, "desc"]],
71    [% ELSE %]
72    "deferRender": true,
73    "data": [% results | none %],
74    "columns": [
75      {
76        "data": 'domain',
77        "render": function(data, type, row, meta) {
78          return '<a href="[% uri_for('/report/netbios') | none %]?domain=' + encodeURIComponent(data || 'blank') + '">' + he.encode(data || '(Blank Domain)') + '</a>';
79        }
80      }, {
81        "data": 'count',
82        "render": function(data, type, row, meta) {
83          return data.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
84        }
85      }
86    ],
87    "order": [[1, "desc"]],
88    [% END %]
89[% INCLUDE 'ajax/datatabledefaults.tt' -%]
90  });
91});
92</script>
93
94