-
Notifications
You must be signed in to change notification settings - Fork 3
/
webSeries.js
128 lines (112 loc) · 3.68 KB
/
webSeries.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
let detailsArr=[
{
videoImage:"https://akamaividz2.zee5.com/image/upload/w_1013,h_405,c_scale,f_webp,q_auto:eco/resources/0-6-3284/cover/1920x770ffd5406dde2541ddb0a0d4dcc57ee834.jpg",
name:"Sunflower",
text1:"WATCH",
text2:"BUY NOW"
},
{
videoImage:"https://akamaividz2.zee5.com/image/upload/w_1013,h_405,c_scale,f_webp,q_auto:eco/resources/0-6-4z5145215/cover/1920x770abf42130d9cf41dab2bf9e648cf3193b0b8736722f40431bb31a5214ab98851c.jpg",
name:"The Broken News",
text1:"WATCH",
text2:"BUY NOW"
},
{
videoImage:"https://akamaividz2.zee5.com/image/upload/w_1013,h_405,c_scale,f_webp,q_auto:eco/resources/0-6-1298/cover/1920x770d9ead07e5b304a989d85cf8c6e0113fb.jpg",
name:"Abhay",
text1:"WATCH",
text2:"BUY NOW"
},
{
videoImage:"https://akamaividz2.zee5.com/image/upload/w_1013,h_405,c_scale,f_webp,q_auto:eco/resources/0-6-4z587408/cover/1920x770195db875fe204fa4afe115764b5dc00ba004028948aa4211b107faed649301d7.jpg",
name:"Mithya",
text1:"WATCH",
text2:"BUY NOW"
}
];
let btnNext=document.querySelector("#next");
let btnPrev=document.querySelector("#prev");
let currentBox=0;
let showImg=document.querySelector("#Image");
let Name=document.querySelector("#slider");
let H1=Name.getElementsByTagName("h1");
let toWatch=document.querySelector("#slider>button:nth-child(3)>h4");
let toBuy=document.querySelector("#slider>button:nth-child(4)>h4");
btnNext.addEventListener("click",function(){
goNext(detailsArr);
});
btnPrev.addEventListener("click",function(){
goPrev(detailsArr);
});
function goNext(detailsArr)
{
currentBox++;
if(currentBox===detailsArr.length)
{
currentBox=0;
}
showImg.src=detailsArr[currentBox]["videoImage"];
H1.innerText=detailsArr[currentBox]["name"];
toWatch.innerText=detailsArr[currentBox]["text1"];
toBuy.innerText=detailsArr[currentBox]["text2"];
}
function goPrev(detailsArr)
{
currentBox--;
if(currentBox===-1)
{
currentBox=detailsArr.length-1;
}
showImg.src=detailsArr[currentBox]["videoImage"];
H1.innerText=detailsArr[currentBox]["name"];
toWatch.innerText=detailsArr[currentBox]["text1"];
toBuy.innerText=detailsArr[currentBox]["text2"];
}
const productContainers = [...document.querySelectorAll('.videoContainer')];
const nxtBtn = [...document.querySelectorAll('.nxtBtn')];
const preBtn = [...document.querySelectorAll('.preBtn')];
productContainers.forEach((item, i) => {
let containerDimensions = item.getBoundingClientRect();
let containerWidth = containerDimensions.width;
nxtBtn[i].addEventListener('click', () => {
item.scrollLeft += containerWidth;
})
preBtn[i].addEventListener('click', () => {
item.scrollLeft -= containerWidth;
})
})
let loginValue=JSON.parse(localStorage.getItem("loginContent")) || [];
let bttn=document.querySelectorAll(".videoContainer button");
for(let i=0;i<bttn.length;i++)
{
bttn[i].addEventListener("click",checkToOpen)
}
function checkToOpen()
{
if(loginValue.length>0)
{
location.href="https://www.youtube.com/watch?v=YVvAI08Gmpc&list=PLU2X-6cCyi6Q_lNyfJywvmW1fq74STg5c&index=7&t=850s";
}
else
{
alert("Please login to access the contents!");
}
}
if(loginValue.length>0)
{
let changeLogin=document.querySelector("#lastTab h3");
changeLogin.innerHTML="LOGOUT";
}
document.querySelector("#lastTab").addEventListener("click",loginChanges);
function loginChanges()
{
if(loginValue.length>0)
{
localStorage.removeItem("loginContent");
location.href="homePage.html";
}
else
{
location.href="logIn.html";
}
}