27 lines
No EOL
891 B
JavaScript
27 lines
No EOL
891 B
JavaScript
// 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';
|
|
mobileMessage.style.display = 'flex';
|
|
} else {
|
|
gameContainer.style.display = 'block';
|
|
mobileMessage.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
// Make isMobileDevice function globally accessible
|
|
window.isMobileDevice = isMobileDevice;
|
|
|
|
// 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)
|
|
window.addEventListener('resize', checkDeviceType); |