2024-06-29 15:24:14 +01:00
|
|
|
const ua = navigator.userAgent.toLowerCase();
|
|
|
|
|
2024-07-03 14:05:14 +01:00
|
|
|
const iPad = ua.includes("mac os") && navigator.maxTouchPoints > 0;
|
|
|
|
const iPhone = ua.includes("iphone os");
|
|
|
|
|
|
|
|
const iOS = iPhone || iPad;
|
|
|
|
const android = ua.includes("android") || ua.includes("diordna");
|
|
|
|
|
|
|
|
const mobile = iOS || android;
|
2024-06-29 15:24:14 +01:00
|
|
|
|
2024-07-02 19:16:03 +01:00
|
|
|
const preferredLocale = navigator.language.toLowerCase().slice(0, 2);
|
|
|
|
|
2024-07-03 14:05:14 +01:00
|
|
|
const installed = window.matchMedia('(display-mode: standalone)').matches;
|
2024-07-02 19:16:03 +01:00
|
|
|
|
2024-07-03 14:05:14 +01:00
|
|
|
const device = {
|
|
|
|
is: {
|
|
|
|
iPad,
|
|
|
|
iPhone,
|
|
|
|
iOS,
|
|
|
|
android,
|
|
|
|
mobile,
|
|
|
|
},
|
2024-07-02 19:16:03 +01:00
|
|
|
preferredLocale,
|
2024-06-29 15:24:14 +01:00
|
|
|
}
|
|
|
|
|
2024-07-03 14:05:14 +01:00
|
|
|
const app = {
|
|
|
|
is: {
|
|
|
|
installed
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export { device, app };
|