-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinnerfunctionality.js
81 lines (64 loc) · 1.82 KB
/
innerfunctionality.js
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
//edit adress
function edit(){
window.location.href="payment1.html"
}
//address apend
let addressData=JSON.parse(localStorage.getItem("address"));
document.querySelector("#name").innerText=addressData.names;
document.querySelector("#street").innerText=addressData.street;
document.querySelector("#city").innerText=addressData.city;
document.querySelector("#country").innerText=addressData.country;
//Paynow button click
function paynow(event){
event.preventDefault();
timer()
let card_div=document.querySelector("#card_div");
let otp=document.querySelector("#otp");
card_div.style.display="none";
otp.style.display="block";
setTimeout(function(){
alert("Your one time password OTP is 78665")
},5000)
}
function resend(){
setTimeout(function(){
alert("Your one time password OTP is 78665")
},5000)
}
//submit payment
function submit_otp(){
let otp=document.querySelector("#enter_otp").value;
if (otp == "78665") {
let data1 = JSON.parse(localStorage.getItem("cartData"));
data1 = null;
localStorage.setItem("cartData", JSON.stringify(data1));
alert(`
Your order is placed sucessfully
Now You will be redirected to the homepage`);
window.location.href="index.html"
}else
alert(`You have entered wrong otp`)
}
//timer
function timer(){
let min_container=document.querySelector("#timer_min")
let sec_container=document.querySelector("#timer_seconds")
let min=2;
let sec=30;
min_container.innerText=min;
sec_container.innerText=sec;
let id=setInterval(function(){
sec=sec-1;
if(min==0 && sec==0){
alert("Your payment failed");
window.location.hred="#";
clearInterval(id)
}
if(sec==0){
sec=60;
min=min-1;
min_container.innerText=min;
}
sec_container.innerText=sec;
},1000)
}