Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions assets/js/browser-incompatibility.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
navigator.browserVersion = (() => {
var ua = navigator.userAgent;
var tem;
var M =
ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) ||
[];
if (/trident/i.test(M[1])) {
tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
return 'IE ' + (tem[1] || '');
}
if (M[1] === 'Chrome') {
tem = ua.match(/\b(OPR|Edge)\/(\d+)/);
if (tem != null) return tem.slice(1).join(' ').replace('OPR', 'Opera');
}
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
tem = ua.match(/version\/(\d+)/i);
if (tem != null) M.splice(1, 1, tem[1]);
return M.join(' ');
})();

const currentBrowser = navigator.browserVersion.split(' ').at(0);
const currentVersion = navigator.browserVersion.split(' ').at(1);

// Minimum version for FULL support. Source - https://caniuse.com/css-nesting
const supportedNestedCSSVersion = {
Safari: 17.2,
Chrome: 112,
Firefox: 117,
Opera: 106,
};

// Set the alert if first time visiting
if (!localStorage.getItem('isBrowserVersionChecked')) {
if (currentVersion < supportedNestedCSSVersion[currentBrowser]) {
alert(
`Incompatible browser\n\nPlease update your browser from ${currentBrowser} ${currentVersion} to ${currentBrowser} ${supportedNestedCSSVersion[currentBrowser]} for full support.`
);
}
localStorage.setItem('isBrowserVersionChecked', true);
}
3 changes: 3 additions & 0 deletions layouts/partials/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
{{ $codecopyv2 := resources.Get "/js/code-copy-v2.js" | fingerprint "sha512" }}
<script src="{{ $codecopyv2.RelPermalink }}" type="text/javascript"></script>

{{ $browserIncompatibility := resources.Get "/js/browser-incompatibility.js" | fingerprint "sha512" }}
<script src="{{ $browserIncompatibility.RelPermalink }}" type="text/javascript"></script>

<!-- load site dropdown js -->
{{ $siteDropdown := resources.Get "/js/site-dropdown.js" | fingerprint "sha512" }}
<script src="{{ $siteDropdown.RelPermalink }}" type="text/javascript"></script>
Expand Down
Loading