-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
92 lines (92 loc) · 3.04 KB
/
Copy pathindex.html
File metadata and controls
92 lines (92 loc) · 3.04 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
<!DOCTYPE html>
<html>
<head>
<title>아잉</title>
<style>
.hf29 {
resize: none;
}
</style>
</head>
<body>
<script>
function e() {
if (document.querySelector(".g9cy").querySelector("#h") != null) {
document.querySelector(".g9cy").querySelector("#h").remove();
}
var p = document.body.querySelector('.hf29').value.trim().replace(/ /g, '').replace(/\n/g, '');
const c = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-", "/", "*", ".", "(", ")"];
const q = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
const x = ["+", "-", "/", "*", "."];
var e = false;
if ((p.split('=').length - 1) == 1) {
if (p[p.length - 1] != '=') {
e = true;
}
} else if((p.split('=').length - 1) != 0) {
e = true;
}
const t = p.replace("=", '');
var g = 0;
for (let i = 0; i < t.length; i++) {
if (c.includes(t[i]) == false) {
e = true;
break;
}
if (i != 0) {
if ((x.includes(t[i - 1]) == true) && (x.includes(t[i]) == true)) {
e = true;
break;
}
if ((t[i] == ")") && (x.includes(t[i - 1]) == true)) {
e = true;
break;
}
if ((t[i] == "(") && (q.includes(t[i - 1]) == true)) {
e = true;
break;
}
}
if (i != t.length-1) {
if ((t[i] == "(") && (x.includes(t[i + 1]) == true)) {
e = true;
break;
}
if ((t[i] == ")") && (q.includes(t[i + 1]) == true)) {
e = true;
break;
}
}
if (t[i] == "(") {
g++;
}
if (t[i] == ")") {
if (g == 0) {
e = true;
break;
}
g--;
}
}
if (g != 0) {
e = true;
}
if (x.includes(t[0]) == true) {
e = true;
}
if (e == true) {
r();
}
}
function r() {
const d = document.createElement("div");
d.id = "h";
d.innerText = "r";
document.querySelector(".g9cy").appendChild(d);
}
</script>
<textarea cols="30" rows="10" class="hf29">1+1=</textarea><br>
<div class="g9cy"></div>
<button onclick="e()">확인</button><br>
</body>
</html>