-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
67 lines (64 loc) · 2.27 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<span>Hello 2</span>
<div id="app"></div>
<input type="file" accept="image/*" onchange="change(this)">
<a href="myaxiory://">Link to app</a>
<a href="myaxioryyy://">This is not working</a>
<div id="device"></div>
<button onclick="focusToApp()">Focus to app</button>
<script>
let x = document.getElementById('app');
let isNoMoreActive = true;
function change(e) {
console.log(e.value);
x.innerHTML = e.value;
}
function focusToApp() {
// pokud je aplikace nainstalována provede se přesměrování do aplikace
window.location = "myaxiory://";
// pokud je aplikace nainstalována tak se tato funkce nikdy neprovede
// pokud aplikace není nainstalována vyhodnotí se jestli uživatel je právě na Androidu, iOs a nebo
// na neznámé zařízení. Podle toho také se přesměruje na příslušnou adresu
setTimeout(() => {
if (!isNoMoreActive) {
return;
}
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
if (/android/i.test(userAgent)) {
document.getElementById('device').innerHTML = 'Android';
localStorage.setItem('device', 'android');
window.location = ''; // Android >> play store adresa
return;
}
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
document.getElementById('device').innerHTML = 'iOS';
localStorage.setItem('device', 'ios');
window.location = ''; // iOS >> app store adresa
return;
}
localStorage.setItem('device', 'unknonw');
document.getElementById('device').innerHTML = 'unknown';
window.location = ''; // 'unknown' >> webová aplikace
}, 1000);
}
document.addEventListener('visibilitychange' , function() {
if (document.hidden) {
document.getElementById('device').innerHTML = 'it was off';
isNoMoreActive = false;
}
}, false);
if (!!localStorage.getItem('device')) {
const device = localStorage.getItem('device');
document.getElementById('device').innerHTML = device;
}
</script>
</body>
</html>