-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
33 lines (25 loc) · 894 Bytes
/
scripts.js
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
//get the catalogue data from the JSON file
const data = fetch('data.json')
.then(response => response.json())
.then(data => {
//console.log(data); // Your JSON data as an array
// initializes the DataTables table
const table = $('#phacronymTable').DataTable({
data: data,
columns: [
{ data: "acronym" },
{ data: "definition" },
]
});
// highlight word that's being searched
table.on('draw', function () {
var body = $(table.table().body());
body.unhighlight();
if ( table.rows( { filter: 'applied' } ).data().length ) {
body.highlight( table.search() );
}
});
})
.catch(error => console.error('Error fetching JSON:', error));
$(document).ready(function () {
});