„MediaWiki:Common.js” változatai közötti eltérés

Innen: Sanctum2 Wikipédia
Ugrás a navigációhozUgrás a kereséshez
(Új oldal, tartalma: „// MediaWiki:Common.js $(document).ready(function() { // Add search box $('table.wikitable').before('<input type="text" id="tableSearch" placeholder="Keresés név alapján" style="margin-bottom:10px;">'); $('#tableSearch').on('keyup', function() { var value = $(this).val().toLowerCase(); $('table.wikitable tr').filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1); }); }); //…”)
 
Nincs szerkesztési összefoglaló
1. sor: 1. sor:
// MediaWiki:Common.js
// Keresőmező hozzáadása
$(document).ready(function() {
$(document).ready(function() {
     // Add search box
     var searchBox = $('<div style="position: sticky; top: 10px; background: #333; padding: 10px; border-radius: 5px; z-index: 1000;">' +
    $('table.wikitable').before('<input type="text" id="tableSearch" placeholder="Keresés név alapján" style="margin-bottom:10px;">');
        '<label for="searchInput" style="color: #fff; font-size: 1.2em; margin-right: 10px;">Keresés tárgynév alapján:</label>' +
        '<input type="text" id="searchInput" placeholder="Írd be a tárgy nevét..." style="padding: 5px; border-radius: 5px; border: 1px solid #72716F;">' +
        '</div>');


     $('#tableSearch').on('keyup', function() {
    $('body').prepend(searchBox);
         var value = $(this).val().toLowerCase();
 
         $('table.wikitable tr').filter(function() {
     $('#searchInput').on('input', function() {
             $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1);
         var searchTerm = $(this).val().toLowerCase();
         $('table.wikitable tr').each(function() {
             var itemName = $(this).find('td:nth-child(2)').text().toLowerCase();
            if (itemName.includes(searchTerm)) {
                $(this).show();
            } else {
                $(this).hide();
            }
         });
         });
    });
    // Fix search box position
    var searchBox = $('#tableSearch');
    $(window).scroll(function() {
        var offset = searchBox.offset().top - $(window).scrollTop();
        if (offset < 0) {
            searchBox.css('position', 'fixed').css('top', '0').css('background-color', '#000').css('color', '#fff').css('z-index', '1000').css('width', '100%').css('padding', '10px');
        } else {
            searchBox.css('position', 'static').css('width', 'auto').css('padding', '0');
        }
     });
     });
});
});

A lap 2024. június 24., 09:25-kori változata

// Keresőmező hozzáadása
$(document).ready(function() {
    var searchBox = $('<div style="position: sticky; top: 10px; background: #333; padding: 10px; border-radius: 5px; z-index: 1000;">' +
        '<label for="searchInput" style="color: #fff; font-size: 1.2em; margin-right: 10px;">Keresés tárgynév alapján:</label>' +
        '<input type="text" id="searchInput" placeholder="Írd be a tárgy nevét..." style="padding: 5px; border-radius: 5px; border: 1px solid #72716F;">' +
        '</div>');

    $('body').prepend(searchBox);

    $('#searchInput').on('input', function() {
        var searchTerm = $(this).val().toLowerCase();
        $('table.wikitable tr').each(function() {
            var itemName = $(this).find('td:nth-child(2)').text().toLowerCase();
            if (itemName.includes(searchTerm)) {
                $(this).show();
            } else {
                $(this).hide();
            }
        });
    });
});