Jump to content

MediaWiki:Common.js: Difference between revisions

From Artemis Archive
No edit summary
No edit summary
Tags: Mobile edit Mobile web edit Advanced mobile edit
Line 1: Line 1:
$(function () {
$(function () {
    // identify mobile device
     const isMobile = /Mobi|Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
     const isMobile = /Mobi|Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
     const reportPage = '/index.php/Report_Animal_Abuse';
     if (isMobile) {
     const linkText = '🚨 Report Abuse';
        console.log('[ReportAbuseLink] Mobile device detected – button disabled.');
        return;
     }


     if (!isMobile) {
     // desktop load button
        // desktop button
    console.log('[ReportAbuseLink] Running...');
        const button = document.createElement('a');
        button.href = reportPage;
        button.textContent = linkText;
        button.id = 'report-abuse-button';


        Object.assign(button.style, {
    const linkURL = '/index.php/Report_Animal_Abuse'; // target page
            position: 'fixed',
    const linkText = 'Report Abuse';
            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 () {
    const button = document.createElement('a');
            button.style.backgroundColor = '#ff0000';
    button.href = linkURL;
        });
    button.textContent = linkText;
        button.addEventListener('mouseout', function () {
    button.style.position = 'absolute';
            button.style.backgroundColor = '#b60000';
    button.style.top = '0.5rem';
        });
    button.style.right = '1rem';
    button.style.padding = '10px 16px';
    button.style.backgroundColor = '#ff4444';
    button.style.color = 'white';
    button.style.fontWeight = 'bold';
    button.style.borderRadius = '6px';
    button.style.textDecoration = 'none';
    button.style.zIndex = '9999';
    button.style.fontSize = '16px';
    button.style.transition = 'background-color 0.3s ease';


        document.body.appendChild(button);
     // Hover effect
     } else {
    button.addEventListener('mouseover', function () {
        // mobile footer link
        button.style.backgroundColor = '#cc0000';
        const footerCheckInterval = setInterval(function () {
    });
            const footer = document.querySelector('#footer-places');
    button.addEventListener('mouseout', function () {
            if (footer) {
        button.style.backgroundColor = '#ff4444';
                clearInterval(footerCheckInterval);
    });


                const li = document.createElement('li');
    document.body.appendChild(button);
                const link = document.createElement('a');
    console.log('[ReportAbuseLink] Button inserted.');
                link.href = reportPage;
                link.textContent = linkText;
                link.style.color = '#b60000';
                link.style.fontWeight = 'bold';
 
                li.appendChild(link);
                footer.appendChild(li);
            }
        }, 500);
    }
});
});

Revision as of 07:52, 21 April 2025

$(function () {
    // identify mobile device
    const isMobile = /Mobi|Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
    if (isMobile) {
        console.log('[ReportAbuseLink] Mobile device detected – button disabled.');
        return;
    }

    // desktop load button
    console.log('[ReportAbuseLink] Running...');

    const linkURL = '/index.php/Report_Animal_Abuse'; // target page
    const linkText = 'Report Abuse';

    const button = document.createElement('a');
    button.href = linkURL;
    button.textContent = linkText;
    button.style.position = 'absolute';
    button.style.top = '0.5rem';
    button.style.right = '1rem';
    button.style.padding = '10px 16px';
    button.style.backgroundColor = '#ff4444';
    button.style.color = 'white';
    button.style.fontWeight = 'bold';
    button.style.borderRadius = '6px';
    button.style.textDecoration = 'none';
    button.style.zIndex = '9999';
    button.style.fontSize = '16px';
    button.style.transition = 'background-color 0.3s ease';

    // Hover effect
    button.addEventListener('mouseover', function () {
        button.style.backgroundColor = '#cc0000';
    });
    button.addEventListener('mouseout', function () {
        button.style.backgroundColor = '#ff4444';
    });

    document.body.appendChild(button);
    console.log('[ReportAbuseLink] Button inserted.');
});