Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
275 lines (228 loc) · 9.11 KB
/
Copy pathscript.js
File metadata and controls
275 lines (228 loc) · 9.11 KB
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
// Search Variable
let searchPosts = document.querySelector("nav .search-input")
let creatorsName = document.querySelectorAll(".post .info h4")
let Posts = document.querySelectorAll(".post")
// Create Posts
let createHead = document.querySelector("nav .create button")
let createSide = document.querySelector(".left > button")
let createPost = document.querySelector(".middle .create-post input")
let createPostParent = document.querySelector(".middle .create-post")
// ======= Search Creators =========
searchPosts.oninput = function searchOfPost () {
Posts.forEach((ele)=> {
ele.style.display = "none"
if(ele.children[0].children[0].children[1].children[0].innerHTML.toLowerCase().startsWith(searchPosts.value.toLowerCase())){
ele.style.display = "block"
}
})
}
console.log()
searchPosts.onblur = () => Posts.forEach( (e) => e.style.display = "block")
// ========= Create Post From Header =========
createHead.addEventListener('click' , focusPost)
createSide.addEventListener('click' , focusPost)
function focusPost () {
createPost.focus()
createPostParent.classList.add('active')
}
createPost.onclick = () => createPostParent.classList.add('active')
function removeClass(){
createPostParent.classList.remove('active')
}
// ============== Menu Item =============
let menuItem = document.querySelectorAll('.menu-item')
menuItem.forEach( (e) => {
e.addEventListener("click",() => {
menuItem.forEach( (ele) => ele.classList.remove("active"))
e.classList.add('active')
})
})
// ============= Notification Btn ================
let NotificationSec =document.querySelector('.notification-list')
let notificationCount = document.querySelector('.menu-item span')
function openNotification() {
NotificationSec.classList.toggle('active')
notificationCount.style.display = "none"
}
// =========== Messages Btn ============
let messagesSection = document.querySelector('.right .messages-section')
let messagesCount = document.querySelector('.left .fa-solid.fa-message span')
let right = document.querySelector('.right')
function closeMessages() {
messagesSection.classList.remove('active')
right.style.display = "none"
}
window.onresize = () => {
if(window.matchMedia('(min-width:992px)').matches){
right.style.display = "block"
}else {
right.style.display = "none"
}
}
function messagesFocus () {
messagesCount.style.display = "none"
right.style.display = "block"
messagesSection.classList.add('active')
if(window.matchMedia('(min-width:992px)').matches){
setTimeout(() => messagesSection.classList.remove('active'),3000)
}
}
// ====== search Messages =======
let searchMessages = document.querySelector('.messages-section .search input')
let allMessages = document.querySelectorAll('.messages .message')
searchMessages.oninput = function searchOfPost () {
allMessages.forEach((ele)=> {
ele.style.display = "none"
if(ele.children[1].children[0].innerHTML.toLowerCase().startsWith(searchMessages.value.toLowerCase())){
ele.style.display = "flex"
}
})
}
// ============ Theme Sitting ================
let themePrompt = document.querySelector('.theme-customize')
let fontSizeProgress = document.querySelectorAll('.theme .font-size .progres span')
function openTheme() {
themePrompt.style.display = "block"
}
// -------- Close Theme Section --------
function closeTheme() {
themePrompt.style.display = "none"
}
// ----------- Font Size ------------
fontSizeProgress.forEach((e) => {
e.addEventListener('click', () => {
fontSizeProgress.forEach((ele) => ele.classList.remove('active'))
e.classList.add('active')
setFontsize(e)
})
})
let root = document.querySelector(':root')
function setFontsize (e) {
if(e == document.querySelector(".progres :nth-child(1)")){
if(window.matchMedia('(min-width:580px)').matches){
root.style.fontSize = "12px"
}else {
root.style.fontSize = "6px"
}
}
if(e == document.querySelector(".progres :nth-child(2)")){
if(window.matchMedia('(min-width:580px)').matches){
root.style.fontSize = "14px"
}else {
root.style.fontSize = "8px"
}
}
if(e == document.querySelector(".progres :nth-child(3)")){
if(window.matchMedia('(min-width:580px)').matches){
root.style.fontSize = "16px"
}else {
root.style.fontSize = "10px"
}
}
if(e == document.querySelector(".progres :nth-child(4)")){
if(window.matchMedia('(min-width:580px)').matches){
root.style.fontSize = "18px"
}else {
root.style.fontSize = "12px"
}
}
if(e == document.querySelector(".progres :nth-child(5)")){
if(window.matchMedia('(min-width:580px)').matches){
root.style.fontSize = "20px"
}else {
root.style.fontSize = "14px"
}
}
}
window.onresize = () => {
let fontSizeData = document.querySelector(".theme .font-size .progres span.active")
setFontsize(fontSizeData)
}
// ---------- Color -----------
let colorOption = document.querySelectorAll('.color .color-options span')
// ----------- Color In LocalStorage----------
if(window.localStorage.getItem('color') == undefined){
window.localStorage.setItem('color' , 252)
}
root.style.setProperty('--primary-color-hue',window.localStorage.getItem('color'))
function colorStorage(color) {
window.localStorage.setItem('color',color)
}
colorOption.forEach((e) => {
e.addEventListener('click' , () => {
colorOption.forEach((e)=> e.classList.remove("active"))
e.classList.add('active')
changeColor()
})
})
function changeColor () {
let primary;
let colorOptionDone = document.querySelectorAll('.color .color-options span.active')[0]
if(colorOptionDone == document.querySelector(".color .color-options span:nth-child(1)")){
primary = 252
}
if(colorOptionDone == document.querySelector(".color .color-options span:nth-child(2)")){
primary = 52
}
if(colorOptionDone == document.querySelector(".color .color-options span:nth-child(3)")){
primary = 352
}
if(colorOptionDone == document.querySelector(".color .color-options span:nth-child(4)")){
primary = 152
}
if(colorOptionDone == document.querySelector(".color .color-options span:nth-child(5)")){
primary = 202
}
colorStorage(primary)
root.style.setProperty('--primary-color-hue',window.localStorage.getItem('color'))
}
// -------- Background ---------
let backgroundLight = document.querySelector(".background .light")
let backgroundDark = document.querySelector(".background .Dark")
let backgroundLightOut = document.querySelector(".background .Lights-out")
let darkColorLightness;
let lightColorLightness;
let whiteColorLightness;
// --------- background in localStorage ---------
if(window.localStorage.getItem('background') == undefined){
window.localStorage.setItem('background',JSON.stringify(["17%","95%","100%"]))
}
darkColorLightness = JSON.parse(window.localStorage.getItem('background'))[0]
lightColorLightness = JSON.parse(window.localStorage.getItem('background'))[1]
whiteColorLightness = JSON.parse(window.localStorage.getItem('background'))[2]
let changBackground = () => {
root.style.setProperty('--dark-color-lightness',darkColorLightness)
root.style.setProperty('--light-color-lightness',lightColorLightness)
root.style.setProperty('--white-color-lightness',whiteColorLightness)
}
changBackground()
backgroundLight.addEventListener('click', () => {
darkColorLightness = `17%`;
lightColorLightness = `95%`;
whiteColorLightness = `100%`;
window.localStorage.setItem('background',JSON.stringify([darkColorLightness,lightColorLightness,whiteColorLightness]))
backgroundLight.classList.add('active')
backgroundDark.classList.remove('active')
backgroundLightOut.classList.remove('active')
changBackground()
})
backgroundDark.addEventListener('click', () => {
darkColorLightness = `95%`;
lightColorLightness = `20%`;
whiteColorLightness = `15%`;
window.localStorage.setItem('background',JSON.stringify([darkColorLightness,lightColorLightness,whiteColorLightness]))
backgroundDark.classList.add('active')
backgroundLight.classList.remove('active')
backgroundLightOut.classList.remove('active')
changBackground()
})
backgroundLightOut.addEventListener('click', () => {
darkColorLightness = `95%`;
lightColorLightness = `10%`;
whiteColorLightness = `0%`;
window.localStorage.setItem('background',JSON.stringify([darkColorLightness,lightColorLightness,whiteColorLightness]))
backgroundLightOut.classList.add('active')
backgroundDark.classList.remove('active')
backgroundLight.classList.remove('active')
changBackground()
})