-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
292 lines (278 loc) · 11.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>NethLink</title>
<link
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap&family=Roboto+Mono:wght@400;600&display=swap"
rel="stylesheet"
/>
<link
rel="icon"
href="./public/TrayNotificationIcon.svg"
type="image/x-icon"
/>
<script src="https://cdn.tailwindcss.com"></script>
<style>
body {
font-family: 'Poppins', sans-serif;
background-image: url('./public/background.svg');
background-size: cover;
}
.font-mono {
font-family: 'Roboto Mono', monospace;
}
</style>
<script>
document.addEventListener('DOMContentLoaded', async function () {
const translations = {
en: {
description:
'Download NethLink update with bug fixes and new features.',
release: 'Release: ',
downloadUpdate: 'Download update',
chooseOS:
'Choose your operating system and click to start the download',
linux: 'Linux',
macos: 'MacOS',
windows: 'Windows',
feature1: "Don't miss a single call",
feature2: 'Speed dials',
feature3: 'All your contacts and Phonebook',
},
it: {
description:
"Scarica l'aggiornamento NethLink con correzioni di bug e nuove funzionalità per le impostazioni e lo stato.",
release: 'Rilascio: ',
downloadUpdate: "Scarica l'aggiornamento",
chooseOS:
'Scegli il tuo sistema operativo e clicca per avviare il download',
linux: 'Linux',
macos: 'MacOS',
windows: 'Windows',
feature1: 'Non perdere una chiamata',
feature2: 'Numeri veloci',
feature3: 'Tutti i tuoi contatti e rubrica',
},
}
const userLang = navigator.language.startsWith('it') ? 'it' : 'en'
const t = translations[userLang]
document.getElementById('description').innerText = t.description
document.getElementById('downloadUpdate').innerText = t.downloadUpdate
document.getElementById('chooseOS').innerText = t.chooseOS
document.getElementById('linux').querySelector('span').innerText =
t.linux
document.getElementById('macos').querySelector('span').innerText =
t.macos
document.getElementById('windows').querySelector('span').innerText =
t.windows
document.getElementById('feature1').innerText = t.feature1
document.getElementById('feature2').innerText = t.feature2
document.getElementById('feature3').innerText = t.feature3
const getMacArchitecture = async () => {
try {
if (
navigator.userAgentData &&
typeof navigator.userAgentData.getHighEntropyValues === 'function'
) {
const data = await navigator.userAgentData.getHighEntropyValues([
'architecture',
])
if (data && data.architecture) {
return data.architecture === 'arm' ? 'arm64' : 'x64'
}
}
return 'x64'
} catch (error) {
console.error('Error detecting Mac architecture:', error)
return 'x64'
}
}
const os = navigator.userAgent
let selectedElement
let selectedIconDownload
let currentOS
let macArchitecture = 'x64'
if (os.indexOf('Linux') !== -1) {
currentOS = 'linux'
selectedElement = document.getElementById('linux')
selectedIconDownload = document.getElementById('linuxDownloadIcon')
selectedElement.classList.add('border-blue-500', 'text-white')
selectedIconDownload.classList.add('text-blue-500')
} else if (os.indexOf('Mac') !== -1) {
currentOS = 'macos'
selectedElement = document.getElementById('macos')
selectedIconDownload = document.getElementById('macDownloadIcon')
selectedElement.classList.add('border-blue-500', 'text-white')
selectedIconDownload.classList.add('text-blue-500')
getMacArchitecture().then((arch) => {
macArchitecture = arch
})
} else if (os.indexOf('Windows') !== -1) {
currentOS = 'windows'
selectedElement = document.getElementById('windows')
selectedIconDownload = document.getElementById('windowsDownloadIcon')
selectedElement.classList.add('border-blue-500', 'text-white')
selectedIconDownload.classList.add('text-blue-500')
}
document.querySelectorAll('.os-button').forEach((button) => {
button.addEventListener('mouseenter', () => {
if (selectedElement) {
selectedElement.classList.remove('border-blue-500', 'text-white')
selectedElement = null
}
if (selectedIconDownload) {
selectedIconDownload.classList.remove('text-blue-500')
selectedIconDownload = null
}
})
})
const fetchDownloadLinks = async () => {
try {
const response = await fetch(
'https://api.github.com/repos/nethesis/nethlink/releases/latest',
)
const data = await response.json()
const releaseVersion = data.tag_name
document.getElementById('release').innerHTML =
`${t.release}<span class="font-mono">${releaseVersion}</span>`
const downloadUrls = data.assets
.filter(
(asset) =>
(asset.content_type === 'application/octet-stream' ||
asset.content_type === 'application/x-msdownload' ||
asset.content_type === 'application/x-ms-dos-executable') &&
!asset.browser_download_url.endsWith('.blockmap'),
)
.reduce((acc, asset) => {
const url = asset.browser_download_url
if (url.includes('.exe')) {
acc.windowsUrl = url
} else if (url.includes('.AppImage')) {
acc.linuxUrl = url
} else if (url.includes('.dmg')) {
if (url.includes('-arm64.dmg')) {
acc.macosArmUrl = url
} else if (url.includes('-x64.dmg')) {
acc.macosX64Url = url
} else {
acc.macosDefaultUrl = url
}
}
return acc
}, {})
if (currentOS === 'macos') {
if (macArchitecture === 'arm64' && downloadUrls.macosArmUrl) {
downloadUrls.macosUrl = downloadUrls.macosArmUrl
} else if (downloadUrls.macosX64Url) {
downloadUrls.macosUrl = downloadUrls.macosX64Url
} else {
downloadUrls.macosUrl = downloadUrls.macosDefaultUrl
}
}
if (!downloadUrls.macosUrl) {
downloadUrls.macosUrl =
downloadUrls.macosDefaultUrl ||
downloadUrls.macosX64Url ||
downloadUrls.macosArmUrl
}
return downloadUrls
} catch (error) {
console.error('Cannot retrieve download url', error)
return {}
}
}
const downloadLinks = await fetchDownloadLinks()
document.getElementById('linux').href = downloadLinks.linuxUrl || '#'
document.getElementById('macos').href = downloadLinks.macosUrl || '#'
document.getElementById('windows').href =
downloadLinks.windowsUrl || '#'
})
</script>
</head>
<body class="flex items-center justify-center h-screen">
<div class="bg-gray-950 py-14 px-12 rounded-2xl shadow-lg w-full max-w-4xl">
<div class="text-left mb-16 text-gray-200">
<img
src="./public/Nethlink-logo.svg"
alt="Nethlink logo"
class="mb-4 w-36"
/>
<p id="description" class="mb-1"></p>
<p id="release" class="mb-4"></p>
</div>
<div class="text-gray-200">
<p id="downloadUpdate" class="font-medium text-2xl leading-5 mb-3"></p>
<p id="chooseOS" class="mb-4 leading-5"></p>
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4">
<a
id="linux"
href="#"
class="os-button text-gray-200 py-3 px-3 rounded-lg inline-flex items-center justify-between border-2 border-gray-600 hover:border-blue-500 hover:text-blue-500"
>
<div class="flex items-center text-gray-200">
<i class="fab fa-linux mr-2 fa-xl"></i> <span></span>
</div>
<div class="download-text" id="linuxDownloadIcon">
<i
class="fa-solid fa-circle-arrow-down fa-xl hover:text-blue-500"
></i>
</div>
</a>
<a
id="macos"
href="#"
class="os-button text-gray-200 py-3 px-3 rounded-lg inline-flex items-center justify-between border-2 border-gray-600 hover:border-blue-500 hover:text-blue-500"
>
<div class="flex items-center text-gray-200">
<i class="fab fa-apple mr-2 fa-xl"></i> <span></span>
</div>
<div class="download-text" id="macDownloadIcon">
<i class="fa-solid fa-circle-arrow-down fa-xl"></i>
</div>
</a>
<a
id="windows"
href="#"
class="os-button text-gray-200 py-3 px-3 rounded-lg inline-flex items-center justify-between border-2 border-gray-600 hover:border-blue-500 hover:text-blue-500"
>
<div class="flex items-center text-gray-200">
<i class="fab fa-windows mr-2 fa-xl"></i> <span></span>
</div>
<div class="download-text" id="windowsDownloadIcon">
<i
class="fa-solid fa-circle-arrow-down fa-xl hover:text-blue-500"
></i>
</div>
</a>
</div>
</div>
<div class="relative py-8">
<div class="absolute inset-6 flex items-center" aria-hidden="true">
<div class="w-full border-t border-gray-700"></div>
</div>
</div>
<div
class="flex flex-col sm:flex-row justify-center items-center text-gray-200 space-y-4 sm:space-y-0 space-x-8 pb-8"
>
<div class="flex items-center">
<i class="fas fa-solid fa-phone mr-2 fa-lg"></i>
<span id="feature1" class="text-xs"></span>
</div>
<div class="flex items-center">
<i class="fas fa-bolt mr-2 fa-lg"></i>
<span id="feature2" class="text-xs"></span>
</div>
<div class="flex items-center space-x-1">
<i class="fas fa-address-book mr-2 fa-lg"></i>
<span id="feature3" class="text-xs"></span>
</div>
</div>
</div>
</body>
</html>