Jump to content

MediaWiki:Common.js: Difference between revisions

From TwainFrame
No edit summary
Tag: Reverted
No edit summary
Tags: Manual revert Reverted
Line 3: Line 3:


// DataTables JS laden und initialisieren
// DataTables JS laden und initialisieren
//mw.loader.getScript('https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js')
mw.loader.getScript('https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js')
   .then(function () {
   .then(function () {
     $(function () {
     $(function () {

Revision as of 02:06, 25 June 2025

// DataTables CSS laden
mw.loader.load('https://cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css', 'text/css');

// DataTables JS laden und initialisieren
mw.loader.getScript('https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js')
  .then(function () {
    $(function () {
      var table = $('#example');

      if (table.length) {
        // Füge zusätzliche Kopfzeile mit Input-Feldern hinzu
        $('#example thead').append('<tr></tr>');
        $('#example thead tr:eq(0) th').each(function () {
          var title = $(this).text();
          $('#example thead tr:eq(1)').append('<th><input type="text" placeholder="Suche ' + title + '" /></th>');
        });

        // DataTable initialisieren
        var dataTable = table.DataTable();

        // Spaltensuche aktivieren
        dataTable.columns().every(function () {
          var that = this;
          $('input', this.header()).on('keyup change clear', function () {
            if (that.search() !== this.value) {
              that.search(this.value).draw();
            }
          });
        });
      }
    });
  });