2024-09-01 16:57:09 +00:00
|
|
|
// public/javascripts/device-detection.js
|
|
|
|
|
|
|
|
function isMobileDevice() {
|
|
|
|
return (typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkDeviceType() {
|
|
|
|
const gameContainer = document.getElementById('gameContainer');
|
|
|
|
const mobileMessage = document.getElementById('mobileMessage');
|
|
|
|
|
|
|
|
if (isMobileDevice()) {
|
|
|
|
gameContainer.style.display = 'none';
|
2024-09-01 17:28:25 +00:00
|
|
|
mobileMessage.style.display = 'flex';
|
2024-09-01 16:57:09 +00:00
|
|
|
} else {
|
|
|
|
gameContainer.style.display = 'block';
|
|
|
|
mobileMessage.style.display = 'none';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-01 17:15:10 +00:00
|
|
|
// Make isMobileDevice function globally accessible
|
|
|
|
window.isMobileDevice = isMobileDevice;
|
|
|
|
|
2024-09-01 16:57:09 +00:00
|
|
|
// Run the check when the page loads
|
|
|
|
window.addEventListener('load', checkDeviceType);
|
|
|
|
|
|
|
|
// Also run the check if the window is resized (in case of device rotation)
|
2024-09-01 17:15:10 +00:00
|
|
|
window.addEventListener('resize', checkDeviceType);
|