MediaWiki:Common.js: Difference between revisions

From LHDB
No edit summary
No edit summary
 
Line 7: Line 7:


     $('<li>').append(link).appendTo('#footer-places').parent();  
     $('<li>').append(link).appendTo('#footer-places').parent();  
});
$(function () {
  const searchInput = $('#searchInput');
  if (!searchInput.length) return;
  searchInput.autocomplete({
    delay: 150,
    minLength: 2,
    source: function (request, response) {
      $.getJSON(mw.util.wikiScript('api'), {
        action: 'wbsearchentities',
        format: 'json',
        language: mw.config.get('wgUserLanguage'),
        search: request.term,
        type: 'item' // zmień na 'property', jeśli chcesz przeszukiwać właściwości
      }, function (data) {
        response($.map(data.search, function (item) {
          return {
            label: item.label + (item.description ? ' – ' + item.description : '') + ' (' + item.id + ')',
            value: item.label,
            id: item.id
          };
        }));
      });
    },
    select: function (event, ui) {
      // Przejdź do encji, np. /wiki/Item:Q123
      window.location.href = mw.util.getUrl('Item:' + ui.item.id);
    }
  });
});
});

Latest revision as of 10:40, 11 July 2025

/* Any JavaScript here will be loaded for all users on every page load. */
$(function () {
    // Tworzymy nowy link
    var link = $('<a>')
        .attr('href', '/wiki/Deklaracja_dostepnosci') 
        .text('Deklaracja dostępności');

    $('<li>').append(link).appendTo('#footer-places').parent(); 
});

$(function () {
  const searchInput = $('#searchInput');

  if (!searchInput.length) return;

  searchInput.autocomplete({
    delay: 150,
    minLength: 2,
    source: function (request, response) {
      $.getJSON(mw.util.wikiScript('api'), {
        action: 'wbsearchentities',
        format: 'json',
        language: mw.config.get('wgUserLanguage'),
        search: request.term,
        type: 'item' // zmień na 'property', jeśli chcesz przeszukiwać właściwości
      }, function (data) {
        response($.map(data.search, function (item) {
          return {
            label: item.label + (item.description ? ' – ' + item.description : '') + ' (' + item.id + ')',
            value: item.label,
            id: item.id
          };
        }));
      });
    },
    select: function (event, ui) {
      // Przejdź do encji, np. /wiki/Item:Q123
      window.location.href = mw.util.getUrl('Item:' + ui.item.id);
    }
  });
});