From e19775972a49c32517b415550b2af281713a0fb2 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 12 Feb 2021 12:16:16 +0300 Subject: [PATCH] Update ios device detection --- .../mobile/app/controller/Search.js | 20 ++++++++++++++++--- .../mobile/app/controller/Search.js | 20 ++++++++++++++++--- .../mobile/app/controller/Search.js | 20 ++++++++++++++++--- 3 files changed, 51 insertions(+), 9 deletions(-) diff --git a/apps/documenteditor/mobile/app/controller/Search.js b/apps/documenteditor/mobile/app/controller/Search.js index 37b8a1484..6d3e7caca 100644 --- a/apps/documenteditor/mobile/app/controller/Search.js +++ b/apps/documenteditor/mobile/app/controller/Search.js @@ -70,9 +70,23 @@ define([ }; function iOSVersion() { - var ua = navigator.userAgent; - var m; - return (m = /(iPad|iPhone|iphone).*?(OS |os |OS\_)(\d+((_|\.)\d)?((_|\.)\d)?)/.exec(ua)) ? parseFloat(m[3]) : 0; + var ua = navigator.userAgent.toLowerCase(); + var isAppleDevices = (ua.indexOf("ipad") > -1 || ua.indexOf("iphone") > -1 || ua.indexOf("ipod") > -1); + if (!isAppleDevices && Common.Utils.isSafari && Common.Utils.isMac && (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1)) + isAppleDevices = true; + + var iosversion = 0; + if (isAppleDevices) { + iosversion = 13; + try + { + var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/); + if (!v) v = (navigator.appVersion).match(/Version\/(\d+).(\d+)/); + iosversion = parseInt(v[1], 10); + } + catch (err) {} + } + return iosversion; } return { diff --git a/apps/presentationeditor/mobile/app/controller/Search.js b/apps/presentationeditor/mobile/app/controller/Search.js index fbc1847b2..171b316b7 100644 --- a/apps/presentationeditor/mobile/app/controller/Search.js +++ b/apps/presentationeditor/mobile/app/controller/Search.js @@ -70,9 +70,23 @@ define([ }; function iOSVersion() { - var ua = navigator.userAgent; - var m; - return (m = /(iPad|iPhone|iphone).*?(OS |os |OS\_)(\d+((_|\.)\d)?((_|\.)\d)?)/.exec(ua)) ? parseFloat(m[3]) : 0; + var ua = navigator.userAgent.toLowerCase(); + var isAppleDevices = (ua.indexOf("ipad") > -1 || ua.indexOf("iphone") > -1 || ua.indexOf("ipod") > -1); + if (!isAppleDevices && Common.Utils.isSafari && Common.Utils.isMac && (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1)) + isAppleDevices = true; + + var iosversion = 0; + if (isAppleDevices) { + iosversion = 13; + try + { + var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/); + if (!v) v = (navigator.appVersion).match(/Version\/(\d+).(\d+)/); + iosversion = parseInt(v[1], 10); + } + catch (err) {} + } + return iosversion; } return { diff --git a/apps/spreadsheeteditor/mobile/app/controller/Search.js b/apps/spreadsheeteditor/mobile/app/controller/Search.js index 7bc278328..bf9677546 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Search.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Search.js @@ -69,9 +69,23 @@ define([ }; function iOSVersion() { - var ua = navigator.userAgent; - var m; - return (m = /(iPad|iPhone|iphone).*?(OS |os |OS\_)(\d+((_|\.)\d)?((_|\.)\d)?)/.exec(ua)) ? parseFloat(m[3]) : 0; + var ua = navigator.userAgent.toLowerCase(); + var isAppleDevices = (ua.indexOf("ipad") > -1 || ua.indexOf("iphone") > -1 || ua.indexOf("ipod") > -1); + if (!isAppleDevices && Common.Utils.isSafari && Common.Utils.isMac && (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1)) + isAppleDevices = true; + + var iosversion = 0; + if (isAppleDevices) { + iosversion = 13; + try + { + var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/); + if (!v) v = (navigator.appVersion).match(/Version\/(\d+).(\d+)/); + iosversion = parseInt(v[1], 10); + } + catch (err) {} + } + return iosversion; } return {