MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
$(function () { | $(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'; | |||
const | 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 | |||
document. | 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); | |||
} | |||
}); | }); |
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); } });