Skip to content

Commit 7ccea82

Browse files
Read UA via backend, remove detection via js
1 parent e19bf00 commit 7ccea82

2 files changed

Lines changed: 27 additions & 21 deletions

File tree

public_html/index.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,31 @@
8484
<div class="build-btn-button">
8585
<div class="build-ico-button">
8686
<div class="build-ico-os">
87-
<img alt="Windows" src="img/icons/list/os-windows-11.png" style='height: 100%; width: 100%; object-fit: contain'/>
88-
<img alt="Linux" src="img/icons/list/os-linux-na.png" style='height: 100%; width: 100%; object-fit: contain; display:none;'/>
89-
<img alt="macOS" src="img/icons/list/os-macos.png" style='height: 100%; width: 100%; object-fit: contain; display:none;'/>
90-
<img alt="FreeBSD" src="img/icons/list/os-bsd.png" style='height: 100%; width: 100%; object-fit: contain; display:none;'/>
87+
<?php
88+
89+
$os_icons = [
90+
'Windows' => 'img/icons/list/os-windows-11.png',
91+
'Linux' => 'img/icons/list/os-linux-na.png',
92+
'macOS' => 'img/icons/list/os-macos.png',
93+
'FreeBSD' => 'img/icons/list/os-bsd.png',
94+
];
95+
96+
$os_name = $os_icon = null;
97+
$ua = $_SERVER['HTTP_USER_AGENT'] ?? '';
98+
99+
if (str_contains($ua, 'FreeBSD')) { $os_name = 'FreeBSD'; $os_icon = $os_icons['FreeBSD']; }
100+
elseif (str_contains($ua, 'Windows')) { $os_name = 'Windows'; $os_icon = $os_icons['Windows']; }
101+
elseif (str_contains($ua, 'Mac OS X')) { $os_name = 'macOS'; $os_icon = $os_icons['macOS']; }
102+
elseif (str_contains($ua, 'Linux') && !str_contains($ua, 'Android')) { $os_name = 'Linux'; $os_icon = $os_icons['Linux']; }
103+
?>
104+
105+
<?php if ($os_icon !== null): ?>
106+
<img alt="<?= $os_name ?>" src="<?= $os_icon ?>" style='height: 100%; width: 100%; object-fit: contain'/>
107+
<?php else: ?>
108+
<?php $first = true; foreach ($os_icons as $name => $icon): ?>
109+
<img alt="<?= $name ?>" src="<?= $icon ?>" style='height: 100%; width: 100%; object-fit: contain<?= $first ? '' : '; display:none' ?>'/>
110+
<?php $first = false; endforeach; ?>
111+
<?php endif; ?>
91112
</div>
92113
</div>
93114
<a href="/download">

public_html/lib/js/inc-anim.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,29 +53,14 @@ $(document).ready(function () {
5353
{ selector: '.handheld-img-screen', interval: 5000 } // Handheld screens for download button
5454
];
5555

56-
const intervals = {};
5756
cyclers.forEach(function ({ selector, interval }) {
57+
if ($(`${selector} img`).length <= 1) return;
5858
$(`${selector} img:gt(0)`).hide();
59-
intervals[selector] = setInterval(function () {
59+
setInterval(function () {
6060
$(`${selector} :first-child`).fadeOut(200)
6161
.next().fadeIn(200).end().appendTo(selector);
6262
}, interval);
6363
});
64-
65-
// Platform detection: only show the user's OS icon for download button
66-
const ua = navigator.userAgent;
67-
let platform;
68-
if (ua.includes('FreeBSD')) platform = 'FreeBSD';
69-
else if (ua.includes('Windows')) platform = 'Windows';
70-
else if (ua.includes('Mac OS X')) platform = 'macOS';
71-
else if (ua.includes('Linux') && !ua.includes('Android')) platform = 'Linux';
72-
73-
if (platform) {
74-
clearInterval(intervals['.build-ico-os']);
75-
const $osImgs = $('.build-ico-os img');
76-
$osImgs.not('[alt="' + platform + '"]').hide();
77-
$osImgs.filter('[alt="' + platform + '"]').show();
78-
}
7964
});
8065
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
8166
// Theme menu fade-out and fade-in animations

0 commit comments

Comments
 (0)