diff --git a/_scripts/page.js b/_scripts/page.js index 523dc8bf17..f72404e89d 100644 --- a/_scripts/page.js +++ b/_scripts/page.js @@ -38,84 +38,3 @@ export function url () { return basePath } - -/** - * detectedOS - * Returns the OS of the user - * - * @return {String} - OS of the user - */ -export function detectedOS () { - const ua = window.navigator.userAgent - if (ua == null || ua === false) return 'Other' - if (ua.indexOf('Android') >= 0) { - return 'Android' - } - if (ua.indexOf('Mac OS X') >= 0 && ua.indexOf('Mobile') >= 0) { - return 'iOS' - } - if (ua.indexOf('Windows') >= 0) { - return 'Windows' - } - if (ua.indexOf('Mac_PowerPC') >= 0 || ua.indexOf('Macintosh') >= 0) { - return 'macOS' - } - if (ua.indexOf('Linux') >= 0) { - return 'Linux' - } - return 'Unknown' -} - -/** - * detectedArchitecture - * Returns the architecture of the user's device using User-Agent Client Hints API - * - * @return {Promise} - Architecture of the user (ARM or x86) - */ -export async function detectedArchitecture () { - // Try to use the modern User-Agent Client Hints API first - if (navigator.userAgentData && navigator.userAgentData.getHighEntropyValues) { - try { - const values = await navigator.userAgentData.getHighEntropyValues(['architecture']) - - if (values.architecture) { - const arch = values.architecture.toLowerCase() - if (arch.indexOf('arm') >= 0) { - return 'ARM' - } - if (arch.indexOf('x86') >= 0) { - return 'x86' - } - } - } catch (e) { - // Fall through to legacy detection - } - } - - // Fallback to legacy user agent parsing - const ua = window.navigator.userAgent - if (ua == null || ua === false) return 'Unknown' - - // Check for ARM indicators in user agent - if (ua.indexOf('ARM') >= 0 || ua.indexOf('aarch64') >= 0 || ua.indexOf('arm64') >= 0) { - return 'ARM' - } - - // Check for x86/x64 indicators - if (ua.indexOf('x86') >= 0 || ua.indexOf('x64') >= 0 || ua.indexOf('WOW64') >= 0 || ua.indexOf('Win64') >= 0 || ua.indexOf('Intel Mac') >= 0) { - return 'x86' - } - - // Additional platform checks - if (navigator.platform) { - const platform = navigator.platform.toLowerCase() - if (platform.indexOf('arm') >= 0 || platform.indexOf('aarch') >= 0) { - return 'ARM' - } - if (platform.indexOf('x86') >= 0 || platform.indexOf('win') >= 0 || platform.indexOf('mac') >= 0 || platform.indexOf('linux') >= 0) { - return 'x86' - } - } - - return 'Unknown' -} diff --git a/_scripts/pages/download.js b/_scripts/pages/download.js index bb5962a865..303f0c1080 100644 --- a/_scripts/pages/download.js +++ b/_scripts/pages/download.js @@ -7,7 +7,6 @@ import jQuery from '~/lib/jquery' -import { detectedArchitecture } from '~/page' import config from '~/config' import { openDownloadOverlay } from '~/widgets/download-modal' @@ -132,19 +131,27 @@ Promise.all([config, jQuery, openDownloadOverlay]).then(([config, $, openDownloa }) // ACTION: .download-http.click: Track downloads - $('.download-link').click(async function () { + $('.download-link').click(function () { + const $this = $(this) let downloadMethod = 'Unknown' - if ($(this).hasClass('magnet')) { + if ($this.hasClass('magnet')) { downloadMethod = 'Magnet' } - if ($(this).hasClass('http')) { + if ($this.hasClass('http')) { downloadMethod = 'HTTP' } + let downloadArchitecture = 'Unknown' + if ($this.hasClass('arm')) { + downloadArchitecture = 'ARM' + } + if ($this.hasClass('x86')) { + downloadArchitecture = 'x86' + } plausible('Download', { props: { Region: config.user.region, Method: downloadMethod, - Architecture: await detectedArchitecture(), + Architecture: downloadArchitecture, Version: config.release.version } }) diff --git a/_scripts/previous.js b/_scripts/previous.js deleted file mode 100644 index 104de87a12..0000000000 --- a/_scripts/previous.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * _scripts/pages/previous.js - * Tracking for download links - */ - -/* global plausible */ - -import jQuery from '~/lib/jquery' - -import config from '~/config' -import { detectedArchitecture } from '~/page' - -Promise.all([config, jQuery]).then(([config, $]) => { - $(document).ready(() => { - // ACTION: .download-http.click: Track download over HTTP - $('.download-link').click(async function () { - let downloadMethod = 'Unknown' - if ($(this).hasClass('magnet')) { - downloadMethod = 'Magnet' - } - if ($(this).hasClass('http')) { - downloadMethod = 'HTTP' - } - plausible('Download', { - props: { - Region: config.user.region, - Method: downloadMethod, - Architecture: await detectedArchitecture(), - Version: config.previous.version - } - }) - }) - console.log('Loaded previous.js') - }) -}) diff --git a/index.php b/index.php index 08612e03c7..004aaed089 100644 --- a/index.php +++ b/index.php @@ -481,16 +481,16 @@

ARMĀ® 64-bit

Apple Silicon, Raspberry Pi, etc

- - Download + + Download

Intel or AMD 64-bit

Most PCs and older Macs

- - Download + + Download
diff --git a/previous.php b/previous.php index 4cc31702f8..b4fd0fa06d 100644 --- a/previous.php +++ b/previous.php @@ -37,8 +37,8 @@

Thank You for Downloading elementary OS

- Download - + Download +

For help and more info, read the installation guide. If you purchased elementary OS, check your email for a receipt that includes your link to download elementary OS again for free.