Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
81 changes: 0 additions & 81 deletions _scripts/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>} - 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'
}
17 changes: 12 additions & 5 deletions _scripts/pages/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import jQuery from '~/lib/jquery'

import { detectedArchitecture } from '~/page'
import config from '~/config'

import { openDownloadOverlay } from '~/widgets/download-modal'
Expand Down Expand Up @@ -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
}
})
Expand Down
35 changes: 0 additions & 35 deletions _scripts/previous.js

This file was deleted.

8 changes: 4 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,16 +481,16 @@
<h3 class="dialog-option-title">ARM® 64-bit</h3>
<p class="dialog-option-subtitle">Apple Silicon, Raspberry Pi, etc</p>
</div>
<a class="button download-link magnet" title="Torrent Magnet Link" href="<?php echo 'magnet:?xt=urn:btih:'.$config['release_arm_magnet'].'&dn='.$config['release_arm_filename']; ?>&tr=https%3A%2F%2Fashrise.com%3A443%2Fphoenix%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&ws=http%3A<?php echo urlencode($download_link.$config['release_arm_filename']); ?>"><i class="fa fa-magnet"></i></a>
<a class="button download-link http" href="<?php echo $download_link.$config['release_arm_filename']; ?>">Download</a>
<a class="button download-link magnet arm" title="Torrent Magnet Link" href="<?php echo 'magnet:?xt=urn:btih:'.$config['release_arm_magnet'].'&dn='.$config['release_arm_filename']; ?>&tr=https%3A%2F%2Fashrise.com%3A443%2Fphoenix%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&ws=http%3A<?php echo urlencode($download_link.$config['release_arm_filename']); ?>"><i class="fa fa-magnet"></i></a>
<a class="button download-link http arm" href="<?php echo $download_link.$config['release_arm_filename']; ?>">Download</a>
</div>
<div class="dialog-option">
<div class="dialog-option-description">
<h3 class="dialog-option-title">Intel or AMD 64-bit</h3>
<p class="dialog-option-subtitle">Most PCs and older Macs</p>
</div>
<a class="button download-link magnet" title="Torrent Magnet Link" href="<?php echo 'magnet:?xt=urn:btih:'.$config['release_magnet'].'&dn='.$config['release_filename']; ?>&tr=https%3A%2F%2Fashrise.com%3A443%2Fphoenix%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&ws=http%3A<?php echo urlencode($download_link.$config['release_filename']); ?>"><i class="fa fa-magnet"></i></a>
<a autofocus class="button download-link http" href="<?php echo $download_link.$config['release_filename']; ?>">Download</a>
<a class="button download-link magnet x86" title="Torrent Magnet Link" href="<?php echo 'magnet:?xt=urn:btih:'.$config['release_magnet'].'&dn='.$config['release_filename']; ?>&tr=https%3A%2F%2Fashrise.com%3A443%2Fphoenix%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&ws=http%3A<?php echo urlencode($download_link.$config['release_filename']); ?>"><i class="fa fa-magnet"></i></a>
<a autofocus class="button download-link http x86" href="<?php echo $download_link.$config['release_filename']; ?>">Download</a>
</div>
</div>
</dialog>
Expand Down
4 changes: 2 additions & 2 deletions previous.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<h1>Thank You for Downloading elementary OS</h1>
<div class="action-area">
<div class="linked">
<a class="button suggested-action download-link http" href="<?php echo $download_link.$config['previous_filename']; ?>">Download</a>
<a class="button suggested-action download-link magnet" title="Torrent Magnet Link" href="<?php echo 'magnet:?xt=urn:btih:'.$config['previous_magnet'].'&dn='.$config['previous_filename']; ?>&tr=https%3A%2F%2Fashrise.com%3A443%2Fphoenix%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&ws=http:<?php echo $download_link.$config['previous_filename']; ?>"><i class="fa fa-magnet"></i></a>
<a class="button suggested-action download-link http x86" href="<?php echo $download_link.$config['previous_filename']; ?>">Download</a>
<a class="button suggested-action download-link magnet x86" title="Torrent Magnet Link" href="<?php echo 'magnet:?xt=urn:btih:'.$config['previous_magnet'].'&dn='.$config['previous_filename']; ?>&tr=https%3A%2F%2Fashrise.com%3A443%2Fphoenix%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&ws=http:<?php echo $download_link.$config['previous_filename']; ?>"><i class="fa fa-magnet"></i></a>
</div>
</div>
<p>For help and more info, read the <a href="<?php echo $page['lang-root'];?>/docs/installation#installation">installation guide</a>. If you purchased elementary OS, check your email for a receipt that includes your link to download elementary OS again for free.</p>
Expand Down
Loading