forked from byteball/obyte-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenapp.html
160 lines (156 loc) · 6.2 KB
/
openapp.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
<html>
<head>
<link rel="stylesheet" type="text/css" href="https://byteball.org/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="https://byteball.org/css/style.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
text-align: center;
padding-top: 20px;
}
.m10 {
margin-top:10px;
margin-bottom:10px;
float: none;
}
.m20 {
margin-top:20px;
margin-bottom:20px;
float: none;
}
</style>
</head>
<body>
<div class="text-center">
Click the button below to open Byteball app on your device (if installed) and receive funds.
</div>
<div id="warning" class="alert alert-danger m10" style="display: none">
Unfortunately, Byteball Wallet is not yet available for iOS platform. Try to use another device to claim your funds.
</div>
<button id="openInApp" class="btn btn-lg btn-success m10">Receive funds</button>
<br><br>
<div class="text-center">
If you do not have Byteball Wallet installed, download it first and then click the button above.
</div>
<div class="m10">
<div>Download app: </div>
<div class="col-md-8 col-md-offset-2 text-center apps m10">
<div class="app">
<div><a target="_blank" href="https://itunes.apple.com/us/app/byteball/id1147137332?ls=1&mt=8"><img src="img/icon-applestore.svg"></a></div>
<div><a target="_blank" href="https://itunes.apple.com/us/app/byteball/id1147137332?ls=1&mt=8">iOS</a></div>
</div>
<div class="app">
<div><a target="_blank" href="https://play.google.com/store/apps/details?id=org.byteball.wallet"><img src="img/android_robot.svg"></a></div>
<div><a target="_blank" href="https://play.google.com/store/apps/details?id=org.byteball.wallet">Android</a></div>
</div>
<div class="app">
<div><a href="/downloads/Byteball-win64.exe"><img src="img/icon-microsoft.svg"></a></div>
<div><a href="/downloads/Byteball-win64.exe">Windows</a></div>
</div>
<div class="app">
<div><a href="/downloads/Byteball-osx64.dmg"><img src="img/icon-mac-os-x.svg"></a></div>
<div><a href="/downloads/Byteball-osx64.dmg">Mac</a></div>
</div>
<div class="app">
<div><a href="/downloads/Byteball-linux64.zip"><img src="img/linux.png"></a></div>
<div><a href="/downloads/Byteball-linux64.zip">Linux</a></div>
</div>
</div>
</div>
<div class="m20">
If the button doesn't work, open your Byteball Wallet, navigate to <i>Receive</i> → <i>Claim funds using textcoin</i> and paste the following string:<br>
<b id="mnemonic"></b><br>
</div>
<script>
var NativeAppLauncher = (function() {
var IOS_VERSION_RE = /OS\s+(\d)_/;
var timers = [];
var userAgent = window.navigator.userAgent;
var isAndroid = function() {
return /Android/.test(userAgent);
};
var isIOS = function() {
return /(?:i(?:Phone|P(?:o|a)d))/.test(userAgent);
};
var iOSVersion = function() {
return isIOS() ? parseInt(userAgent.match(IOS_VERSION_RE)[1], 10) : 0;
};
var isChrome = function() {
// Opera (OPR) also identifies itself as Chrome and has to be corrected for.
// OPR is used on Android but on iOS it is OPiOS where Opera does NOT identify as Chrome. Go figure!
// Probably because on iOS it is Opera Mini and has all browser have to be based on Safari/WebKit.
return /Chrome/.test(userAgent) && !/OPR/.test(userAgent);
};
var isFirefox = function() {
return /Firefox/.test(userAgent);
};
return {
// Stop any running timers.
clearTimers: function() {
timers.map(clearTimeout);
timers = [];
},
getDeepLink: function() {
return "byteball:" + window.location.hash.substr(1);
},
openApp: function(deeplink, storeURI) {
var launcher = this;
var storeLaunched = false;
var gotStoreURI = "string" == typeof storeURI;
// If this handler is part of the UI thread, i.e. the `direct` result of a user action then
// redirecting to the App Store will happen immediately. When not part of the UI thread however,
// the redirect will bring up an Open in App dialog. Unless there is already a dialog showing,
// in which case the redirect dialog will wait for the currently shown dialog to be dismissed.
gotStoreURI && timers.push(window.setTimeout(function() {
if (!isIOS()) {
storeLaunched = true;
window.top.location = storeURI;
} else {
document.getElementById('warning').style.display = 'block';
}
}, 1000));
isIOS() && timers.push(window.setTimeout(function() {
storeLaunched && window.location.reload()
}, 2000));
window.location = deeplink;
},
// Get the deep link URI to the Byteball app in the store appropriate for the OS.
// Using a deep link guarantees that the app store opens even when using an alternate browser (e.g. Puffin or Firefox)
getStoreURI: function() {
return isAndroid() ?
"market://details?id=org.byteball.wallet&referrer=" + window.location.hash.substr(1).replace("textcoin?", "") :
"https://github.com/byteball/byteball/releases";
},
// Try to launch the native app on iOS/Android. Redirect to the app store if launch fails.
init: function() {
var launcher = this;
var events = ["pagehide", "blur"];
if (isIOS() || (isAndroid() && !isChrome())) {
events.push("beforeunload");
}
function addListenerMulti(element, eventNames, listener) {
var events = eventNames.split(' ');
for (var i = 0, iLen = events.length; i < iLen; i++) {
element.addEventListener(events[i], listener, false);
}
}
addListenerMulti(window, events.join(" "), function(e) {
launcher.clearTimers();
});
document.getElementById('openInApp')
.onclick = function() {
// Detach the app launcher from the UI thread so that the Open in App dialog won't be
// interrupted when the delayed redirect to the App Store fires.
setTimeout(function() {
launcher.openApp.call(launcher, launcher.getDeepLink(), launcher.getStoreURI());
}.bind(this), 0);
return false;
};
document.getElementById('mnemonic').innerHTML = window.location.hash.substr("#textcoin?".length);
}
};
})();
NativeAppLauncher.init();
</script>
</body>
</html>