-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskrypt.js
41 lines (37 loc) · 1.25 KB
/
skrypt.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
const getInputValues = () => {
const shapeType = document.querySelector("#ksztalt").value;
const r = parseInt(document.querySelector("#R").value, 10);
const g = parseInt(document.querySelector("#G").value, 10);
const b = parseInt(document.querySelector("#B").value, 10);
return { shapeType, r, g, b };
};
const getShape = ({ shapeType }) => {
if ((shapeType == 1)) {
let shape = "miś";
return shape;
} else if ((shapeType == 2)) {
let shape = "żabka";
return shape;
} else if ((shapeType == 3)) {
let shape = "serce";
return shape;
}
};
const assingShape = (shape) => {
document.querySelector(".form").innerHTML +=
"<p>Zamówiłeś żelka: " + shape + "</p>";
};
const getRGB = ({ r, g, b }) => {
if ((r, g, b > 255 || r, g, b < 0)) {
document.querySelector(".colorPicker").innerHTML = "Podaj poprawną wartość";
} else {
document.querySelector(".colorPicker").style.backgroundColor =
"rgb(" + r + ", " + g + ", " + b + ")";
}
};
const calculate = () => {
const getValues = getInputValues();
const shapeValue = getShape(getValues);
assingShape(shapeValue);
getRGB(getValues);
};