-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
318 lines (242 loc) · 8 KB
/
index.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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
//side-bar
const sideItems = document.querySelectorAll('.side-items');
const message = document.querySelector('.message');
const messages = document.querySelector('.messages ');
//customization
const theme = document.querySelector('.theme');
const Customization = document.querySelector('.Custom');
const color = document.querySelector('.color');
//message search
const messageSearch = document.querySelector('#message-search');
//fontsize
const fontSize = document.querySelector(".sizing span ");
var root = document.querySelector(":root");
//const array=Array.from(fontSize);
//colorpallete
const colorPallete=document.querySelector('.colors');
const array2=Array.from(colorPallete);
//background
const bg1=document.querySelector(".bg-1");
const bg2=document.querySelector(".bg-2");
const bg3=document.querySelector(".bg-3");
//color
const yellow=document.querySelector(".YELLOW");
const purple=document.querySelector(".PURPLE");
const red=document.querySelector(".RED");
const green=document.querySelector(".GREEN");
const skyblue=document.querySelector(".SKY-BLUE");
//change font
const font1=document.querySelector(".fonts-1");
const font2=document.querySelector(".fonts-2");
const font3=document.querySelector(".fonts-3");
const font4=document.querySelector(".fonts-4");
const font5=document.querySelector(".fonts-5");
//remove active class from all side-items
const changeActiveItem = () => {
sideItems.forEach(items => {
items.classList.remove('active');
})
}
//=====active class and notification popup====//
sideItems.forEach(items => {
items.addEventListener('click', () => {
changeActiveItem();
items.classList.add('active');
if (items.id != "notification") {
document.querySelector('.notification-pop').style.display = 'none';
}
else {
document.querySelector('.notification-pop').style.display = 'block';
document.querySelector('#notification .notification-count').style.display = 'none';
}
})
}
)
//=====MESSAGE====//
const searchMessage = () => {
const val = messageSearch.value.toLowerCase();
message.forEach(chat => {
let name=chat.querySelector('h5').textContent.toLowerCase();
if(name.indexOf(val) != -1){
chat.style.display = 'flex';
} else{
chat.style.display = 'none';
}
})
}
//===search msg===//
messageSearch.addEventListener('keyup', messageSearch);
//====message card highlight====//
message.addEventListener('click', () => {
messages.style.boxShadow = '0 0 1rem var(--color-primary)';
setTimeout(() => {
messages.style.boxShadow = 'none';
}, 2000);
document.querySelector('.message .notification-count').style.display = 'none';
});
//=== open theme cutomization===/
theme.addEventListener('click', () => {
Customization.style.display = 'grid';
})
//closes theme
const closetheme = (e) => {
if (e.target.classList.contains("Custom")) {
Customization.style.display = "none";
}
}
//close theme
Customization.addEventListener('click', closetheme);
//===theme customization color====//
//colorPallete.forEach(color => {
//color.addEventListener('click', () => {
//changecolor();
//});
//change every color using addeventlistener
yellow.addEventListener('click',()=>{
removeCactive();
yellow.classList.toggle("active");
let primaryHue;
primaryHue =61;
root.style.setProperty('--primary-color-hue',primaryHue);
})
purple.addEventListener('click',()=>{
removeCactive();
purple.classList.toggle("active");
let primaryHue;
primaryHue =290;
root.style.setProperty('--primary-color-hue',primaryHue);
})
red.addEventListener('click',()=>{
removeCactive();
red.classList.toggle("active");
let primaryHue;
primaryHue =358;
root.style.setProperty('--primary-color-hue',primaryHue);
})
green.addEventListener('click',()=>{
removeCactive();
green.classList.toggle("active");
let primaryHue;
primaryHue =110;
root.style.setProperty('--primary-color-hue',primaryHue);
})
skyblue.addEventListener('click',()=>{
removeCactive();
skyblue.classList.toggle("active");
let primaryHue;
primaryHue =183;
root.style.setProperty('--primary-color-hue',primaryHue);
})
//})
yellow.addEventListener('click', ()=>{
let primaryHue;
primaryHue=61;
root.style.setProperty('--primary-color-hue',primaryHue);
});
//change fonts using addeventlistner
font1.addEventListener('click',()=>{
removeActiveClass();
font1.classList.toggle('active');
let fontsize;
fontsize = '10px';
root.style.setProperty('----sticky-top-left','5.4rem');
root.style.setProperty('----sticky-top-right','5.4rem');
document.querySelector('html').style.fontSize = fontsize;
} )
font2.addEventListener('click',()=>{
removeActiveClass();
let fontsize;
font2.classList.toggle('active');
fontsize = '13px';
root.style.setProperty('----sticky-top-left','5.4rem');
root.style.setProperty('----sticky-top-right','-7rem');
document.querySelector('html').style.fontSize= fontsize;
} )
font3.addEventListener('click',()=>{
removeActiveClass();
let fontsize;
font3.classList.toggle('active');
fontsize = '16px';
root.style.setProperty('----sticky-top-left','-2rem');
root.style.setProperty('----sticky-top-right','-17rem');
document.querySelector('html').style.fontSize = fontsize;
} )
font4.addEventListener('click',()=>{
removeActiveClass();
let fontsize;
font4.classList.toggle('active');
fontsize = '19px';
root.style.setProperty('----sticky-top-left','-5rem');
root.style.setProperty('----sticky-top-right','-25rem');
document.querySelector('html').style.fontSize = fontsize;
} )
font5.addEventListener('click',()=>{
removeActiveClass();
let fontsize;
font5.classList.toggle('active');
fontsize = '22px';
root.style.setProperty('----sticky-top-left','-12rem');
root.style.setProperty('----sticky-top-right','-35rem');
document.querySelector('html').style.fontSize = fontsize;
} )
//remove active class from color elements
const removeCactive=()=>{
yellow.classList.remove("active");
purple.classList.remove("active");
red.classList.remove("active");
green.classList.remove("active");
skyblue.classList.remove("active");
}
//remove active class from size elements
const removeActiveClass = () =>{
font1.classList.remove('active');
font2.classList.remove('active');
font3.classList.remove('active');
font4.classList.remove('active');
font5.classList.remove('active');
}
//background theme
let lightlightness;
let darklightness;
let whitelightness;
//change active of bg
const changeActivebg=()=>{
bg1.classList.remove('active');
bg2.classList.remove('active');
bg3.classList.remove('active');
}
//change background
const changeBg = ()=>{
root.style.setProperty('--light-color-lightness', lightlightness);
root.style.setProperty('--dark-color-lightness', darklightness);
root.style.setProperty('--white-color-lightness', whitelightness);
}
bg2.addEventListener('click', ()=>{
lightlightness='15%';
darklightness='95%';
whitelightness='20%';
changeActivebg();
//add active
bg2.classList.toggle('active');
//remove active
changeBg();
});
bg1.addEventListener('click', ()=>{
changeActivebg();
//add active
bg1.classList.toggle('active');
//remove active
//remove customized changes from local storage
window.location.reload();
changeBg();
});
bg3.addEventListener('click', ()=>{
lightlightness='0%';
darklightness='95%';
whitelightness='10%';
changeActivebg();
//add active
bg3.classList.toggle('active');
//remove active
changeBg();
});