Created
October 21, 2022 15:45
-
-
Save lukaso/53f60146ffbb5259012a5c7f703f76c6 to your computer and use it in GitHub Desktop.
blender macos detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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