demo/extension: Expand iPad check to work for iPadOS 13+

This commit is contained in:
Daniel Jacobs 2023-11-14 15:17:22 -05:00
parent b196c8d1bc
commit ffdb248872
2 changed files with 16 additions and 2 deletions

View File

@ -230,7 +230,9 @@ reloadSwf.addEventListener("click", () => {
window.addEventListener("load", () => {
if (
navigator.userAgent.match(/iPad/i) ||
navigator.userAgent.match(/iPhone/i)
navigator.userAgent.match(/iPhone/i) ||
(navigator.platform === "MacIntel" &&
typeof navigator.standalone !== "undefined")
) {
localFileInput.removeAttribute("accept");
}

View File

@ -7,6 +7,16 @@ import type {
URLLoadOptions,
} from "ruffle-core";
declare global {
interface Navigator {
/**
* iPadOS sends a User-Agent string that appears to be from macOS.
* navigator.standalone is not defined on macOS, so we use it for iPad detection.
*/
standalone?: boolean;
}
}
const api = PublicAPI.negotiate(window.RufflePlayer!, "local");
window.RufflePlayer = api;
const ruffle = api.newest()!;
@ -216,7 +226,9 @@ reloadSwf.addEventListener("click", () => {
window.addEventListener("load", () => {
if (
navigator.userAgent.match(/iPad/i) ||
navigator.userAgent.match(/iPhone/i)
navigator.userAgent.match(/iPhone/i) ||
(navigator.platform === "MacIntel" &&
typeof navigator.standalone !== "undefined")
) {
localFileInput.removeAttribute("accept");
}