MediaWiki:Common.js: Difference between revisions
Appearance
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); | ||
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.'); | |||
}); | }); |
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.'); });