-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
59 lines (54 loc) · 2.13 KB
/
index.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
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
const cheerio = require('cheerio');
const crypto = require('crypto');
module.exports = {
book:{
assets: './assets',
js: [ 'js/jquery.min.js'
,'js/jquery.dataTables.min.js'
,'js/dataTables.dataTables.min.js'
,'js/colReorder.dataTables.min.js'
,'js/dataTables.colReorder.min.js'
,'js/fixedColumns.dataTables.min.js'
,'js/dataTables.fixedColumns.min.js'
,'js/fixedHeader.dataTables.min.js'
,'js/dataTables.fixedHeader.min.js'
,'js/responsive.dataTables.min.js'
,'js/dataTables.responsive.min.js'
,'js/rowGroup.dataTables.min.js'
,'js/dataTables.rowGroup.min.js'
,'js/searchBuilder.dataTables.min.js'
,'js/dataTables.searchBuilder.min.js'
,'js/select.dataTables.min.js'
,'js/dataTables.select.min.js'
,'js/searchPanes.dataTables.min.js'
,'js/dataTables.searchPanes.min.js'
,'js/plugin.js'],
css: [ 'css/jquery.dataTables.min.css'
,'css/colReorder.dataTables.min.css'
,'css/fixedColumns.dataTables.min.css'
,'css/fixedHeader.dataTables.min.css'
,'css/responsive.dataTables.min.css'
,'css/rowGroup.dataTables.min.css'
,'css/searchBuilder.dataTables.min.css'
,'css/searchPanes.dataTables.min.css'
,'css/select.dataTables.min.css'
]
},
hooks: {
init: async function () {
},
"page": function(page) {
// Inspect page contents and initialize all tables that carry the datatables class
const $ = cheerio.load(page.content, null, false);
// Iterate around all the tables marked as datatables and collect their element id
$('table[class=datatable]').each(function( index ) {
if ( $(this).attr('id') === undefined ){
$(this).attr('id',`datatable-${crypto.randomBytes(16).toString('base64').substring(0, 16)}`);
}
$(this).attr("data-dt-process", "true");
});
page.content = $.html();
return page;
},
}
};