Przełącz menu
Przełącz menu użytkownika
Nie jesteś zalogowany
Twój adres IP będzie publicznie widoczny, jeśli dokonasz jakichkolwiek zmian.

MediaWiki:Common.js: Różnice pomiędzy wersjami

Strona MediaWiki
mNie podano opisu zmian
mNie podano opisu zmian
Znaczniki: Z urządzenia mobilnego Z wersji mobilnej (przeglądarkowej)
Linia 69: Linia 69:


document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function() {
     // Function to create the new list item
     // Create the custom list item
     var createListItem = function(id) {
     function createCustomLink(id, text, onclickAction) {
         var li = document.createElement('li');
         var li = document.createElement('li');
         li.id = id; // Set a unique ID for the new list item to prevent duplicates
         li.id = id;
        li.style.display = 'inline-block'; // Ensure the item is displayed
 
         var a = document.createElement('a');
         var a = document.createElement('a');
         a.href = "#"; // Placeholder href, replace with the actual URL
         a.href = "#";
         a.textContent = "Privacy Control Center";
         a.textContent = text;
        a.onclick = function(event) {
            event.preventDefault(); // Prevent the default anchor action
            onclickAction(); // Run the custom action
        };
         li.appendChild(a);
         li.appendChild(a);
         return li;
         return li;
     };
     }


     // Add the list item to the desktop version
     // Function to determine if the skin is Minerva (mobile)
    var desktopFooter = document.querySelector('#footer-places');
     function isMinervaSkin() {
     if (desktopFooter && !document.getElementById('custom-footer-link-desktop')) {
         return document.body.classList.contains('skin-minerva');
         var desktopLi = createListItem('custom-footer-link-desktop');
        desktopFooter.appendChild(desktopLi);
     }
     }


     // Add the list item to the mobile version
     // Function to add the custom link
     var mobileFooter = document.querySelector('.footer-places');
     function addCustomFooterLink() {
    if (mobileFooter && !document.getElementById('custom-footer-link-mobile')) {
        var customLinkAction = function() {
        var mobileLi = createListItem('custom-footer-link-mobile');
            // Custom action when clicking the link
        mobileFooter.appendChild(mobileLi);
            console.log('Privacy Control Center opened.'); // Replace with actual functionality
        };
 
        if (isMinervaSkin()) {
            // Mobile (Minerva skin)
            var privacyPolicyLinkMobile = document.querySelector('.footer-places li#footer-places-privacy');
            if (privacyPolicyLinkMobile) {
                var customLinkMobile = createCustomLink('custom-footer-privacy-link-mobile', 'Privacy Control Center', customLinkAction);
                privacyPolicyLinkMobile.parentNode.insertBefore(customLinkMobile, privacyPolicyLinkMobile.nextSibling);
                customLinkMobile.style.display = 'block'; // Ensure visibility on mobile
            }
        } else {
            // Desktop
            var privacyPolicyLinkDesktop = document.getElementById('footer-places-privacy');
            if (privacyPolicyLinkDesktop) {
                var customLinkDesktop = createCustomLink('custom-footer-privacy-link', 'Privacy Control Center', customLinkAction);
                privacyPolicyLinkDesktop.parentNode.insertBefore(customLinkDesktop, privacyPolicyLinkDesktop.nextSibling);
            }
        }
     }
     }
    addCustomFooterLink();
});
});

Wersja z 00:57, 24 lut 2024

/* Umieszczony tutaj kod JavaScript zostanie załadowany przez każdego użytkownika, podczas każdego ładowania strony. */

// linki z tagiem a i klasą extiw będą otwierane w nowej zakładce
mw.hook('wikipage.content').add(function($content) {
    $content.find('a.extiw').attr('target', '_blank');
});

/* Opinia DSA */
window.Userback = window.Userback || {};
Userback.access_token = '4796|88831|3S2WfgkWf8v2sBL2pd0NJxOI8QHu2swcDq6oDLcScFi56Z3xqk';
(function(d) {
	var s = d.createElement('script');s.async = true;
	s.src = 'https://static.userback.io/widget/v1.js';
	(d.head || d.body).appendChild(s);
})(document);

/* RODO */
(function() {
    var scriptElement = document.createElement('script');
    scriptElement.src = "https://platform.illow.io/banner.js?siteId=44c89d68-4273-42c8-9e9f-cf98fb4c4d09";
    document.head.appendChild(scriptElement);
})();

/* opcje ciasteczek */
/*
mw.loader.using('mediawiki.util', function () {
    $(document).ready(function () {
        var customLink = $('<li id="custom-footer-privacy-link"><a href="#" onclick="illow.showWidget(); return false;" class="bannerLink">Ustawienia prywatności</a></li>');
        $('#footer-places').append(customLink);
    });
});
*/
/* opcje ciasteczek w trybie mobilnym */
/*
mw.loader.using(['mediawiki.util', 'mobilefrontend'], function () {
    $(document).ready(function () {
        var customLinkHtml = '<li id="custom-footer-privacy-link-mobile"><a href="#" onclick="illow.showWidget(); return false;" class="bannerLink">Privacy Control Center</a></li>';

        // For Desktop
        $('#footer-places').append(customLinkHtml);

        // For MobileFrontend
        var mobileMenu = $('.mw-mf-footer-items');
        if (mobileMenu.length) {
            mobileMenu.append(customLinkHtml);
        }
    });
});
*/

// This script should be added to MediaWiki:Common.js or an equivalent site-wide script file.
// This script should be added to MediaWiki:Common.js or an equivalent site-wide script file.
/*
$(function () {
    var customLink = $('<li id="custom-footer-privacy-link"><a href="#" onclick="illow.showWidget(); return false;">Privacy Control Center</a></li>');

    // For Desktop
    $('#footer-places-privacy').after(customLink);

    // For Mobile
    // Check if MobileFrontend is active by looking for a mobile-specific class or ID
    if ($('body').hasClass('skin-minerva') || $('#mw-mf-display-toggle').length > 0) {
        // This ensures the code executes in a mobile context
        $('#footer-places-privacy').after(customLink.clone());
    }
});
*/


document.addEventListener('DOMContentLoaded', function() {
    // Create the custom list item
    function createCustomLink(id, text, onclickAction) {
        var li = document.createElement('li');
        li.id = id;
        var a = document.createElement('a');
        a.href = "#";
        a.textContent = text;
        a.onclick = function(event) {
            event.preventDefault(); // Prevent the default anchor action
            onclickAction(); // Run the custom action
        };
        li.appendChild(a);
        return li;
    }

    // Function to determine if the skin is Minerva (mobile)
    function isMinervaSkin() {
        return document.body.classList.contains('skin-minerva');
    }

    // Function to add the custom link
    function addCustomFooterLink() {
        var customLinkAction = function() {
            // Custom action when clicking the link
            console.log('Privacy Control Center opened.'); // Replace with actual functionality
        };

        if (isMinervaSkin()) {
            // Mobile (Minerva skin)
            var privacyPolicyLinkMobile = document.querySelector('.footer-places li#footer-places-privacy');
            if (privacyPolicyLinkMobile) {
                var customLinkMobile = createCustomLink('custom-footer-privacy-link-mobile', 'Privacy Control Center', customLinkAction);
                privacyPolicyLinkMobile.parentNode.insertBefore(customLinkMobile, privacyPolicyLinkMobile.nextSibling);
                customLinkMobile.style.display = 'block'; // Ensure visibility on mobile
            }
        } else {
            // Desktop
            var privacyPolicyLinkDesktop = document.getElementById('footer-places-privacy');
            if (privacyPolicyLinkDesktop) {
                var customLinkDesktop = createCustomLink('custom-footer-privacy-link', 'Privacy Control Center', customLinkAction);
                privacyPolicyLinkDesktop.parentNode.insertBefore(customLinkDesktop, privacyPolicyLinkDesktop.nextSibling);
            }
        }
    }

    addCustomFooterLink();
});