-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
171 lines (157 loc) · 6.76 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96">
<title>Signet Faucet</title>
<link rel="stylesheet" href="/css/main.css">
</head>
<body>
<nav id="myNav" class="navbar is-fixed-top">
<div class="container">
<div class="navbar-brand">
<a class="navbar-item" href="/">
<img src="/images/logo-signet.svg" alt="Signet Faucet" width="57" height="40">
Signet Faucet
</a>
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="signetNav">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div class="navbar-menu" id="signetNav">
<div class="navbar-start">
<a class="navbar-item" href="about.html">About</a>
<a class="navbar-item" href="https://bin.bublina.eu.org/?68dbfa5698fcf316#6KBGZkWssS3TrzTVg93K7VCQECBTmwKn2x9WjRYV72rn">Comments</a>
</div>
</div>
</div>
</nav>
<div class="content">
<!-- body-->
<section class="section">
<div class="container">
<div class="columns is-centered">
<div class="column is-6-desktop is-8-tablet">
<div class="box has-text-centered">
<h3 class="title is-size-4-desktop is-size-5">Enter address</h3>
<div id="faucet_err"></div>
<form id="myform" action="javascript:faucet_fetch();" autocomplete="off">
<div class="field has-margin-top-25">
<div class="control">
<input class="input" id="address" name="address" type="text" placeholder="tb1[pq]... or [mn]... or 2..." tabindex="1" autocapitalize="off" autocorrect="off" pattern="^(tb1([02-9ac-hj-np-z]{59}|[02-9ac-hj-np-z]{39})|[mn2][a-km-zA-HJ-NP-Z1-9]{25,34})$" title="Use a valid signet address (legacy, p2sh-segwit, bech32 or bech32m).">
</div>
</div>
<button id="sendButton" class="button is-primary is-fullwidth has-margin-top-25" tabindex="2">Press ENTER to send</button>
</form>
<p>Please <a href="about.html">recycle</a> used coins.</p>
</div>
</div>
</div>
</div>
</section>
</div>
<footer class="footer has-text-centered">
<div class="container">
<div class="columns rv-padding">
<div class="column has-text-left-tablet sponsor">
<p><a href="https://www.dglab.com/en" target="_blank">
<img src="/images/dglab_logo.svg" alt="DG Lab" height="50" width="50">
</a></p>
</div>
<div class="column has-text-center has-text-right-tablet copyright">
<div class="copyright__text">
<p class="is-size-7">Copyright © DG Lab All rights reserved.</p>
</div>
</div>
</div>
</div>
</footer>
<script src="/lib/jquery.min.js" async></script>
<script async>
function readyFn( jQuery ) {
if ( window.jQuery ){
$('#address').focus();
fillburger();
} else {
window.setTimeout("readyFn();",20);
}
}
readyFn();
function faucet_err(msg, mclass="notification is-danger is-light") {
const div = document.getElementById('faucet_err');
div.className = mclass;
div.innerHTML = msg;
}
function faucet_fetch() {
let address = document.getElementById('address').value;
address.oninvalid = function(event) {
event.target.setCustomValidity('Username should only contain lowercase letters. e.g. john');
}
if (!address) return faucet_err("Enter an address");
let url = `/claim/?address=${escape(address)}`;
faucet_err("- processing -", "");
const sendButton = document.getElementById('sendButton');
sendButton.disabled = true;
$.ajax({
url,
type: 'GET',
success: function(data) {
sendButton.disabled = false;
// replace txid with explorer link
let comps = data.split("txid ");
console.log(`comps = ${comps}`);
if (comps.length === 2) {
data = `${comps[0]}txid <a href="https://ex.signet.bublina.eu.org/tx/${comps[1]}" target="_blank">${comps[1].substr(0, 10)}...</a>`;
}
faucet_err(data, "notification is-success is-light");
},
error: function(err) {
sendButton.disabled = false;
// {"readyState":4,
// "responseText":"{\"message\":\"Please slow down\"}",
// "responseJSON":{"message":"Please slow down"},
// "status":400,
// "statusText":"error"}
var msg = "";
if (err.status) {
msg += err.status + ": ";
}
if (err.responseJSON && err.responseJSON.message) {
msg += err.responseJSON.message;
return faucet_err("Error: " + msg);
}
if (err.responseText) {
msg += err.responseText;
return faucet_err("Error: " + msg);
}
faucet_err(msg + JSON.stringify(err));
}
});
}
function fillburger() {
// Get all "navbar-burger" elements
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
// Check if there are any navbar burgers
if ($navbarBurgers.length > 0) {
// Add a click event on each of them
$navbarBurgers.forEach( el => {
el.addEventListener('click', () => {
// Get the target from the "data-target" attribute
const target = el.dataset.target;
const $target = document.getElementById(target);
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
}
}
</script>
</body>
</html>