|
|
| Line 1: |
Line 1: |
| /* Any JavaScript here will be loaded for all users on every page load. */// Load DataTables library | | /* Any JavaScript here will be loaded for all users on every page load. */// Load DataTables library |
| mw.loader.using( 'jquery' ).done( function () {
| |
| $.getScript("https://cdn.datatables.net/1.13.8/js/jquery.dataTables.min.js", function () {
| |
| // Activate DataTables on any table with class="datatable"
| |
| $(document).ready(function () {
| |
| $("table.datatable").DataTable({
| |
| paging: true, // Adds pagination
| |
| searching: true, // Adds search box
| |
| ordering: true, // Enables column sorting
| |
| info: true // Shows "Showing 1 to 10 of X entries"
| |
| });
| |
| });
| |
| });
| |
| });
| |
|
| |
| mw.hook('wikipage.content').add(function ($content) {
| |
| var $tbl = $content.find('#dungeons');
| |
| if ($tbl.length && !$tbl.hasClass('dt-initialized')) {
| |
| // Load DataTables if not already present
| |
| var loadDT = function () {
| |
| if ($.fn.dataTable) {
| |
| $tbl.addClass('dt-initialized').DataTable({
| |
| paging: true,
| |
| searching: true,
| |
| ordering: true,
| |
| info: true
| |
| });
| |
| } else {
| |
| // Fallback: load from CDN once
| |
| $.when(
| |
| $.getScript('https://cdn.datatables.net/1.13.8/js/jquery.dataTables.min.js')
| |
| ).done(function () {
| |
| $('<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.13.8/css/jquery.dataTables.min.css">').appendTo('head');
| |
| $tbl.addClass('dt-initialized').DataTable({
| |
| paging: true,
| |
| searching: true,
| |
| ordering: true,
| |
| info: true
| |
| });
| |
| });
| |
| }
| |
| };
| |
| loadDT();
| |
| }
| |
| });
| |