Last active
February 16, 2022 16:09
-
-
Save miketaylr/f042c482cd2ee33abbfa0fca723c5d66 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getClientOSVersion(){ | |
const os = getClientOS(); | |
var osVersion = "11.6.3"; | |
if(os.indexOf("Win") != -1) | |
{ | |
osVersion = getWindowsOSVersion(osVersion); | |
if (osVersion.match(/11\.0/)) { | |
osInfo = "Windows 11"; | |
} | |
else if (osVersion.match(/10\.0/)) { | |
osInfo = "Windows 10"; | |
} | |
else if (osVersion.match(/6\.3/)) { | |
osInfo = "Windows 8.1"; | |
} | |
else if (osVersion.match(/6\.2/)) { | |
osInfo = "Windows 8"; | |
} | |
else if (osVersion.match(/6\.1/)) { | |
osInfo = "Windows 7"; | |
} | |
else if (osVersion.match(/6\.0/)) { | |
osInfo = "Windows Vista"; | |
} | |
else if (osVersion.match(/(5\.1|XP)/)) { | |
osInfo = "Windows XP"; | |
} | |
else{ | |
osInfo = "推奨環境外のWindows OS"; | |
} | |
} | |
else if(os.indexOf("Mac") != -1) | |
{ | |
if (osVersion.match(/^10[._]6/)) { | |
osInfo = "Mac OS 10.6"; | |
} | |
else if (osVersion.match(/^10[._]7/)) | |
{ | |
osInfo = "Mac OS 10.7"; | |
} | |
else if (osVersion.match(/^10[._]8/)) | |
{ | |
osInfo = "Mac OS 10.8"; | |
} | |
else if (osVersion.match(/^10[._]9/)) | |
{ | |
osInfo = "Mac OS 10.9"; | |
} | |
else if (osVersion.match(/^10[._]10/)) | |
{ | |
osInfo = "Mac OS 10.10"; | |
} | |
else if (osVersion.match(/^10[._]11/)) | |
{ | |
osInfo = "Mac OS 10.11"; | |
} | |
else if (osVersion.match(/^10[._]12/)) | |
{ | |
osInfo = "Mac OS 10.12"; | |
} | |
else if (osVersion.match(/^10[._]13/)) | |
{ | |
osInfo = "Mac OS 10.13"; | |
} | |
else if (osVersion.match(/^10[._]14/)) | |
{ | |
osInfo = "Mac OS 10.14"; | |
} | |
else if (osVersion.match(/^10[._]15/)) | |
{ | |
osInfo = "Mac OS 10.15"; | |
} | |
else if (osVersion.match(/^10[._]16/)) | |
{ | |
osInfo = "Mac OS 10.16"; | |
} | |
else if (osVersion.match(/^11[._][0-9]+/)) | |
{ | |
osInfo = "Mac OS 11"; | |
} | |
else if (osVersion.match(/^12[._][0-9]+/)) | |
{ | |
osInfo = "Mac OS 12"; | |
} | |
else{ | |
osInfo = "推奨環境外のMac OS"; | |
} | |
} | |
else { | |
osInfo = "推奨環境外のOS"; | |
} | |
return osInfo; | |
} | |
function getClientOSEtax() | |
{ | |
const os = "macOS"; | |
const osversion = "11.6.3"; | |
return getClientOSVersionEtax(os, osversion); | |
} | |
function isRecommendedBrowserAsSp() | |
{ | |
const os = "macOS"; | |
const browser = "Google Chrome"; | |
if(os === SMARTOS_TYPE.ANDROID && browser === BROWSER_TYPE.GOOGLE_CHROME){ | |
return "OK"; | |
} | |
if(os === SMARTOS_TYPE.IOS && browser === BROWSER_TYPE.GOOGLE_CHROME){ | |
return "SF_OTHER_SP"; | |
} | |
return "OTHER"; | |
} | |
function getSmartDeviceOS(){ | |
const mobile = false; | |
const os = "macOS"; | |
let osversion = "11.6.3"; | |
if(mobile || os === "Android"){ | |
const num = osversion.match(new RegExp("([0-9]+[._][0-9]+)|([0-9]+)")); | |
if (num === null) | |
{ | |
return ""; | |
} | |
return os + " " + num[0].replace("_", "."); | |
} | |
return ""; | |
} | |
function getSpMajorVersion() | |
{ | |
const os = getSmartDeviceOS(); | |
const versionArray = os.match(/(Android|iOS)\s(\d+)[._]\d*/); | |
if (versionArray === null) | |
{ | |
return 0; | |
} | |
const version = versionArray.slice(-1)[0]; | |
if (!/\d+/.test(version)) | |
{ | |
return 0; | |
} | |
return parseInt(version); | |
} | |
function getTabletOS() | |
{ | |
return getSmartDeviceOS(); | |
} | |
function isRecommendedOsAsEtax() | |
{ | |
const userOs = getClientOSEtax(); | |
return userOs.TYPE !== OS_TYPE.OTHER; | |
} | |
function isRecommendedBrowserAsEtax(juraiMyNoFlg) | |
{ | |
const bi = new BrowserInfo(); | |
const userOs = getClientOSEtax().TYPE; | |
if(juraiMyNoFlg !== 0) | |
{ | |
if(bi.edg || bi.googleChrome) | |
{ | |
if(userOs === OS_TYPE_ETAX.WINDOWS_8_1.TYPE || userOs === OS_TYPE_ETAX.WINDOWS_10.TYPE || userOs === OS_TYPE_ETAX.WINDOWS_11.TYPE) | |
{ | |
return "OK"; | |
} | |
} | |
} | |
return "OTHER"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const BROWSER_TYPE = { | |
MICROSOFT_EDGE: 'Microsoft Edge', | |
GOOGLE_CHROME: 'Google Chrome', | |
OTHER: 'OTHER' | |
} | |
const BROWSER_TYPE_ETAX = { | |
MICROSOFT_EDGE: 'Microsoft Edge', | |
GOOGLE_CHROME: 'Google Chrome', | |
OTHER: 'OTHER' | |
} | |
const OS_TYPE = { | |
WINDOWS: 'Windows', | |
MAC: 'Mac', | |
OTHER: 'OTHER' | |
} | |
const SMARTOS_TYPE = { | |
ANDROID: 'Android', | |
IOS: 'iOS', | |
OTHER: 'OTHER' | |
} | |
const OS_TYPE_ETAX = { | |
WINDOWS_11: { OS: OS_TYPE.WINDOWS, TYPE: 'Windows 11' }, | |
WINDOWS_10: { OS: OS_TYPE.WINDOWS, TYPE: 'Windows 10' }, | |
WINDOWS_8_1: { OS: OS_TYPE.WINDOWS, TYPE: 'Windows 8.1' }, | |
MAC_10_14: { OS: OS_TYPE.MAC, TYPE: 'Mac OS 10.14' }, | |
MAC_10_15: { OS: OS_TYPE.MAC, TYPE: 'Mac OS 10.15' }, | |
MAC_11: { OS: OS_TYPE.MAC, TYPE: 'Mac OS 11' }, | |
MAC_12: { OS: OS_TYPE.MAC, TYPE: 'Mac OS 12' }, | |
OTHER_WINDOWS: { OS: OS_TYPE.WINDOWS, TYPE: 'OTHER' }, | |
OTHER_MAC: { OS: OS_TYPE.MAC, TYPE: 'OTHER' }, | |
OTHER: { OS: OS_TYPE.OTHER, TYPE: 'OTHER' } | |
} | |
function getUAData(){ | |
if (typeof navigator.userAgentData !== 'undefind') { | |
const browser = getBrowser(navigator.userAgentData.brands); | |
const isMobile = navigator.userAgentData.mobile; | |
return { | |
"browser": browser.brand, | |
"browserVersion": browser.version, | |
"isMobile": isMobile | |
} | |
}else{ | |
return null; | |
} | |
} | |
function isTablet() | |
{ | |
if (typeof navigator.userAgentData !== 'undefind') { | |
if(navigator.userAgentData.mobile || getClientOS() === SMARTOS_TYPE.ANDROID){ | |
return true; | |
} | |
} | |
return false; | |
} | |
function isMobile() | |
{ | |
return isTablet(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment