-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (38 loc) · 1.05 KB
/
app.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
const addMask = () => {
const shape = document.getElementById('shapes').value;
const mask = document.querySelector('.mask');
mask.classList.add(shape);
const shapeSelect = document.getElementById('shapes');
shapeSelect.addEventListener('click', function () {
mask.classList.remove(shape);
});
};
const onSubmit = () => {
const form = document.getElementById('form');
form.addEventListener('submit', (e) => {
e.preventDefault();
});
};
const colorPicker = () => {
onSubmit();
const num = document.getElementById('color').value;
// sanitize input for xss
const sanitizedStr = num.replace(/(<([^>]+)>)/gi, '');
document.documentElement.style.setProperty(
'--primary-color',
'#' + sanitizedStr
);
onSubmit();
};
const backgroundImagePicker = () => {
onSubmit();
const url = document.getElementById('url').value;
// sanitize input for xss
const sanitizedStr = url.replace(/(<([^>]+)>)/gi, '');
document.documentElement.style.setProperty(
'--background-image',
`url(${sanitizedStr})`
);
onSubmit();
};
addMask();