2024-06-29 15:24:14 +01:00
|
|
|
const ua = navigator.userAgent.toLowerCase();
|
|
|
|
|
2024-07-03 14:05:14 +01:00
|
|
|
const iPhone = ua.includes("iphone os");
|
2024-07-10 18:28:23 +01:00
|
|
|
const iPad = !iPhone && ua.includes("mac os") && navigator.maxTouchPoints > 0;
|
2024-07-03 14:05:14 +01:00
|
|
|
|
|
|
|
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-12 13:49:29 +01:00
|
|
|
const language = navigator.language.toLowerCase().slice(0, 2);
|
2024-07-02 19:16:03 +01:00
|
|
|
|
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-12 13:49:29 +01:00
|
|
|
const reducedMotion = window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;
|
|
|
|
const reducedTransparency = window.matchMedia(`(prefers-reduced-transparency: reduce)`).matches;
|
|
|
|
|
2024-07-03 14:05:14 +01:00
|
|
|
const device = {
|
|
|
|
is: {
|
|
|
|
iPhone,
|
2024-07-10 18:28:23 +01:00
|
|
|
iPad,
|
2024-07-03 14:05:14 +01:00
|
|
|
iOS,
|
|
|
|
android,
|
|
|
|
mobile,
|
|
|
|
},
|
2024-07-12 13:49:29 +01:00
|
|
|
prefers: {
|
|
|
|
language,
|
|
|
|
reducedMotion,
|
|
|
|
reducedTransparency,
|
|
|
|
},
|
2024-07-10 19:27:46 +01:00
|
|
|
userAgent: navigator.userAgent,
|
2024-06-29 15:24:14 +01:00
|
|
|
}
|
|
|
|
|
2024-07-03 14:05:14 +01:00
|
|
|
const app = {
|
|
|
|
is: {
|
|
|
|
installed
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export { device, app };
|