-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
357 lines (357 loc) · 12.9 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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta property="og:type" content="website">
<meta property="og:url" content="https://biohzrdmx.github.io/browser-info">
<meta property="og:title" content="browserInfo">
<meta property="og:image" content="share.webp">
<meta property="og:description" content="A small tool to help with support tasks">
<meta property="og:site_name" content="browserInfo">
<meta property="og:locale" content="en_US">
<title>browserInfo</title>
<link rel="shortcut icon" href="favicon.ico">
<link rel="preconnect" href="https://cdnjs.cloudflare.com">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css">
<style>
body {
display: flex;
min-height: 100vh;
flex-direction: column;
}
a {
text-decoration: none;
}
section {
flex: 1 0 0;
}
article {
background: #FAFAFA;
border-radius: 0.25rem;
padding: 1rem;
}
.icon {
display: flex;
background: var(--bs-primary);
color: var(--bs-white);
width: 4rem;
height: 4rem;
border-radius: 4rem;
font-size: 2rem;
align-items: center;
justify-content: center;
margin: 0 auto 1rem;
}
.details strong {
display: block;
}
.details strong::first-letter {
text-transform:capitalize;
}
.details span {
font-size: 0.85em;
display: block;
color: #777;
}
</style>
</head>
<body>
<section>
<div class="container py-1">
<div class="my-3">
<div class="text-center">
<h1 class="mb-0"><img src="logo.svg" width="320" alt="browserInfo"></h1>
<p class="mb-4 mb-lg-5" data-translate="main.text">A small tool to help with support tasks</p>
<div class="details">
<div class="row g-3 mb-5">
<div class="col-lg">
<article class="h-100">
<div class="icon"><i class="js-device-icon fa-solid"></i></div>
<h3 data-translate="device.title">Device</h3>
<div class="mb-2"><span data-translate="device.screen">Screen resolution</span><strong class="js-device-screen">--</strong></div>
<div><span data-translate="device.viewport">Viewport size</span><strong class="js-device-viewport">--</strong></div>
</article>
</div>
<div class="col-lg">
<article class="h-100">
<div class="icon"><i class="js-os-icon fa-brands"></i></div>
<h3 data-translate="os.title">Operating system</h3>
<div class="mb-2"><span data-translate="os.name">Name</span><strong class="js-os-name">--</strong></div>
<div><span data-translate="os.version">Version</span><strong class="js-os-version">--</strong></div>
</article>
</div>
<div class="col-lg">
<article class="h-100">
<div class="icon"><i class="js-browser-icon fa-brands"></i></div>
<h3 data-translate="browser.title">Browser</h3>
<div class="mb-2"><span data-translate="browser.name">Name</span><strong class="js-browser-name">--</strong></div>
<div><span data-translate="browser.version">Version</span><strong class="js-browser-version">--</strong></div>
</article>
</div>
</div>
</div>
<h2 class="mb-1" data-translate="details.title">Working with a developer?</h2>
<p class="mb-3" data-translate="details.text">You can easily copy all the details from above from the following text area to give them to your developer:</p>
<div class="row justify-content-center">
<div class="col-lg-6">
<div class="form-group mb-3">
<textarea name="details" id="details" rows="2" class="form-control js-details" spellcheck="false"></textarea>
<div class="valid-feedback" data-translate="details.copied">Details copied to the clipboard!</div>
</div>
<a href="#" class="btn btn-outline-primary js-copy-details"><i class="fa-solid fa-copy"></i> <span data-translate="details.button">Copy details</span></a>
</div>
</div>
</div>
</div>
</div>
</section>
<footer>
<div class="container py-3">
<div class="text-center">
<div class="row justify-content-center mb-2">
<div class="col-md-3 col-lg-2">
<div class="form-group mb-2">
<select name="locale" id="locale" class="form-select">
<option value="de">Deutsch</option>
<option value="en">English</option>
<option value="es">Español</option>
<option value="fr">Français</option>
<option value="it">Italiano</option>
<option value="pt">Português</option>
</select>
</div>
</div>
</div>
<div><small class="text-muted">Copyright © 2023 biohzrdmx. All rights reserved.</small></div>
<div><small class="text-muted">Source code available at <a href="https://github.com/biohzrdmx/browser-info">GitHub</a> and released under the <a href="https://github.com/biohzrdmx/browser-info/blob/master/LICENSE">MIT</a> license.</small></div>
</div>
</div>
</footer>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/UAParser.js/1.0.34/ua-parser.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
const ua = new UAParser(),
device = ua.getDevice(),
browser = ua.getBrowser(),
os = ua.getOS(),
textarea = $('[name=details]'),
deviceScreen = $('.js-device-screen'),
deviceViewport = $('.js-device-viewport');
// Text labels
$('.js-browser-name').text(browser.name );
$('.js-browser-version').text(browser.version);
$('.js-os-name').text(os.name);
$('.js-os-version').text(os.version);
// Icons
switch (device.type) {
case 'mobile':
$('.js-device-icon').addClass('fa-mobile-screen');
break;
case 'tablet':
$('.js-device-icon').addClass('fa-tablet-screen-button');
break;
case 'smarttv':
$('.js-device-icon').addClass('fa-tv');
break;
default:
$('.js-device-icon').addClass(device.type ? 'fa-microchip' : 'fa-desktop');
break;
}
switch (os.name) {
case 'Windows':
$('.js-os-icon').addClass('fa-windows');
break;
case 'Mac OS':
$('.js-os-icon').addClass('fa-apple');
break;
case 'Android':
$('.js-os-icon').addClass('fa-android');
break;
case 'Linux':
$('.js-os-icon').addClass('fa-linux');
break;
case 'Ubuntu':
$('.js-os-icon').addClass('fa-ubuntu');
break;
default:
$('.js-os-icon').attr('class', 'fa-solid fa-gears');
break;
}
switch (browser.name) {
case 'Firefox':
$('.js-browser-icon').addClass('fa-firefox');
break;
case 'Chrome':
$('.js-browser-icon').addClass('fa-chrome');
break;
case 'Safari':
$('.js-browser-icon').addClass('fa-safari');
break;
case 'Edge':
$('.js-browser-icon').addClass('fa-edge');
break;
default:
$('.js-browser-icon').attr('class', 'fa-solid fa-globe');
break;
}
let details = {
ua: navigator.userAgent,
device: {},
os: {
name: os.name,
version: os.version
},
browser: {
name: browser.name,
version: browser.version
}
};
// Dynamic sizes
const updateSizes = () => {
details.device = {
screen: `${screen.width}x${screen.height}`,
viewport: `${innerWidth}x${innerHeight}`
};
textarea.val( JSON.stringify(details) );
deviceScreen.text(`${screen.width}x${screen.height}`);
deviceViewport.text(`${innerWidth}x${innerHeight}`);
requestAnimationFrame(updateSizes);
};
updateSizes();
// Copy button
$('.js-copy-details').click((e) => {
e.preventDefault();
textarea.select();
if (! textarea.hasClass('is-valid') ) {
textarea.addClass('is-valid');
setTimeout(() => {
textarea.removeClass('is-valid');
textarea.get(0).selectionStart = textarea.get(0).selectionEnd;
}, 1500);
}
document.execCommand('copy');
});
// Localized strings
const locales = {
'de': {
"main.text": "Ein kleines Tool zur Unterstützung bei Support-Aufgaben",
"device.title": "Gerät",
"device.screen": "Bildschirmauflösung",
"device.viewport": "Ansichtsfenstergröße",
"os.title": "Betriebssystem",
"os.name": "Name",
"os.version": "Ausführung",
"browser.title": "Browser",
"browser.name": "Name",
"browser.version": "Ausführung",
"details.title": "Arbeiten Sie mit einem Entwickler zusammen?",
"details.text": "Sie können alle Details von oben einfach aus dem folgenden Textbereich kopieren, um sie Ihrem Entwickler zu geben:",
"details.copied": "Details in die Zwischenablage kopiert!",
"details.button": "Details kopieren"
},
'en': {
"main.text": "A small tool to help with support tasks",
"device.title": "Device",
"device.screen": "Screen resolution",
"device.viewport": "Viewport size",
"os.title": "Operating system",
"os.name": "Name",
"os.version": "Version",
"browser.title": "Browser",
"browser.name": "Name",
"browser.version": "Version",
"details.title": "Working with a developer?",
"details.text": "You can easily copy all the details from above from the following text area to give them to your developer:",
"details.copied": "Details copied to the clipboard!",
"details.button": "Copy details"
},
'es': {
"main.text": "Una pequeña herramienta para ayudar con tareas de soporte",
"device.title": "Dispositivo",
"device.screen": "Resolución de pantalla",
"device.viewport": "Tamaño de ventana",
"os.title": "Sistema operativo",
"os.name": "Nombre",
"os.version": "Versión",
"browser.title": "Navegador",
"browser.name": "Nombre",
"browser.version": "Versión",
"details.title": "¿Trabajas con un desarrollador?",
"details.text": "Puedes copiar fácilmente todos los detalles de arriba desde la siguiente área de texto para dárselos a tu desarrollador:",
"details.copied": "¡Detalles copiados al portapapeles!",
"details.button": "Copiar detalles"
},
'fr': {
"main.text": "Un petit outil pour aider aux tâches de support",
"device.title": "Appareil",
"device.screen": "Résolution d'écran",
"device.viewport": "Taille de la fenêtre",
"os.title": "Système opérateur",
"os.name": "Nom",
"os.version": "Version",
"browser.title": "Navigateur",
"browser.name": "Nom",
"browser.version": "Version",
"details.title": "Travailler avec un développeur?",
"details.text": "Vous pouvez facilement copier tous les détails ci-dessus à partir de la zone de texte suivante pour les donner à votre développeur:",
"details.copied": "Détails copiés dans le presse-papier!",
"details.button": "Copier les détails"
},
'it': {
"main.text": "Un piccolo strumento per aiutare con le attività di supporto",
"device.title": "Dispositivo",
"device.screen": "Risoluzione dello schermo",
"device.viewport": "Dimensioni della finestra",
"os.title": "Sistema operativo",
"os.name": "Nome",
"os.version": "Versione",
"browser.title": "Navigatore",
"browser.name": "Nome",
"browser.version": "Versione",
"details.title": "Lavori con uno sviluppatore?",
"details.text": "Puoi facilmente copiare tutti i dettagli dall'alto dalla seguente area di testo per darli al tuo sviluppatore:",
"details.copied": "Dettagli copiati negli appunti!",
"details.button": "Copia i dettagli"
},
'pt': {
"main.text": "Uma pequena ferramenta para ajudar nas tarefas de suporte",
"device.title": "Dispositivo",
"device.screen": "Resolução da tela",
"device.viewport": "Tamanho da janela de visualização",
"os.title": "Sistema operacional",
"os.name": "Nome",
"os.version": "Versão",
"browser.title": "Navegador",
"browser.name": "Nome",
"browser.version": "Versão",
"details.title": "Trabalhando com um desenvolvedor?",
"details.text": "Você pode facilmente copiar todos os detalhes acima da seguinte área de texto para fornecê-los ao seu desenvolvedor:",
"details.copied": "Detalhes copiados para a área de transferência!",
"details.button": "Copiar detalhes",
}
};
// Locale loading
(() => {
const locale = localStorage.getItem('locale') || 'en';
$('[name="locale"]').val(locale);
})();
// Locale switching
$('[name="locale"]').on('change', (e) => {
const select = $(e.currentTarget),
locale = select.val();
if ( locales[locale] != undefined ) {
localStorage.setItem('locale', locale);
$('[data-translate]').each((index, element) => {
const el = $(element),
key = el.data('translate');
el.text( locales[locale][key] || `Missing string '${key}'` );
});
}
}).trigger('change');
});
</script>
</body>
</html>