Jump to content

MediaWiki:Common.js: Difference between revisions

From Artemis Archive
No edit summary
No edit summary
Line 1: Line 1:
$(function () {
$(function () {
     mw.loader.using('mediawiki.util').then(function () {
     const isMobile = /Mobi|Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
        console.log('[ReportAbuseLink] Inserting LARGE styled button with hover...');
    const reportPage = '/index.php/Report_Animal_Abuse';
    const linkText = '🚨 Report Abuse';


         const pageTitle = 'Report_Animal_Abuse';
    if (!isMobile) {
         const linkHref = mw.util.getUrl(pageTitle);
        // desktop button
         const linkText = '🚨 Report Animal Abuse';
         const button = document.createElement('a');
         button.href = reportPage;
        button.textContent = linkText;
         button.id = 'report-abuse-button';


         if (document.getElementById('report-abuse-button')) return;
         Object.assign(button.style, {
            position: 'fixed',
            top: '10px',
            right: '10px',
            backgroundColor: '#b60000',
            color: 'white',
            padding: '12px 20px',
            fontSize: '16px',
            fontWeight: 'bold',
            borderRadius: '6px',
            textDecoration: 'none',
            zIndex: '9999',
            boxShadow: '0 4px 6px rgba(0,0,0,0.2)',
            transition: 'background-color 0.3s',
        });


         // Create a <style> element for hover effect
         button.addEventListener('mouseover', function () {
        const style = document.createElement('style');
            button.style.backgroundColor = '#ff0000';
        style.textContent = `
        });
            #report-abuse-button a:hover {
        button.addEventListener('mouseout', function () {
                background-color: #ff0000 !important;
            button.style.backgroundColor = '#b60000';
                box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);
        });
                transform: scale(1.05);
 
                transition: all 0.2s ease-in-out;
        document.body.appendChild(button);
            }
    } else {
         `;
         // mobile footer link
         document.head.appendChild(style);
         const footerCheckInterval = setInterval(function () {
            const footer = document.querySelector('#footer-places');
            if (footer) {
                clearInterval(footerCheckInterval);


        // Create the button
                const li = document.createElement('li');
        const container = document.createElement('div');
                const link = document.createElement('a');
        container.id = 'report-abuse-button';
                link.href = reportPage;
        container.innerHTML = `<a href="${linkHref}" style="
                link.textContent = linkText;
            display: inline-block;
                link.style.color = '#b60000';
            background-color: #b10000;
                link.style.fontWeight = 'bold';
            color: #fff;
            font-weight: bold;
            font-size: 18px;
            padding: 10px 18px;
            border-radius: 8px;
            text-decoration: none;
            position: fixed;
            top: 12px;
            right: 12px;
            z-index: 9999;
            box-shadow: 0 4px 8px rgba(0,0,0,0.25);
        ">${linkText}</a>`;


        document.body.appendChild(container);
                li.appendChild(link);
        console.log('[ReportAbuseLink] Button rendered with hover effect.');
                footer.appendChild(li);
    });
            }
        }, 500);
    }
});
});

Revision as of 07:47, 21 April 2025

$(function () {
    const isMobile = /Mobi|Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
    const reportPage = '/index.php/Report_Animal_Abuse';
    const linkText = '🚨 Report Abuse';

    if (!isMobile) {
        // desktop button
        const button = document.createElement('a');
        button.href = reportPage;
        button.textContent = linkText;
        button.id = 'report-abuse-button';

        Object.assign(button.style, {
            position: 'fixed',
            top: '10px',
            right: '10px',
            backgroundColor: '#b60000',
            color: 'white',
            padding: '12px 20px',
            fontSize: '16px',
            fontWeight: 'bold',
            borderRadius: '6px',
            textDecoration: 'none',
            zIndex: '9999',
            boxShadow: '0 4px 6px rgba(0,0,0,0.2)',
            transition: 'background-color 0.3s',
        });

        button.addEventListener('mouseover', function () {
            button.style.backgroundColor = '#ff0000';
        });
        button.addEventListener('mouseout', function () {
            button.style.backgroundColor = '#b60000';
        });

        document.body.appendChild(button);
    } else {
        // mobile footer link
        const footerCheckInterval = setInterval(function () {
            const footer = document.querySelector('#footer-places');
            if (footer) {
                clearInterval(footerCheckInterval);

                const li = document.createElement('li');
                const link = document.createElement('a');
                link.href = reportPage;
                link.textContent = linkText;
                link.style.color = '#b60000';
                link.style.fontWeight = 'bold';

                li.appendChild(link);
                footer.appendChild(li);
            }
        }, 500);
    }
});