-
Notifications
You must be signed in to change notification settings - Fork 0
/
buy.js
202 lines (180 loc) · 4.9 KB
/
buy.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
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
const addData = [
{
name: "MUNNA BHAIYA",
mobile: "9424410124",
address: "front of rana house VTP road vivekanand colony MP, India",
pincode: "473551",
city: "shivpuri",
value: "two",
state: "up",
country: "india",
},
{
name: "GUDDU PANDIT",
mobile: "722995792",
address:
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Ab vel tempore ad voluptate? ",
pincode: "123456",
value: "three",
city: "mirzapur",
state: "up",
country: "india",
},
{
name: "BABLU PANDIT",
mobile: "9873442921",
address:
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Ab vel tempore ad voluptate? ",
pincode: "123456",
city: "mirzapur",
state: "up",
value: "three",
country: "india",
},
];
function getAdd() {
let addresss = ``;
addData.forEach(function (adre) {
addresss += `
<div class="feed-div">
<input class="input" name="adress" type="radio" value="${adre.value}" />
<div class="left">
<label for="${adre.value}"
>${adre.name}, ${adre.address}, ${adre.city}, ${adre.state} ${adre.country}, ${adre.pincode}, Phone number: ${adre.mobile}
</label>
</div>
</div>
`;
});
return addresss;
}
function render() {
document.getElementById("feed").innerHTML = getAdd();
}
render();
let addNewAdd = document.getElementById("add");
addNewAdd.addEventListener("click", function (e) {
let show = gsap.timeline();
e.preventDefault();
show.to(".new", {
opacity: 1,
duration: 0.5,
y: "-30px",
zIndex: 99,
});
backbtn.addEventListener("click", function (e) {
e.preventDefault();
e.stopPropagation();
show.reverse();
});
savebtn.addEventListener("click", function (e) {
e.preventDefault();
e.stopPropagation();
show.reverse();
});
});
let backbtn = document.getElementById("back");
backbtn.addEventListener("click", function (e) {
e.preventDefault();
e.stopPropagation();
show.reverse();
});
let savebtn = document.getElementById("save");
savebtn.addEventListener("click", function (e) {
getNewAdress();
});
function getNewAdress() {
let countryin = document.getElementById("country");
let namein = document.getElementById("names");
let mobilein = document.getElementById("mobile");
let pincodein = document.getElementById("pincode");
let addressbarin = document.getElementById("addressbar");
let cityin = document.getElementById("city");
let statein = document.getElementById("state");
addData.unshift({
country: countryin.value,
name: namein.value,
mobile: mobilein.value,
pincode: pincodein.value,
address: addressbarin.value,
value: "four",
city: cityin.value,
state: statein.value,
});
render();
countryin.value = "";
namein.value = "";
mobilein.value = "";
pincodein.value = "";
addressbarin.value = "";
cityin.value = "";
statein.value = "";
}
let useaddbtn = document.getElementById("useaddbtn");
let addiv = document.getElementById("addiv");
useaddbtn.addEventListener("click", function () {
useaddbtn.style.zIndex = -5;
usepayment.style.zIndex = 9;
gsap.to("#addiv", {
height:"70px",
duration:0.6
})
});
const paymentdata = [
{
value: "first method",
upi1: "phonepe",
upi2: "google pay",
upi3: "paytm",
upi4: "amazon pay",
},
];
let usepayment = document.getElementById("usepayment");
usepayment.addEventListener("click", function () {
usepayment.textContent='ORDER'
gsap.to("#paye", {
height:"68px",
duration:0.6
})
usepayment.addEventListener("click", function(){
gsap.to("#feed3",{
height:"210px",
duration:0.6
})
usepayment.textContent='THANKYOU FOR BUYING'
})
});
function getpayment() {
let payment = ``;
paymentdata.forEach(function (pay) {
payment += `
<div class="feed2-div">
<input class="input" name="payment" type="radio" value="${pay.value}" />
<div class="left">
<label for="${pay.value}"
>${pay.upi1}
</div>
<input class="input" name="payment" type="radio" value="${pay.value}" />
<div class="left">
<label for="${pay.value}"
>${pay.upi2}
</div>
<input class="input" name="payment" type="radio" value="${pay.value}" />
<div class="left">
<label for="${pay.value}"
>${pay.upi3}
</div>
<input class="input" name="payment" type="radio" value="${pay.value}" />
<div class="left">
<label for="${pay.value}"
>${pay.upi4}
</div>
</div>
`;
});
return payment;
}
function render2() {
document.getElementById("feed2").innerHTML = getpayment();
}
render2();