This commit is contained in:
Tomasz Sidoruk 2022-06-19 15:01:32 +02:00
parent 26eb6da790
commit 103ec0bb23
3 changed files with 188 additions and 8 deletions

View File

@ -1,5 +1,9 @@
function pickpayment(e){
document.getElementById("dropbtn").innerText=e.target.innerText;
}
document.getElementById("paymentMethodCash").addEventListener("click",pickpayment);
document.getElementById("paymentMethodTransfer").addEventListener("click",pickpayment);
document.getElementById("paymentMethodBitcoin").addEventListener("click",pickpayment);
function checkRole() { function checkRole() {
fetch('https://dragonmaster.pl/inz/user', { fetch('https://dragonmaster.pl/inz/user', {
headers: { headers: {
@ -47,9 +51,14 @@ function login() {
}) })
.catch(error => console.log(error)) .catch(error => console.log(error))
} }
var invoiceid="";
var paymentid="";
function tournamentSave() { function tournamentSave() {
if(document.getElementById("dropbtn").innerText =="Przelew"){
alert("not implemented yet :(");
return;
}
fetch('https://dragonmaster.pl/inz/registration', { fetch('https://dragonmaster.pl/inz/registration', {
method: "PUT", method: "PUT",
headers: { headers: {
@ -57,7 +66,7 @@ function tournamentSave() {
}, },
body: JSON.stringify( body: JSON.stringify(
{ {
"paymentmethod": "cash", "paymentmethod": document.getElementById("dropbtn").innerText =="Gotówka"?"cash":"btc",
"tournament": localStorage.getItem('tournamentId'), "tournament": localStorage.getItem('tournamentId'),
"partner": document.getElementById("ID_input").value "partner": document.getElementById("ID_input").value
} }
@ -66,14 +75,82 @@ function tournamentSave() {
) )
.then(res => { .then(res => {
if (res.ok) { if (res.ok) {
alert("Udało się zapisać!") alert("Udało się zapisać!");
window.location.href = '../index.html' if (document.getElementById("dropbtn").innerText =="Bitcoin") {
}else{
window.location.href = '../index.html';
}
} }
else { console.log("Coś poszło nie tak!") } else { console.log("Coś poszło nie tak!") }
return res return res
}) })
.then(res => res.json()) .then(res => res.json())
.then(res => {
if (document.getElementById("dropbtn").innerText =="Bitcoin") {
paymentid=res.id;
var splited=res.url.split("/");
invoiceid=splited[splited.length-1];
window.btcpay.showInvoice(invoiceid);
window.btcpay.onModalWillLeave(process);
}
})
.catch(error => console.log(error)) .catch(error => console.log(error))
} }
var counter = 0;
function process(){
document.getElementById("loader").style.display="block";
counter = 0;
setTimeout(check, 1000);
}
function check(){
fetch('https://dragonmaster.pl/inz/registration/paymentstatus?id='+paymentid, {
method: "GET",
headers: {
Authorization: ("Bearer " + localStorage.getItem("token"))
}
}
)
.then(res => {
if (res.ok) {
}
else { alert("something not work :("); }
return res
})
.then(res => res.json())
.then(res => {
if (res.status == "DONE" || res.status == "PROCESSING") {
document.getElementById("loader").style.display="none";
document.getElementById("msg").style.display="block";
document.getElementById("msg").innerText="payed";
window.location.href = '../index.html';
}else{
if (res.status == "PENDING" ) {
if(counter==5){
document.getElementById("loader").style.display="none";
document.getElementById("msg").style.display="block";
document.getElementById("msg").innerText="you probably closed popup";
document.getElementById("reopen").style.display="block";
}else{
setTimeout(check, 1000);
}
counter ++;
}else{
document.getElementById("msg").style.display="block";
document.getElementById("msg").innerText=res.status;
document.getElementById("reopen").style.display="block";
}
}
})
.catch(error => console.log(error))
}
function reopen(){
document.getElementById("msg").style.display="none";
document.getElementById("reopen").style.display="none";
window.btcpay.showInvoice(invoiceid);
}
document.getElementById("reopen").addEventListener("click",reopen);

View File

@ -32,7 +32,7 @@
<br> <br>
<div class="dropdown"> <div class="dropdown">
<button class="dropbtn">Gotówka</button> <button id ="dropbtn" class="dropbtn">Gotówka</button>
<div class="dropdown-content"> <div class="dropdown-content">
<a id="paymentMethodCash">Gotówka</a> <a id="paymentMethodCash">Gotówka</a>
<a id="paymentMethodTransfer">Przelew</a> <a id="paymentMethodTransfer">Przelew</a>
@ -50,11 +50,26 @@
</div> </div>
<div class="login_footer"> <div class="login_footer">
<div id="loader" class="loader" style="display:none;">
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
</div> </div>
<div id ="msg" class="loader" style="display:none;">
</div>
<button class="myButton" id="reopen" style="display:none;">
otwóż ponownie
</button>
</div>
</div> </div>
</div> </div>
<script type="text/javascript" src="app.js"></script> <script type="text/javascript" src="app.js"></script>
<script src ="https://btcpay.dragonmaster.pl/modal/btcpay.js"></script>
</body> </body>
</html> </html>

View File

@ -60,6 +60,7 @@ html {
padding-top: 1%; padding-top: 1%;
background-color: #ffffff; background-color: #ffffff;
position: relative;
} }
/*layer 4*/ /*layer 4*/
@ -166,3 +167,90 @@ a:active {
font-weight: 600; font-weight: 600;
font-size: 28px; font-size: 28px;
} }
body {
margin: 0;
}
.loader {
position: absolute;
left:40%;
}
.dot {
width: 24px;
height: 24px;
background: #007c36;
border-radius: 100%;
display: inline-block;
animation: slide 1s infinite;
}
.dot:nth-child(1) {
animation-delay: 0.1s;
background: #007846;
}
.dot:nth-child(2) {
animation-delay: 0.2s;
background: #008c5a;
}
.dot:nth-child(3) {
animation-delay: 0.3s;
background: #00a06e;
}
.dot:nth-child(4) {
animation-delay: 0.4s;
background: #00b482;
}
.dot:nth-child(5) {
animation-delay: 0.5s;
background: #00c896;
}
@-moz-keyframes slide {
0% {
transform: scale(1);
}
50% {
opacity: 0.3;
transform: scale(2);
}
100% {
transform: scale(1);
}
}
@-webkit-keyframes slide {
0% {
transform: scale(1);
}
50% {
opacity: 0.3;
transform: scale(2);
}
100% {
transform: scale(1);
}
}
@-o-keyframes slide {
0% {
transform: scale(1);
}
50% {
opacity: 0.3;
transform: scale(2);
}
100% {
transform: scale(1);
}
}
@keyframes slide {
0% {
transform: scale(1);
}
50% {
opacity: 0.3;
transform: scale(2);
}
100% {
transform: scale(1);
}
}