Skip to content

Commit

Permalink
Use JS to detect Apple mobile devices
Browse files Browse the repository at this point in the history
  • Loading branch information
wcolding committed Jan 19, 2024
1 parent 5319005 commit d7116e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion static/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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`);
Expand Down
2 changes: 1 addition & 1 deletion templates/App.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multibingo Generator</title>
<link rel="stylesheet" href="../static/App.css" />
</head>
Expand Down

0 comments on commit d7116e1

Please sign in to comment.