-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathindex.html
73 lines (70 loc) · 2.29 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
<!DOCTYPE html>
<html style="background-color: #eee">
<head>
<title>dat-gateway</title>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/bulma@0.7.4/css/bulma.css">
<link rel="stylesheet" type="text/css" href="https://unpkg.com/font-awesome@4.7.0/css/font-awesome.css">
<script>
function handleLoaded() {
registerProtocol();
autoNavigate();
}
function registerProtocol() {
try {
navigator.registerProtocolHandler(
"dat",
location.href + "?url=%s",
"Dat Gateway Redirection"
)
} catch(e) {
console.error("Couldn't register protocol handler");
console.error(e);
}
}
function autoNavigate() {
// Attempt to load the Dat URL from the querystring
var parsedURL = new URL(window.location.href)
var toNavigate = parsedURL.searchParams.get("url")
if (toNavigate) {
document.querySelector("input").value = toNavigate;
}
}
function navigateUrl() {
var url = document.querySelector("input").value;
var cleaned = url.replace(/^dat:\/\//, "");
window.location.href = "/" + cleaned;
return false;
}
</script>
</head>
<body onload="return handleLoaded()">
<section class="section">
<div class="container box" style="max-width:480px">
<h1 class="title">dat-gateway</h1>
<p class="subtitle">portal to a decentralized web</p>
<div class="content">
<p>You can use this gateway to visit content hosted over the p2p <a href="https://datproject.org/">Dat</a> protocol.</p>
<p>So why not visit something?</p>
<p>Enter Dat keys in the URL like this: <code>/:key/:path</code> or use the form below.</p>
<p>
<form onsubmit="return navigateUrl()">
<div class="field has-addons">
<div class="control is-expanded">
<input class="input" placeholder="dat://">
</div>
<div class="control">
<button class="button is-info">Go!</button>
</div>
</div>
</form>
</p>
<p>
<small>
View <a href="https://github.com/garbados/dat-gateway">the source</a>.
</small>
</p>
</div>
</div>
</section>
</body>
</html>