Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
blender macos detection
/* Get the current operating system. See get_os.js */
let os = getOS();
/* Windows. */
if (os == 'windows') {
showPlatformWarning('This Windows version might not be supported.');
}
else if (os == 'windows-arm') {
showPlatformWarning('Blender is not available for Windows ARM architecture yet.');
}
/* Linux. */
else if (os.startsWith('linux') || os.startsWith('freebsd')) {
/* Set the Download button platform to Linux. */
downloadButtons = document.getElementsByClassName('dl-os-linux');
if (os == 'freebsd') {
showPlatformWarning('There are no official builds for FreeBSD yet.');
}
}
/* macOS. */
else if (os.startsWith('macos') || os.startsWith('ios')) {
/* Set the Download button platform to macOS. */
downloadButtons = document.getElementsByClassName('dl-os-macos');
if (os == 'macos-apple-silicon') {
downloadButtons = document.getElementsByClassName('dl-os-macos-apple-silicon');
/* Safari does not have a reliable way to detect if the system is Intel or Apple Silicon,
* Show Download buttons for both systems for the time being until navigator.gpu is supported. */
let is_safari = navigator.userAgent.indexOf('Safari') > -1 && navigator.userAgent.indexOf('Chrome') <= -1;
if (is_safari) {
downloadButtons = document.querySelectorAll('[class^="dl-header-cta dl-os-macos"]');
}
} else if (os == 'macos-32' || os == 'macos-PPC') {
showPlatformWarning('This macOS version might not be supported.');
}
else if (os == 'ios') {
showPlatformWarning('Blender is not available for iOS yet.');
}
}
/* Show the Download button for the current OS. */
for (var i = 0; i < downloadButtons.length; i++) {
downloadButtons[i].style.display = 'block';
downloadButtons[i].classList.add('active');
}
/* Style the other platforms button, so we can highlight alternative builds on the same platform. */
$('#menu-other-platforms').addClass('dl-other-list-os-' + os);
$('.dl-header-other').addClass('current-os-' + os);
/* Click anywhere on the page to hide these popups. */
$(document).click(function () {
$('.dl-togglable, .js-toggle-menu').removeClass('active');
});
/* Register stats for download. */
$('.js-download').click(function(e){
dl_stats = $(this).attr('dl_stats');
ga('send', 'event', 'button', 'download', dl_stats);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment