Added a helper class for useragent utilities.
This commit is contained in:
parent
bc19d336a6
commit
a96695da3a
4 changed files with 89 additions and 30 deletions
|
|
@ -47,3 +47,48 @@ export function getDateForSavedSessionTimeout() {
|
|||
currentDate.setDate(currentDate.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS);
|
||||
return currentDate.toUTCString();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Function to return the iOS version of the device.
|
||||
*/
|
||||
|
||||
export function getiOSversion() {
|
||||
if (/iP(hone|od|ad)/.test(navigator.platform)) {
|
||||
// supports iOS 2.0 and later:
|
||||
var v = navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
|
||||
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function to return true/false if the user agent is a mobile device or not.
|
||||
*/
|
||||
|
||||
export function isMobileDevice() {
|
||||
const userAgent = navigator.userAgent;
|
||||
return (
|
||||
userAgent.includes("Android") ||
|
||||
userAgent.includes("Mobile") ||
|
||||
userAgent.includes("iPod") ||
|
||||
userAgent.includes("iPhone") ||
|
||||
userAgent.includes("IEMobile") ||
|
||||
userAgent.includes("BlackBerry") ||
|
||||
userAgent.includes("webOS")
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Function to return true/false if the user is using an apple browser on a device.
|
||||
*/
|
||||
|
||||
export function isAppleBrowser() {
|
||||
const userAgent = navigator.userAgent;
|
||||
return (
|
||||
userAgent.includes("iPod") ||
|
||||
userAgent.includes("iPad") ||
|
||||
userAgent.includes("iPhone") ||
|
||||
userAgent.includes("Mac")
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
42
src/helpers/useragent-helper.js
Normal file
42
src/helpers/useragent-helper.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
Function to return the iOS version of the device.
|
||||
*/
|
||||
|
||||
export function getiOSversion() {
|
||||
if (/iP(hone|od|ad)/.test(navigator.platform)) {
|
||||
// supports iOS 2.0 and later:
|
||||
var v = navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
|
||||
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Function to return true/false if the user agent is a mobile device or not.
|
||||
*/
|
||||
|
||||
export function isMobileDevice() {
|
||||
const userAgent = navigator.userAgent;
|
||||
return (
|
||||
userAgent.includes("Android") ||
|
||||
userAgent.includes("Mobile") ||
|
||||
userAgent.includes("iPod") ||
|
||||
userAgent.includes("iPhone") ||
|
||||
userAgent.includes("IEMobile") ||
|
||||
userAgent.includes("BlackBerry") ||
|
||||
userAgent.includes("webOS")
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Function to return true/false if the user is using an apple browser on a device.
|
||||
*/
|
||||
|
||||
export function isAppleBrowser() {
|
||||
const userAgent = navigator.userAgent;
|
||||
return (
|
||||
userAgent.includes("iPod") ||
|
||||
userAgent.includes("iPad") ||
|
||||
userAgent.includes("iPhone") ||
|
||||
userAgent.includes("Mac")
|
||||
);
|
||||
}
|
||||
|
|
@ -43,34 +43,6 @@ export default {
|
|||
scrollToPageBottom() {
|
||||
const container = document.getElementsByClassName('fade-on-route-transition')[0];
|
||||
container.scrollTo({ top: container.scrollHeight, left: 0, behavior: 'smooth' });
|
||||
},
|
||||
getiOSversion() {
|
||||
if (/iP(hone|od|ad)/.test(navigator.platform)) {
|
||||
// supports iOS 2.0 and later:
|
||||
var v = navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
|
||||
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
|
||||
}
|
||||
},
|
||||
isMobileDevice() {
|
||||
const userAgent = navigator.userAgent;
|
||||
return (
|
||||
userAgent.includes("Android") ||
|
||||
userAgent.includes("Mobile") ||
|
||||
userAgent.includes("iPod") ||
|
||||
userAgent.includes("iPhone") ||
|
||||
userAgent.includes("IEMobile") ||
|
||||
userAgent.includes("BlackBerry") ||
|
||||
userAgent.includes("webOS")
|
||||
);
|
||||
},
|
||||
isAppleBrowser() {
|
||||
const userAgent = navigator.userAgent;
|
||||
return (
|
||||
userAgent.includes("iPod") ||
|
||||
userAgent.includes("iPad") ||
|
||||
userAgent.includes("iPhone") ||
|
||||
userAgent.includes("Mac")
|
||||
);
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ import {
|
|||
import { buildURLSearchParams, getPartNumbersListForQueryString } from '@/helpers/querystring-helper';
|
||||
import { getTopLevelGlassPartsWithRecal } from '@/helpers/recal-helper';
|
||||
import { getDateForSavedSessionTimeout } from '@/helpers/session-helper';
|
||||
import { isMobileDevice } from '@/helpers/useragent-helper';
|
||||
import issPageValues from '@/router/router-constants/issPage-values';
|
||||
import CoverageStatuses from '@/constants/coverage-statuses';
|
||||
import baseMixin from '@/mixins/base-mixin';
|
||||
|
||||
const storeId = 'main';
|
||||
|
||||
|
|
@ -2645,7 +2645,7 @@ export const useMainStore = defineStore({
|
|||
actionName: actionName ?? "",
|
||||
referralSequenceNumber: referralSequenceNumber ?? "",
|
||||
referralNumber: referralNumber ?? "",
|
||||
applicationName: baseMixin.methods.isMobileDevice() ? "ISS Mobile" : "ISS",
|
||||
applicationName: isMobileDevice() ? "ISS Mobile" : "ISS",
|
||||
workOrderId: workOrderId ?? "",
|
||||
workOrderNumber: workOrderNumber ?? "",
|
||||
conceptVariation: conceptVariation,
|
||||
|
|
|
|||
Loading…
Reference in a new issue