|
12 | 12 | href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap&family=Roboto+Mono:wght@400;600&display=swap" |
13 | 13 | rel="stylesheet" |
14 | 14 | /> |
15 | | - <link rel="icon" href="./public/TrayNotificationIcon.svg" type="image/x-icon" /> |
| 15 | + <link |
| 16 | + rel="icon" |
| 17 | + href="./public/TrayNotificationIcon.svg" |
| 18 | + type="image/x-icon" |
| 19 | + /> |
16 | 20 | <script src="https://cdn.tailwindcss.com"></script> |
17 | 21 | <style> |
18 | 22 | body { |
|
28 | 32 | document.addEventListener('DOMContentLoaded', async function () { |
29 | 33 | const translations = { |
30 | 34 | en: { |
31 | | - description: 'Download NethLink update with bug fixes and new features.', |
| 35 | + description: |
| 36 | + 'Download NethLink update with bug fixes and new features.', |
32 | 37 | release: 'Release: ', |
33 | 38 | downloadUpdate: 'Download update', |
34 | | - chooseOS: 'Choose your operating system and click to start the download', |
| 39 | + chooseOS: |
| 40 | + 'Choose your operating system and click to start the download', |
35 | 41 | linux: 'Linux', |
36 | 42 | macos: 'MacOS', |
37 | 43 | windows: 'Windows', |
38 | 44 | feature1: "Don't miss a single call", |
39 | 45 | feature2: 'Speed dials', |
40 | | - feature3: 'All your contacts and Phonebook' |
| 46 | + feature3: 'All your contacts and Phonebook', |
41 | 47 | }, |
42 | 48 | it: { |
43 | 49 | description: |
44 | 50 | "Scarica l'aggiornamento NethLink con correzioni di bug e nuove funzionalità per le impostazioni e lo stato.", |
45 | 51 | release: 'Rilascio: ', |
46 | 52 | downloadUpdate: "Scarica l'aggiornamento", |
47 | | - chooseOS: 'Scegli il tuo sistema operativo e clicca per avviare il download', |
| 53 | + chooseOS: |
| 54 | + 'Scegli il tuo sistema operativo e clicca per avviare il download', |
48 | 55 | linux: 'Linux', |
49 | 56 | macos: 'MacOS', |
50 | 57 | windows: 'Windows', |
51 | 58 | feature1: 'Non perdere una chiamata', |
52 | 59 | feature2: 'Numeri veloci', |
53 | | - feature3: 'Tutti i tuoi contatti e rubrica' |
54 | | - } |
| 60 | + feature3: 'Tutti i tuoi contatti e rubrica', |
| 61 | + }, |
55 | 62 | } |
56 | 63 |
|
57 | 64 | const userLang = navigator.language.startsWith('it') ? 'it' : 'en' |
|
60 | 67 | document.getElementById('description').innerText = t.description |
61 | 68 | document.getElementById('downloadUpdate').innerText = t.downloadUpdate |
62 | 69 | document.getElementById('chooseOS').innerText = t.chooseOS |
63 | | - document.getElementById('linux').querySelector('span').innerText = t.linux |
64 | | - document.getElementById('macos').querySelector('span').innerText = t.macos |
65 | | - document.getElementById('windows').querySelector('span').innerText = t.windows |
| 70 | + document.getElementById('linux').querySelector('span').innerText = |
| 71 | + t.linux |
| 72 | + document.getElementById('macos').querySelector('span').innerText = |
| 73 | + t.macos |
| 74 | + document.getElementById('windows').querySelector('span').innerText = |
| 75 | + t.windows |
66 | 76 | document.getElementById('feature1').innerText = t.feature1 |
67 | 77 | document.getElementById('feature2').innerText = t.feature2 |
68 | 78 | document.getElementById('feature3').innerText = t.feature3 |
69 | 79 |
|
| 80 | + const getMacArchitecture = async () => { |
| 81 | + try { |
| 82 | + if ( |
| 83 | + navigator.userAgentData && |
| 84 | + typeof navigator.userAgentData.getHighEntropyValues === 'function' |
| 85 | + ) { |
| 86 | + const data = await navigator.userAgentData.getHighEntropyValues([ |
| 87 | + 'architecture', |
| 88 | + ]) |
| 89 | + if (data && data.architecture) { |
| 90 | + return data.architecture === 'arm' ? 'arm64' : 'x64' |
| 91 | + } |
| 92 | + } |
| 93 | + return 'x64' |
| 94 | + } catch (error) { |
| 95 | + console.error('Error detecting Mac architecture:', error) |
| 96 | + return 'x64' |
| 97 | + } |
| 98 | + } |
| 99 | + |
70 | 100 | const os = navigator.userAgent |
71 | 101 | let selectedElement |
| 102 | + let selectedIconDownload |
72 | 103 | let currentOS |
| 104 | + let macArchitecture = 'x64' |
| 105 | + |
73 | 106 | if (os.indexOf('Linux') !== -1) { |
74 | 107 | currentOS = 'linux' |
75 | 108 | selectedElement = document.getElementById('linux') |
|
82 | 115 | selectedIconDownload = document.getElementById('macDownloadIcon') |
83 | 116 | selectedElement.classList.add('border-blue-500', 'text-white') |
84 | 117 | selectedIconDownload.classList.add('text-blue-500') |
| 118 | + |
| 119 | + getMacArchitecture().then((arch) => { |
| 120 | + macArchitecture = arch |
| 121 | + }) |
85 | 122 | } else if (os.indexOf('Windows') !== -1) { |
86 | 123 | currentOS = 'windows' |
87 | 124 | selectedElement = document.getElementById('windows') |
|
106 | 143 | const fetchDownloadLinks = async () => { |
107 | 144 | try { |
108 | 145 | const response = await fetch( |
109 | | - 'https://api.github.com/repos/nethesis/nethlink/releases/latest' |
| 146 | + 'https://api.github.com/repos/nethesis/nethlink/releases/latest', |
110 | 147 | ) |
111 | 148 | const data = await response.json() |
112 | 149 |
|
|
120 | 157 | (asset.content_type === 'application/octet-stream' || |
121 | 158 | asset.content_type === 'application/x-msdownload' || |
122 | 159 | asset.content_type === 'application/x-ms-dos-executable') && |
123 | | - !asset.browser_download_url.endsWith('.blockmap') |
| 160 | + !asset.browser_download_url.endsWith('.blockmap'), |
124 | 161 | ) |
125 | 162 | .reduce((acc, asset) => { |
126 | 163 | const url = asset.browser_download_url |
|
129 | 166 | } else if (url.includes('.AppImage')) { |
130 | 167 | acc.linuxUrl = url |
131 | 168 | } else if (url.includes('.dmg')) { |
132 | | - acc.macosUrl = url |
| 169 | + if (url.includes('-arm64.dmg')) { |
| 170 | + acc.macosArmUrl = url |
| 171 | + } else if (url.includes('-x64.dmg')) { |
| 172 | + acc.macosX64Url = url |
| 173 | + } else { |
| 174 | + acc.macosDefaultUrl = url |
| 175 | + } |
133 | 176 | } |
134 | 177 | return acc |
135 | 178 | }, {}) |
136 | 179 |
|
| 180 | + if (currentOS === 'macos') { |
| 181 | + if (macArchitecture === 'arm64' && downloadUrls.macosArmUrl) { |
| 182 | + downloadUrls.macosUrl = downloadUrls.macosArmUrl |
| 183 | + } else if (downloadUrls.macosX64Url) { |
| 184 | + downloadUrls.macosUrl = downloadUrls.macosX64Url |
| 185 | + } else { |
| 186 | + downloadUrls.macosUrl = downloadUrls.macosDefaultUrl |
| 187 | + } |
| 188 | + } |
| 189 | + |
| 190 | + if (!downloadUrls.macosUrl) { |
| 191 | + downloadUrls.macosUrl = |
| 192 | + downloadUrls.macosDefaultUrl || |
| 193 | + downloadUrls.macosX64Url || |
| 194 | + downloadUrls.macosArmUrl |
| 195 | + } |
| 196 | + |
137 | 197 | return downloadUrls |
138 | 198 | } catch (error) { |
139 | 199 | console.error('Cannot retrieve download url', error) |
|
144 | 204 | const downloadLinks = await fetchDownloadLinks() |
145 | 205 | document.getElementById('linux').href = downloadLinks.linuxUrl || '#' |
146 | 206 | document.getElementById('macos').href = downloadLinks.macosUrl || '#' |
147 | | - document.getElementById('windows').href = downloadLinks.windowsUrl || '#' |
| 207 | + document.getElementById('windows').href = |
| 208 | + downloadLinks.windowsUrl || '#' |
148 | 209 | }) |
149 | 210 | </script> |
150 | 211 | </head> |
151 | 212 | <body class="flex items-center justify-center h-screen"> |
152 | 213 | <div class="bg-gray-950 py-14 px-12 rounded-2xl shadow-lg w-full max-w-4xl"> |
153 | 214 | <div class="text-left mb-16 text-gray-200"> |
154 | | - <img src="./public/Nethlink-logo.svg" alt="Nethlink logo" class="mb-4 w-36" /> |
| 215 | + <img |
| 216 | + src="./public/Nethlink-logo.svg" |
| 217 | + alt="Nethlink logo" |
| 218 | + class="mb-4 w-36" |
| 219 | + /> |
155 | 220 | <p id="description" class="mb-1"></p> |
156 | 221 | <p id="release" class="mb-4"></p> |
157 | 222 | </div> |
|
168 | 233 | <i class="fab fa-linux mr-2 fa-xl"></i> <span></span> |
169 | 234 | </div> |
170 | 235 | <div class="download-text" id="linuxDownloadIcon"> |
171 | | - <i class="fa-solid fa-circle-arrow-down fa-xl hover:text-blue-500"></i> |
| 236 | + <i |
| 237 | + class="fa-solid fa-circle-arrow-down fa-xl hover:text-blue-500" |
| 238 | + ></i> |
172 | 239 | </div> |
173 | 240 | </a> |
174 | 241 | <a |
|
192 | 259 | <i class="fab fa-windows mr-2 fa-xl"></i> <span></span> |
193 | 260 | </div> |
194 | 261 | <div class="download-text" id="windowsDownloadIcon"> |
195 | | - <i class="fa-solid fa-circle-arrow-down fa-xl hover:text-blue-500"></i> |
| 262 | + <i |
| 263 | + class="fa-solid fa-circle-arrow-down fa-xl hover:text-blue-500" |
| 264 | + ></i> |
196 | 265 | </div> |
197 | 266 | </a> |
198 | 267 | </div> |
|
0 commit comments