forked from ping-pub/faucet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
102 lines (97 loc) · 4.43 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Cosmos SDK Blockchain Faucet</title>
<link rel="icon" href="https://ping.pub/favicon.ico" />
<meta name=”robots” content="index, follow">
<meta name="description" content="Uniform Faucet Tool For Cosmos SDK Blockchains - Powered By Ping.pub">
<meta></head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
</head>
<body>
<div id="app">
<main class="container-md">
<div class="py-5 text-center">
<img id="logo" class="d-block mx-auto mb-4" :src="logo" :alt="`${testnet} Faucet`">
<h1><span id="testnet">{{ testnet }}</span> Faucet</h1>
<p class="lead">Dear, Cosmonauts! <br>
Welcome to our testnet! Are you looking for some tokens to start?
</p>
</div>
<div class="row g-5">
<div class="input-group">
<input id="address" class="form-control" :placeholder="placeholder" v-model="address" name="address">
<button type="button" class="btn btn-secondary d-flex flex-row " @click="requestToken(this)">
<span>
<span id="button-loading" class="spinner-border spinner-border-sm mt-1 mr-1" style="display:none" role="status" aria-hidden="true"></span>
</span>
<span class="sr-only">Request Token</span>
</button>
</div>
</div>
<div id="message" v-html="message"></div>
</main>
<footer class="my-5 pt-5 text-muted text-center text-small">
<p class="mb-1">© 2022 Built By <a href="https://ping.pub">Ping.pub</a><span id="deployer" v-html="deployer"></span></p>
<ul class="list-inline">
<li class="list-inline-item"><a href="https://github.com/ping-pub/faucet.git">Deploy a new instance?</a></li>
</ul>
</footer>
</div>
<script type="module">
import { createApp } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js'
createApp({
data() {
return {
message: '',
testnet: 'Ping Testnet',
logo: 'https://ping.pub/logo.svg',
placeholder: 'Input an address to request token',
deployer: '',
address: ''
}
},
created() {
console.log(this)
fetch("/config.json").then(response => response.json()).then(data => {
this.testnet = data.name
this.logo = data.logo
this.placeholder = `Input an address (e.g.: ${data.sample}) to received tokens`
if(data.deployer) {
this.deployer = `, Hosted By ${data.deployer}`
}
});
},
methods: {
requestToken(obj) {
if (this.address) {
// button state
obj.disabled = true
document.getElementById("button-loading").style.display = 'block';
fetch(`/send/${this.address}`).then(response => response.json()).then(data => {
// button state
obj.disabled = false
document.getElementById("button-loading").style.display = 'none';
// show result
this.message = `
<div class="alert alert-${data.result.code ===0? 'success': 'danger'} alert-dismissible show fade mt-2" role="alert">
<li>${data.result.code ===0? 'Token sent': 'Request failed'}</li>
<textarea class="form-control mt-1" rows="5" style="background-color:transparent">${JSON.stringify(data, null, 2)}</textarea>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
`
});
} else {
this.message = '<span class="text-danger">Address is required</span>'
}
}
}
}).mount('#app')
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>
<script>
</script>
</body>
</html>