File size: 856 Bytes
756e034
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
$(document).ready(function () {
  function fetchResults(query) {
    $.get(`/search?text=${encodeURIComponent(query)}`, function (data) {
      const table = $('#resultsTable').DataTable();
      table.clear();
      data.forEach(row => {
        const audioHtml = `<audio controls preload="metadata" style="height:20px; width:120px;">
                             <source src="/audio/${row.id}" type="audio/mpeg"></audio>`;
        table.row.add([
          row.id, row.channel, row.video_id, row.speaker,
          row.start_time, row.end_time, row.upload_date,
          row.text, row.pos_tags, audioHtml
        ]);
      });
      table.draw();
    });
  }

  $('#resultsTable').DataTable();
  $('#searchBox').on('input', function () {
    const query = $(this).val();
    fetchResults(query);
  });

  // Initial empty fetch
  fetchResults('');
});