forked from diodechain/website
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjoinzone.html
More file actions
198 lines (163 loc) · 7.03 KB
/
Copy pathjoinzone.html
File metadata and controls
198 lines (163 loc) · 7.03 KB
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
---
title: Join Zone
layout: page
class: header--white
permalink: /joinzone/
nav:
---
<script>
(function () {
const url = new URL(window.location.href);
const codePattern = /^[A-Za-z0-9_-]{32,}$/;
const hashValue = (url.hash || "").replace(/^#/, "").trim();
const queryValue = (url.searchParams.get("invite") || url.searchParams.get("code") || "").trim();
const looksLikeCode = (value) => codePattern.test(value);
const inviteCode = looksLikeCode(queryValue) ? queryValue : (looksLikeCode(hashValue) ? hashValue : "");
if (!inviteCode) {
window.location.replace((url.origin + url.pathname).replace(/\/joinzone\/?$/, "/"));
return;
}
// Backwards compatibility: turn /joinzone/#<code> into /joinzone/?invite=<code>
// so the hash remains available for popups like #download-app.
if (!looksLikeCode(queryValue) && looksLikeCode(hashValue)) {
url.hash = "";
url.searchParams.set("invite", inviteCode);
history.replaceState({}, "", url.toString());
}
window.__joinzoneInviteCode = inviteCode;
})();
function CopyToClipboard(id) {
var el = document.getElementById(id);
var text = (el && (el.textContent || el.innerText) || "").trim();
function showNotification() {
document.querySelector("#notify").style.display = "";
setTimeout(function () {
document.querySelector("#notify").style.display = "none";
}, 3000);
}
function legacyCopy(value) {
var tempInput = document.createElement("textarea");
tempInput.value = value;
tempInput.setAttribute("readonly", "");
tempInput.style.position = "fixed";
tempInput.style.top = "0";
tempInput.style.left = "0";
tempInput.style.opacity = "0";
document.body.appendChild(tempInput);
tempInput.select();
try {
document.execCommand("copy");
showNotification();
} catch (err) {
console.error("Could not copy text: ", err);
}
document.body.removeChild(tempInput);
}
if (!text) return;
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(text).then(showNotification, function (err) {
console.error("Could not copy text: ", err);
legacyCopy(text);
});
} else {
legacyCopy(text);
}
}
</script>
<script>
document.addEventListener("DOMContentLoaded", function () {
const getInviteCode = () => window.__joinzoneInviteCode || "";
const inviteCode = getInviteCode();
if (!inviteCode) return;
const deepLink = "ddrive://invite/" + inviteCode;
const joinCodeEl = document.getElementById("joincode");
if (joinCodeEl) joinCodeEl.textContent = inviteCode;
const isAndroid = /Android/i.test(navigator.userAgent);
const isIOS = /iPhone|iPad|iPod/i.test(navigator.userAgent);
const isMobile = isAndroid || isIOS;
const cfgEl = document.getElementById("joinzone-config");
const iosStoreUrl = (cfgEl && cfgEl.dataset && cfgEl.dataset.iosStoreUrl) || "";
const androidStoreUrl = (cfgEl && cfgEl.dataset && cfgEl.dataset.androidStoreUrl) || "";
const downloadCenterUrl = (cfgEl && cfgEl.dataset && cfgEl.dataset.downloadCenterUrl) || "/download/";
const downloadUrl = isIOS ? iosStoreUrl : (isAndroid ? androidStoreUrl : downloadCenterUrl);
document.querySelectorAll("[data-joinzone-download]").forEach((link) => {
link.setAttribute("href", downloadUrl || downloadCenterUrl);
});
const desktopModal = document.getElementById("joinzone-openapp-modal");
const mobileStatus = document.getElementById("joinzone-mobile-status");
const fallback = document.getElementById("joinzone-fallback");
function attemptOpenApp(url) {
try {
window.location.href = url;
} catch (e) {}
// If the app didn't open (blocked, not installed, or user canceled), reveal a fallback CTA.
setTimeout(function () {
if (fallback) fallback.hidden = false;
}, 1500);
}
document.querySelectorAll("[data-joinzone-openinapp]").forEach((link) => {
link.setAttribute("href", deepLink);
link.addEventListener("click", function (e) {
e.preventDefault();
attemptOpenApp(deepLink);
});
});
document.querySelectorAll("[data-joinzone-close]").forEach((button) => {
button.addEventListener("click", function () {
if (desktopModal) desktopModal.hidden = true;
});
});
if (isMobile) {
if (mobileStatus) mobileStatus.hidden = false;
attemptOpenApp(deepLink);
} else {
if (desktopModal) desktopModal.hidden = false;
}
});
</script>
<div
id="joinzone-config"
hidden
data-ios-store-url="{{ site.download.app.ios }}"
data-android-store-url="{{ site.download.app.android }}"
data-download-center-url="{{ site.links.download.url | relative_url }}"
></div>
<div class="joinzone-openapp-modal" id="joinzone-openapp-modal" hidden>
<div class="joinzone-openapp-modal__backdrop" data-joinzone-close></div>
<div class="joinzone-openapp-modal__dialog" role="dialog" aria-modal="true" aria-labelledby="joinzone-openapp-title">
<button type="button" class="joinzone-openapp-modal__close" data-joinzone-close aria-label="Close">×</button>
<h3 class="joinzone-openapp-modal__title" id="joinzone-openapp-title">Open in Diode</h3>
<p class="joinzone-openapp-modal__text">Click below to open the Diode app and join this Zone.</p>
<div class="joinzone-openapp-modal__actions">
<a class="btn" href="#" role="button" data-joinzone-openinapp>Open in App</a>
<a class="btn btn--blank" href="#close" data-joinzone-close>Continue on Web</a>
</div>
<p class="joinzone-openapp-modal__note">No app? <a href="#download-app" class="popup-open" data-joinzone-close>Download Diode</a></p>
</div>
</div>
<div class="text-center joinzone">
<h2 class="title">Join Code</h2>
<hr class="title_line">
<p class="subtitle">Click the "Join" button on the Zones page in Diode and enter this Join Code!</p>
<h3 class="joincode" id="joincode"></h3>
<div class="joinzone__actions">
<a class="btn" href="#" role="button" data-joinzone-openinapp>Open in App</a>
<button onclick="CopyToClipboard('joincode')" class="btn" id="cc-copy">Copy to Clipboard</button>
</div>
<div class="download-prompt" id="notify" role="alert" style="display: none;">
Copied!
</div>
<div class="joinzone__status" id="joinzone-mobile-status" hidden>
Opening Diode…
</div>
<div class="joinzone__fallback" id="joinzone-fallback" hidden>
<p>If Diode didn’t open, you can use the Join Code above or download the app.</p>
<a class="btn" href="{{ site.links.download.url | relative_url }}" data-joinzone-download>Get Diode</a>
</div>
<br/><br/>
<img style="display:block; margin-left:auto; margin-right: auto; width: 520px;" src="{{ 'joinzone/joincode-entry-example.gif' | prepend: site.path.images | relative_url}}" alt="how to join zone with join code">
<p class="download-prompt">Need Diode?</p>
<div>
<a href="#download-app" class="btn popup-open">{{ site.links.download.title }}</a>
</div>
</div>