diff --git a/common/badBrowserCheckA.js b/common/badBrowserCheckA.js new file mode 100644 index 00000000..3cefa3c3 --- /dev/null +++ b/common/badBrowserCheckA.js @@ -0,0 +1,10 @@ + +// use dates as vars so they're not stripped out by minification +let letCheck = new Date(); +const constCheck = new Date(); +const arrowCheck = (() => new Date())(); + +if (letCheck && constCheck && arrowCheck) { + window.localStorage.setItem('goodBrowser', 'true'); + console.log('badBrowserCheckA: PASS') +} diff --git a/common/badBrowserCheckB.js b/common/badBrowserCheckB.js new file mode 100644 index 00000000..a975ff6d --- /dev/null +++ b/common/badBrowserCheckB.js @@ -0,0 +1,36 @@ +var badBrowser = false; + +try { + // Local storage + window.localStorage.setItem('test', 'test'); + window.localStorage.removeItem('test'); + + // Flexbox + var el = document.createElement('div'); + el.style.display = 'flex'; + if (el.style.display !== 'flex') { + badBrowser = true; + } + + // const and let check from badBrowserCheckA.js + if (window.localStorage.goodBrowser !== 'true') { + badBrowser = true; + } + window.localStorage.removeItem('goodBrowser'); + +} catch (err) { + badBrowser = true; +} + +if (badBrowser) { + console.log('badBrowserCheckB: FAIL'); + var el = document.getElementsByClassName('BadBrowser')[0]; + el.className += ' is-open'; + // Dumb check for known mobile OS's. Not important to catch all, just + // displays more appropriate information. + if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) { + el.className += ' is-mobile'; + } +} else { + console.log('badBrowserCheckB: PASS') +} diff --git a/common/index.html b/common/index.html index 0b00eab7..cac71d94 100644 --- a/common/index.html +++ b/common/index.html @@ -71,40 +71,6 @@ - diff --git a/webpack_config/makeConfig.js b/webpack_config/makeConfig.js index 365c2b09..d9304990 100644 --- a/webpack_config/makeConfig.js +++ b/webpack_config/makeConfig.js @@ -32,6 +32,8 @@ module.exports = function(opts = {}) { // ====== Entry ======= // ==================== const entry = { + badBrowserCheckA: './common/badBrowserCheckA.js', + badBrowserCheckB: './common/badBrowserCheckB.js', client: './common/index.tsx' };