MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 1: Line 1:
mw.hook('wikipage.content').add(function() {
$(document).ready(function() {
     const copyableElements = document.querySelectorAll('.copyable-text');
     $('.copyable-text').on('click', function() {
 
        var textToCopy = $(this).text(); // Получаем текст элемента
    copyableElements.forEach(function(element) {
        navigator.clipboard.writeText(textToCopy).then(function() {
        element.addEventListener('click', function() {
            // Добавляем класс .copied для показа уведомления
            const textToCopy = element.textContent;
            $(this).addClass('copied');
 
        }.bind(this), function(err) {
            navigator.clipboard.writeText(textToCopy).then(function() {
            console.error('Ошибка при копировании текста: ', err);
                alert('Текст скопирован: ' + textToCopy);
            }).catch(function(err) {
                console.error('Ошибка копирования: ', err);
                alert('Не удалось скопировать текст');
            });
         });
         });
     });
     });
});
});




Navigation menu

Help

Help Image

Here's pages that you can help us to get more information about them.

Stand with Ukraine

Ukrainian Flag