-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparentheses.html
More file actions
71 lines (64 loc) · 2.26 KB
/
parentheses.html
File metadata and controls
71 lines (64 loc) · 2.26 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
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Проверка скобок</title>
<script src="validateParentheses.js"></script>
</head>
<body style="font-family: sans-serif, serif;" id="body">
<form style="margin: auto; width: 370px; max-height: 450px; text-align: center;
margin-top: 100px; border-radius: 10px; box-shadow: 1px 1px 1px 1px;"
id="parenthesesForm">
<input style="width: 300px; height: 30px; border-radius: 10px; padding-left: 10px;
padding-right: 10px; margin: auto; margin-bottom: 30px; margin-top: 50px;"
placeholder="скобочное выражение..." id="parenthesesInp">
<h3 style="text-align: left; padding-left: 10px;">
Примеры корректных выражений:
</h3>
<ol style="text-align: left;">
<li>
()
</li>
<li>
({[]})
</li>
<li>
(){}[]
</li>
</ol>
<h3 style="text-align: left; padding-left: 10px;">
Примеры некорректных выражений:
</h3>
<ol style="text-align: left; padding-bottom: 50px;">
<li>
)
</li>
<li>
(}[]
</li>
<li>
{{[{])((}{
</li>
</ol>
</form>
<script>
const RED_COLOR = "#EE204D";
const GREEN_COLOR = "#44944A";
let parentheses_inp = parenthesesForm.parenthesesInp;
parentheses_inp.addEventListener("input", () => {
if (parentheses_inp.value == "") {
parentheses_inp.style.background = "";
return;
}
let parentheses = parentheses_inp.value;
let parentheses_status = getParenthesesStatus(parentheses);
if (parentheses_status) {
parentheses_inp.style.background = GREEN_COLOR;
return;
}
parentheses_inp.style.background = RED_COLOR;
})
</script>
</body>
</html>