MediaWiki:Common.js

From LHDB
Revision as of 10:40, 11 July 2025 by Lhdb (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* 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);
    }
  });
});