-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
186 lines (179 loc) · 7.2 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!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>Alt Signet Faucet</title>
<link rel="stylesheet" href="/css/bulma.min.css">
<style>
.word-wrap {
word-wrap: break-word;
word-break: break-all;
}
</style>
</head>
<body>
<nav id="myNav" class="navbar is-fixed-top has-background-dark">
<div class="container">
<div class="navbar-brand">
<a class="navbar-item has-text-white" href="/">
<img src="/images/logo-signet.svg" alt="Signet Faucet" width="57" height="40">
Alt 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 has-background-dark" id="signetNav">
<div class="navbar-start">
<a class="navbar-item has-text-white" href="about.html">About</a>
<a class="navbar-item has-text-white" href="https://github.com/jsarenik/bitcoin-faucet-shell/discussions">Discussion</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">
<!--<p><b>Apologies, this faucet does not work at the moment (2025-01-30). Use the main <a href="https://signetfaucet.com">signetfaucet.com</a> in the meantime.</b></p>-->
<p class="has-text-weight-bold"><b>This is a test network. Coins have no value.</b></p>
<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(pfees9rn5nz|[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>
<div id="cftsWidget"></div>
<button id="sendButton" type="submit" class="button is-primary is-fullwidth has-margin-top-25" tabindex="2" disabled>^ Please wait ^</button>
</form>
<p>Please <a href="about.html">recycle</a> used coins.</p>
<!-- <span style="font-size: xx-small;" class="word-wrap"><code>tb1p4tp4l6glyr2gs94neqcpr5gha7344nfyznfkc8szkreflscsdkgqsdent4</code></span> -->
</div>
</div>
</div>
</div>
</section>
</div>
<script src="/lib/jquery.min.js" async></script>
<script async>
const sendButton = document.getElementById('sendButton');
const myform = document.getElementById('myform');
function readyFn( jQuery ) {
if ( window.jQuery ){
$('#address').focus();
fillburger();
} else {
window.setTimeout("readyFn();",20);
}
}
readyFn();
function faucet_err(msg, mclass="notification is-danger") {
const div = document.getElementById('faucet_err');
div.className = mclass;
div.innerHTML = msg;
}
function eb() {
let cfts = turnstile.getResponse();
if (cfts) {
$('#address').focus();
sendButton.innerHTML = "Press (ENTER) to receive";
sendButton.disabled = false;
}
}
function _turnstileCb() {
turnstile.render('#cftsWidget', {
sitekey: '0x4AAAAAAA36puNDPRXfvPDZ',
callback: function (token) {
eb();
},
});
}
function faucet_fetch() {
let address = document.getElementById('address').value;
let cfts = turnstile.getResponse();
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)}&cfts=${escape(cfts)}`;
faucet_err("- processing -", "");
const sendButton = document.getElementById('sendButton');
sendButton.disabled = true;
myform.reset();
sendButton.innerHTML = "^^ Please wait ^^";
$.ajax({
url,
type: 'GET',
success: function(data) {
turnstile.reset();
sendButton.disabled = true;
myform.reset();
sendButton.innerHTML = "^^ Please wait ^^";
// replace txid with explorer link
let comps = data.split("to ");
// console.log(`comps = ${comps}`);
if (comps.length === 2) {
data = `${comps[0]} to <a href="https://mempool.space/signet/address/${comps[1]}" target="_blank"><code>${comps[1].substr(0, 4)} ${comps[1].substr(4, 4)} ⋯ ${comps[1].substr(-7, 4)} ${comps[1].substr(-3, 2)}</code></a>`;
}
faucet_err(data, "notification is-success");
},
error: function(err) {
turnstile.reset();
sendButton.disabled = true;
myform.reset();
sendButton.innerHTML = "^^ Please wait ^^";
// {"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>
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js?onload=_turnstileCb"></script>
</body>
</html>