@@ -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