-
Notifications
You must be signed in to change notification settings - Fork 3
/
deals.js
118 lines (95 loc) · 4.45 KB
/
deals.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
var dealarr=[
{
"img":"https://orderserv-kfc-assets.yum.com/15895bb59f7b4bb588ee933f8cd5344a/images/offers/lg/CHKZINGER.jpg",
"title":"1 Pc free Chicken Zinger on a cart value of 499 or above on first order. Only for registered users.",
"content":"1 Pc free Chicken Zinger on a cart value of 499 or above on first order. Only for registered users.",
"validitiy":"Valid to 31/12/30",
},
{
"img":"https://orderserv-kfc-assets.yum.com/15895bb59f7b4bb588ee933f8cd5344a/images/offers/lg/VEGZINGER.jpg",
"title":"1 Pc free Veg Zinger on a cart value of 499 or above on first order. Only for registered users",
"content":"1 Pc free Veg Zinger on a cart value of 499 or above on first order. Only for registered users",
"validitiy":"Valid to 31/12/30",
},
{
"img":"https://orderserv-kfc-assets.yum.com/15895bb59f7b4bb588ee933f8cd5344a/images/offers/lg/ADDCHK99.jpg",
"title":"Add 2 Pc Hot n Crispy Chicken @ just Rs 99 on min cart value of Rs 499 or more. Applicable on 2nd & 3rd order for signed in user.",
"content":"Add 2 Pc Hot n Crispy Chicken @ just Rs 99 on min cart value of Rs 499 or more. Applicable on 2nd & 3rd order for signed in user.",
"validitiy":"Valid to 01/01/30",
},
{
"img":"https://orderserv-kfc-assets.yum.com/15895bb59f7b4bb588ee933f8cd5344a/images/offers/lg/BIGSAVE.jpg",
"title":"Upto Rs 100 off on min cart value of Rs 599 or more . Applicable on 4th order onwards for signed in user.",
"content":"Upto Rs 100 off on min cart value of Rs 599 or more . Applicable on 4th order onwards for signed in user.",
"validitiy":"Valid to 01/01/24",
},
]
function dealAppend(){
dealarr.map(function(elem){
var card=document.createElement("div");
card.setAttribute("class","card");
var cardimg=document.createElement("div");
cardimg.setAttribute("class","cardImg");
var img=document.createElement("img");
img.src=elem.img;
cardimg.append(img);
var ContentTitle=document.createElement("div");
ContentTitle.setAttribute("class","cardContentTitle");
ContentTitle.innerHTML=elem.title;
var cardContent=document.createElement("div");
cardContent.setAttribute("class","cardContent");
cardContent.innerHTML=elem.content;
var cardButton=document.createElement("div");
cardButton.setAttribute("class","cardButton");
var offerViewDetails=document.createElement("div");
offerViewDetails.setAttribute("class","offerViewDetails");
offerViewDetails.innerHTML="View Details";
offerViewDetails.addEventListener("click",()=>{
modalappend(elem);
})
var a=document.createElement("a");
a.href="./product.html";
var btn= document.createElement("button");
btn.setAttribute("class","redeemButton");
btn.innerHTML="Redeem";
a.append(btn);
cardButton.append(offerViewDetails,a);
card.append(cardimg,ContentTitle,cardContent,cardButton);
document.querySelector(".cardsContainer").append(card);
})
}
dealAppend();
var modal = document.getElementById("myModal");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks the button, open the modal
function modalappend(elem) {
modal.style.display = "block";
document.getElementById("popuptitle").textContent=elem.title;
document.getElementById("validity").textContent=elem.validitiy;
document.getElementById("popupcontent").textContent=elem.content;
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
function navcheck(){
let name = localStorage.getItem("name");
let City = localStorage.getItem("City");
if( name!=null && City!=null ){
document.getElementById("uesr_name").textContent = "";
document.getElementById("uesr_name").append(name);
document.getElementById("btnbtn").innerHTML = null;
document.getElementById("cityname").textContent = "";
document.getElementById("cityname").append(City);
var anchor=document.getElementById("signout_signin");
anchor.href="accountpops.html";
}
}
navcheck();