Empêcher game.js de charger sur mobile
This commit is contained in:
parent
15957f0462
commit
e334b61b32
2 changed files with 17 additions and 5 deletions
|
@ -1,13 +1,22 @@
|
|||
@()
|
||||
|
||||
@main("Arkanoid Game") {
|
||||
<div id="gameContainer">
|
||||
<canvas id="gameCanvas" width="540" height="675"></canvas>
|
||||
</div>
|
||||
|
||||
<div id="mobileMessage" style="display: none;">
|
||||
<p><img src="/assets/images/image-casse-briques-mobile.png" alt="Capture d'écran du jeu casse-briques DéconstruIT"/></p>
|
||||
<p>Le jeu de casse-briques DéconstruIT est disponible sur ordinateur seulement pour l'instant</p>
|
||||
</div>
|
||||
|
||||
<div id="gameContainer">
|
||||
<canvas id="gameCanvas" width="540" height="675"></canvas>
|
||||
</div>
|
||||
|
||||
<script src="@routes.Assets.versioned("javascripts/device-detection.js")"></script>
|
||||
<script src="@routes.Assets.versioned("javascripts/game.js")"></script>
|
||||
<script>
|
||||
if (!isMobileDevice()) {
|
||||
var script = document.createElement('script');
|
||||
script.src = '@routes.Assets.versioned("javascripts/game.js")';
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
</script>
|
||||
}
|
|
@ -17,8 +17,11 @@ function checkDeviceType() {
|
|||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
window.addEventListener('resize', checkDeviceType);
|
Loading…
Reference in a new issue