(function () { class BrowserDetector { constructor() { this.browser = {}; this.unsupportedBrowsers = { Chrome: 102, Firefox: 102, IE: 11, Edge: 102, Opera: 90, Safari: 14, SafariMobile: 14, AscDesktopEditor: 6, SamsungBrowser: 4, UCBrowser: 12, }; this.detectBrowser(); } detectBrowser() { this.browser = (function () { const agent = navigator.userAgent; let temp = []; let match = agent.match( /(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i ) || []; if (/trident/i.test(match[1])) { temp = /\brv[ :]+(\d+)/g.exec(ua) || []; return { name: "IE", version: temp[1] || "" }; } if (match[1] === "Chrome") { temp = agent.match( /\b(OPR|Edge|AscDesktopEditor|SamsungBrowser|UCBrowser)\/(\d+.\d)/ ); const userOS = agent.search("Linux") !== -1 && agent.search("X11") !== -1 ? "Linux" : ""; if (temp != null) { return { name: temp[1].replace("OPR", "Opera"), version: temp[2], chromeVersion: match[2] || 70, userOS, }; } } match = match[2] ? [match[1], match[2]] : [navigator.appName, navigator.appVersion, "-?"]; if ((temp = agent.match(/version\/(\d+)/i)) != null) { match.splice(1, 1, temp[1]); } if ((temp = agent.match(/mobile\/(\d+)/i)) != null) { match[0] += "Mobile"; } if ((temp = agent.match(/mobile/i)) != null) { if ((temp = agent.match(/chrome\/?\s*(\d+)/i)) != null) { match[1] = temp[1]; } } return { name: match[0], version: match[1], chromeVersion: match[1] || 70, }; })(); } isSupported() { if (this.unsupportedBrowsers.hasOwnProperty(this.browser.name)) { if ( this.browser.name === "AscDesktopEditor" && this.browser.userOS === "Linux" && +this.browser.chromeVersion <= 75 ) return false; if ( +this.browser.version < this.unsupportedBrowsers[this.browser.name] && +this.browser.chromeVersion < this.unsupportedBrowsers.Chrome ) { return false; } } return true; } getBrowserInfo() { return { name: this.browser.name, version: this.browser.version, }; } } const browserInfo = new BrowserDetector().getBrowserInfo(); const isDesktop = browserInfo.name === "AscDesktopEditor"; const isSupported = new BrowserDetector().isSupported(); if (isDesktop && !isSupported) { const styles = ``; const title = `You are using an old version of the app. Please update ONLYOFFICE Desktop Editors to the latest version to connect to DocSpace.`; const header = `Can’t connect to ${window.location.host}`; const body = `

${header}

${title}

`; document.head.innerHTML += styles; document.title = `You are using an old version of the app. Please update ONLYOFFICE Desktop Editors to the latest version to connect to DocSpace.`; document.body.innerHTML = body; return; } if (!isSupported) { const styles = ``; const body = `

Browser needs to be updated

You are using an outdated browser version

`; document.head.innerHTML += styles; document.title = "You are using an outdated browser version"; document.body.innerHTML = body; } })();