MediaWiki:Common.js: Porovnání verzí

Z The Last Kingdom UO Wiki
Bez shrnutí editace
Bez shrnutí editace
značka: ruční vrácení zpět
 
(Není zobrazeno 9 mezilehlých verzí od stejného uživatele.)
Řádek 1: Řádek 1:
document.addEventListener('DOMContentLoaded', function () {
mw.loader.using(['mediawiki.util'], function () {
    console.log('Attempting to override footer link');
  $(function () {


     var privacyLink = document.querySelector('a[href="/wiki/Ochrana_osobn%C3%ADch_%C3%BAdaj%C5%AF"]');
     function createSwitcher() {
    if (privacyLink) {
      if ($('#lang-switcher').length) return;
         privacyLink.href = 'https://foundation.wikimedia.org/wiki/Privacy_policy';
 
         privacyLink.target = '_blank';
      $('body').append(
         console.log('Privacy link successfully overridden');
        '<div id="lang-switcher" style="position:fixed;top:10px;right:10px;z-index:9999;background:#fff;padding:6px 12px;border:1px solid #ccc;border-radius:6px;font-size:14px;box-shadow:0 2px 6px rgba(0,0,0,0.2);">' +
    } else {
        '<a href="#" id="lang-cs">Čeština</a> | ' +
         console.log('Privacy link not found');
        '<a href="#" id="lang-en">English</a>' +
        '</div>'
      );
 
      $('#lang-en').click(function (e) {
         e.preventDefault();
        document.cookie = "googtrans=/cs/en;path=/";
         location.reload();
      });
 
      $('#lang-cs').click(function (e) {
         e.preventDefault();
        document.cookie = "googtrans=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
         location.reload();
      });
     }
     }
    function loadGoogle() {
      if ($('#google_translate_element').length) return;
      $('body').append('<div id="google_translate_element" style="display:none;"></div>');
      window.googleTranslateElementInit = function () {
        new google.translate.TranslateElement({
          pageLanguage: 'cs',
          includedLanguages: 'cs,en',
          autoDisplay: false
        }, 'google_translate_element');
      };
      $.getScript('https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit');
    }
    createSwitcher();
    loadGoogle();
    // Reinforce switcher after translation DOM rewrite
    setTimeout(createSwitcher, 2000);
  });
});
});