From d7116e1a03268aad9d30fb642814123c3c450aaa Mon Sep 17 00:00:00 2001 From: Will Colding Date: Fri, 19 Jan 2024 13:48:35 -0500 Subject: [PATCH] Use JS to detect Apple mobile devices --- static/App.js | 16 +++++++++++++++- templates/App.html | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/static/App.js b/static/App.js index 0ce5bfa..caf70c0 100644 --- a/static/App.js +++ b/static/App.js @@ -11,7 +11,10 @@ let nameElement; let descElement; function init() { - + // Check for mobile Apple devices and fix viewport + let devices = ['iphone', 'ipad']; + filterViewportByDeviceList(devices); + nameElement = document.getElementById("presetName"); descElement = document.getElementById("presetDesc"); updatePresetDesc(0); @@ -40,6 +43,17 @@ function init() { updateCounterDisplay(); } +function filterViewportByDeviceList(listOfDevices) { + let navString = navigator.userAgent.toLowerCase(); + listOfDevices.forEach((device) => { + if (navString.indexOf(device) != -1) { + let viewport = document.querySelector("meta[name=viewport]"); + viewport.setAttribute('content', 'width=device-width, user-scalable=no'); + return; + } + }); +} + function clearAllChecks() { gamesObj.forEach((entry) => { let allSelect = document.getElementById(`${entry.game}_allSelect`); diff --git a/templates/App.html b/templates/App.html index 705d03f..7128a97 100644 --- a/templates/App.html +++ b/templates/App.html @@ -2,7 +2,7 @@ - + Multibingo Generator