Skip to content

Commit

Permalink
Fix sorting (with a bit of a hack)
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Sep 3, 2024
1 parent 14d2d20 commit fdae6f3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 36 deletions.
29 changes: 1 addition & 28 deletions docs/_static/main.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,6 @@
$(document).ready( function () {
$(document).ready(function() {
$('table.datatable').DataTable({
paging: false,
searching: false,
});

var tableInstance = $('table.centertable').DataTable({
columnDefs: [{
targets: '_all',
orderable: true
}],
order: [],
drawCallback: function() {
this.api().rows().nodes().to$().each(function(index) {
if (index < 6)
$(this).addClass('no-sort');
});
},
paging: false,
searching: false,
})

tableInstance.on('order.dt', function() {
tableInstance.column(0).order('no-sort').draw();
});

// Custom sorting behavior
$.fn.dataTable.ext.order['no-sort'] = function (_, _, dataIndex) {
if (dataIndex < 6)
return -1; // Force header and first 5 rows to be at the top
return 1;
};
});
10 changes: 3 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,11 @@
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
html_css_files = [
'https://cdn.datatables.net/2.1.5/css/jquery.dataTables.css',
'https://cdn.datatables.net/fixedheader/4.0.1/css/fixedHeader.dataTables.css',
'https://cdn.datatables.net/1.10.23/css/jquery.dataTables.min.css',
'style.css'
]
html_js_files = [
'https://code.jquery.com/jquery-3.7.1.js',
'https://cdn.datatables.net/2.1.5/js/dataTables.js',
'https://cdn.datatables.net/fixedHeader/4.0.1/js/dataTables.fixedHeader.js',
'https://cdn.datatables.net/fixedHeader/4.0.1/js/fixedHeader.dataTables.js',
'https://cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js',
'main.js',
]

Expand Down Expand Up @@ -146,7 +142,7 @@
# ('vb', 'visualbasic'),
]
extlinks = {
'prob': ('https://projecteuler.net/problem=%s', 'Problem #%s'),
'prob': ('https://projecteuler.net/problem=%s', '\u200BProblem #%s'),
'source': ('https://github.com/LivInTheLookingGlass/Euler/blob/main/%s', 'here on GitHub!%.0s'),
'live-test': ('/_static/test-%s.html', 'click here!%.0s'),
'csref': ('https://learn.microsoft.com/en-us/dotnet/api/%s', '%s'),
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Problems Solved
+------+--------------------------------+

.. table::
:class: centertable
:class: datatable centertable

+-----------+------------+------------+------------+------------+------------+------------+------------+
| | |C| | |Cp| | |C#| | |Ja| | |Js| | |Py| | |Rs| |
Expand Down

0 comments on commit fdae6f3

Please sign in to comment.