Skip to content

Commit 6a7cbdb

Browse files
author
SPRINX0\prochazka
committed
os detection
1 parent 35bfd61 commit 6a7cbdb

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

assets/css/_layout.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,18 @@ div.highlight {
125125
margin-bottom: 0.75rem;
126126
}
127127
}
128+
129+
// Special styling for user's OS section
130+
.user-os-section {
131+
border: 2px solid #28a745;
132+
background: linear-gradient(135deg, #f8fff9 0%, #ffffff 100%);
133+
134+
&:hover {
135+
box-shadow: 0 8px 25px rgba(40, 167, 69, 0.15);
136+
}
137+
138+
.os-icon-container {
139+
background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
140+
box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
141+
}
142+
}

layouts/shortcodes/download.html

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,18 @@ <h2>Download DbGate Community</h2>
2929

3030
{{ $items := index .Site.Data.download }}
3131

32+
<div id="download-sections-container">
3233
{{ range $items }}
3334
{{ $osname := .text }}
34-
<div class="download-section mb-6">
35+
<div class="download-section mb-6" data-os="{{.text}}">
3536
<div class="os-header">
3637
<div class="os-icon-container">
3738
<i class="{{.icon}} os-icon"></i>
3839
</div>
3940
<div class="os-info">
40-
<h3 class="os-name">{{.text}}</h3>
41+
<h3 class="os-name">
42+
{{.text}}
43+
</h3>
4144
<p class="os-description">{{ if eq .text "Windows" }}Compatible with Windows 10, 11 and Server editions{{ else if eq .text "Linux" }}Supports major Linux distributions{{ else if eq .text "MacOS" }}For macOS 10.15 Catalina and later{{ else if eq .text "Web" }}Platform-independent solutions{{ else if eq .text "Source code" }}Build from source{{ end }}</p>
4245
</div>
4346
</div>
@@ -65,6 +68,7 @@ <h3 class="os-name">{{.text}}</h3>
6568
</div>
6669
</div>
6770
{{ end }}
71+
</div>
6872

6973

7074

@@ -221,4 +225,49 @@ <h2>Please provide your e-mail address</h2>
221225
window.closeDownloadData = null;
222226
}, 1000);
223227
}
228+
229+
// OS Detection and Reordering
230+
function detectOS() {
231+
const userAgent = navigator.userAgent;
232+
const platform = navigator.platform;
233+
234+
if (userAgent.indexOf('Win') !== -1 || platform.indexOf('Win') !== -1) {
235+
return 'Windows';
236+
} else if (userAgent.indexOf('Mac') !== -1 || platform.indexOf('Mac') !== -1) {
237+
return 'MacOS';
238+
} else if (userAgent.indexOf('Linux') !== -1 || platform.indexOf('Linux') !== -1) {
239+
return 'Linux';
240+
}
241+
return null;
242+
}
243+
244+
function reorderDownloadSections() {
245+
const detectedOS = detectOS();
246+
if (!detectedOS) return;
247+
248+
const container = document.getElementById('download-sections-container');
249+
const sections = Array.from(container.querySelectorAll('.download-section'));
250+
251+
// Find the section for the detected OS
252+
const userOSSection = sections.find(section =>
253+
section.getAttribute('data-os') === detectedOS
254+
);
255+
256+
if (userOSSection) {
257+
// Add "Your OS" badge
258+
const badge = userOSSection.querySelector('.your-os-badge');
259+
if (badge) {
260+
badge.style.display = 'inline-block';
261+
}
262+
263+
// Add special styling to user's OS section
264+
userOSSection.classList.add('user-os-section');
265+
266+
// Move to the top
267+
container.insertBefore(userOSSection, container.firstChild);
268+
}
269+
}
270+
271+
// Run OS detection when page loads
272+
document.addEventListener('DOMContentLoaded', reorderDownloadSections);
224273
</script>

0 commit comments

Comments
 (0)