-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
163 lines (119 loc) · 5.33 KB
/
Copy pathscript.js
File metadata and controls
163 lines (119 loc) · 5.33 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
// SECTION Text Inputs
const text_inputs = document.querySelectorAll('.text')
const elements = [...text_inputs]
elements.forEach((element, index) => {
element.addEventListener('input', (event) => {
const input = event.target
const label = input.nextElementSibling
if (input.value.length !== 0) {
input.classList.add('not-empty')
label.classList.add('not-empty')
} else {
input.classList.remove('not-empty')
label.classList.remove('not-empty')
}
});
});
const html_events = ['blur', 'input']
elements.slice(2, elements.length).forEach((element, index) => {
html_events.forEach((e) => {
element.addEventListener(e, (event) => {
const input = event.target
const label = input.nextElementSibling
const validation = input.validity
if (validation.valuemissing || validation.typeMismatch || validation.tooLong || validation.tooShort) {
input.classList.add('invalid')
label.classList.add('invalid')
} else {
if (element.id == 'cpwd') checkConfirmPass(e)
else {
if (element.id == 'pwd') checkConfirmPass(e)
input.classList.remove('invalid')
label.classList.remove('invalid')
}
}
});
});
});
// Compare & Report on Confirm Password
function checkConfirmPass(e) {
if (elements[4].value !== elements[5].value) {
elements[5].classList.add('invalid')
elements[5].nextElementSibling.classList.add('invalid')
elements[5].setCustomValidity('Passwords do not Match')
} else if (elements[4].value === elements[5].value) {
elements[5].classList.remove('invalid')
elements[5].nextElementSibling.classList.remove('invalid')
elements[5].setCustomValidity('')
}
if (e == 'blur') elements[5].setCustomValidity('')
elements[5].reportValidity();
}
// !SECTION
// SECTION Color Change
const toggles = Array.from(document.querySelectorAll('.tog'))
toggles.forEach((radio) => {
radio.addEventListener('click', () => {
radio.classList.add('select')
// Colors Gradient Percentage
let bg_clr = window.getComputedStyle(document.body).getPropertyValue('background-image');
const bg_regex = new RegExp(/(\b\d{1,3})(?=%)/, 'g');
// Image
let img = document.querySelector('.image')
let bg_img = window.getComputedStyle(img).getPropertyValue('background-image')
const bgimg_regex = new RegExp(/rgb[a]?\(.+?\)|(?<=assets\/)([\w\.\_\-]+)/, 'g')
// ANCHOR Function to Change Based on Radio
function radioChange(bg_percentage, clr_light_full, clr_light_transp, clr_dark, bg_image, logo) {
// Color
document.documentElement.style.setProperty('--light-full', clr_light_full)
document.documentElement.style.setProperty('--light-transp', clr_light_transp)
document.documentElement.style.setProperty('--dark', clr_dark)
// Image
const bgimg_setup = [clr_light_full, clr_light_transp, clr_dark, bg_image]
let cnt = 0
let bg_img_new = bg_img.replace(bgimg_regex, () => bgimg_setup[cnt++])
img.style.setProperty('background-image', bg_img_new)
// Background Percentage
let count = 0;
let bg_clr_new = bg_clr.replace(bg_regex, () => bg_percentage[count++]);
document.body.style.setProperty('background-image', bg_clr_new)
// Logo
document.querySelector('#logo').setAttribute('src', logo)
}
// SECTION Colors
if (radio.value == 'dc') {
// ANCHOR DC
const bg_percentage = [0, 80, 100]
const clr_light_full = 'var(--dc-light-full)'
const clr_light_transp = 'var(--dc-light-transp)'
const clr_dark = 'var(--dc-dark)'
const bg_image = 'DC_Bg.webp'
const logo = 'assets/DC_Logo.png'
radioChange(bg_percentage, clr_light_full, clr_light_transp, clr_dark, bg_image, logo)
} else if (radio.value == 'rand') {
// ANCHOR RAND
const bg_percentage = [0, 30, 100]
const clr_light_full = 'var(--rand-light-full)'
const clr_light_transp = 'var(--rand-light-transp)'
const clr_dark = 'var(--rand-dark)'
const bg_image = 'Rand_Bg.jpg'
const logo = 'assets/Rand_Logo.png'
radioChange(bg_percentage, clr_light_full, clr_light_transp, clr_dark, bg_image, logo)
} else if (radio.value == 'marvel') {
// ANCHOR MARVEL
const bg_percentage = [0, 30, 50];
const clr_light_full = 'var(--marvel-light-full)'
const clr_light_transp = 'var(--marvel-light-transp)'
const clr_dark = 'var(--marvel-dark)'
const bg_image = 'Marvel_Bg.webp'
const logo = 'assets/Marvel_Logo.png'
radioChange(bg_percentage, clr_light_full, clr_light_transp, clr_dark, bg_image, logo)
} else {
return -1
}
// !SECTION
// Remove Select Class from Other
toggles.filter((item) => { return item != radio }).forEach((item) => item.classList.remove('select'))
})
})
// !SECTION