-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript2.js
More file actions
352 lines (283 loc) · 12.8 KB
/
Copy pathscript2.js
File metadata and controls
352 lines (283 loc) · 12.8 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
function updateCurrentTime() {
var currentTimeElement = document.getElementById('currentTime');
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var ampm = hours >= 12 ? '오후' : '오전';
hours = hours % 12;
hours = hours ? hours : 12;
hours = String(hours).padStart(2, '0');
minutes = String(minutes).padStart(2, '0');
var currentTimeText = hours + ':' + minutes;
currentTimeElement.textContent = currentTimeText;
}
setInterval(updateCurrentTime, 60000);
updateCurrentTime();
window.onload = function() {
// app.html 페이지에 정의된 openModal2 함수 호출
window.openModal();
};
const contentContainer = document.querySelector('.other-videos');
const toolbar = document.querySelector('.toolbar');
function handleVisibility() {
const contentRect = contentContainer.getBoundingClientRect();
const toolbarRect = toolbar.getBoundingClientRect();
// 현재 화면에 보이는지 여부를 계산
const isVisible = (
contentRect.top < window.innerHeight &&
contentRect.bottom > 0 &&
toolbarRect.top < window.innerHeight &&
toolbarRect.bottom > 0
);
// 화면에 보이면 visible, 아니면 hidden으로 설정
contentContainer.style.visibility = isVisible ? 'visible' : 'hidden';
toolbar.style.visibility = isVisible ? 'visible' : 'hidden';
}
function openModal() {
var overlay = document.getElementById('overlay');
overlay.style.display = 'flex';
overlay.style.height = '100%'; // 모달의 height를 변경하여 위로 슬라이드
document.body.style.overflowY = 'hidden'; // 열릴 때 스크롤 숨김
var newPopupBackground = document.getElementById("newPopupBackground");
newPopupBackground.style.display = "block";
}
function closeModal() {
var overlay = document.getElementById('overlay');
overlay.style.height = '0'; // 모달의 height를 변경하여 아래로 슬라이드
setTimeout(function() {
overlay.style.display = 'none';
document.body.style.overflowY = 'auto'; // 닫힐 때 스크롤 허용
}, 500); // 모달이 완전히 닫힌 후에 display를 none으로 변경
var newPopupBackground = document.getElementById("newPopupBackground");
newPopupBackground.style.display = "none";
}
function openModal3() {
var overlay3 = document.getElementById('overlay3');
overlay3.style.display = 'flex';
overlay3.style.height = '100%'; // 모달의 height를 변경하여 위로 슬라이드
document.body.style.overflowY = 'hidden'; // 열릴 때 스크롤 숨김
var newPopupBackground3 = document.getElementById("newPopupBackground3");
newPopupBackground3.style.display = "block";
}
function closeModal3() {
var overlay3 = document.getElementById('overlay3');
overlay3.style.height = '0'; // 모달의 height를 변경하여 아래로 슬라이드
setTimeout(function() {
overlay3.style.display = 'none';
document.body.style.overflowY = 'auto'; // 닫힐 때 스크롤 허용
}, 500); // 모달이 완전히 닫힌 후에 display를 none으로 변경
var newPopupBackground3 = document.getElementById("newPopupBackground3");
newPopupBackground3.style.display = "none";
}
// JavaScript 코드를 작성합니다.
let inputElement = document.getElementById('textInput');
let outputElement = document.getElementById('output');
let textArray = [];
function handleKeyPress(event) {
// 엔터 키를 눌렀을 때만 처리
if (event.key === 'Enter') {
saveText();
}
}
function saveText() {
let text = inputElement.value;
// 입력된 텍스트를 배열에 저장
textArray.push(text);
// 배열에 저장된 텍스트를 화면에 표시
displayText();
// 입력 박스 비우기
inputElement.value = '';
}
function displayText() {
// 배열에 저장된 텍스트를 화면에 표시
outputElement.innerHTML = '<h3></h3>';
outputElement.innerHTML += '<ul>';
textArray.forEach(function (text) {
outputElement.innerHTML += '<li class="list">' + text + '<img src="img/x.png" alt="x" class="list-remove"></li>';
});
outputElement.innerHTML += '</ul>';
}
function toggleKeyboard() {
var keyboardImage = document.getElementById('keyboardImage');
var modal = document.querySelector('.modal3');
var keyboardIcon = document.getElementById('modal-header3-contents-icon');
keyboardIcon.style.display = 'none';
if (keyboardImage.style.display === 'none') {
// 키보드 이미지가 숨겨져 있다면 보이도록 설정하고, 모달 높이를 조절합니다.
keyboardImage.style.display = 'block';
modal.style.height = (modal.offsetHeight + 300) + 'px';
} else {
// 키보드 이미지가 보이고 있다면 숨기도록 설정하고, 모달 높이를 조절합니다.
keyboardImage.style.display = 'none';
modal.style.height = (modal.offsetHeight - 300) + 'px';
}
}
// JavaScript 코드를 작성합니다.
function openModal5() {
var overlay5 = document.getElementById('overlay5');
overlay5.style.display = 'flex';
overlay5.style.height = '100%'; // 모달의 height를 변경하여 위로 슬라이드
document.body.style.overflowY = 'hidden'; // 열릴 때 스크롤 숨김
var newPopupBackground5 = document.getElementById("newPopupBackground5");
newPopupBackground5.style.display = "block";
}
function closeModal5() {
var overlay5 = document.getElementById('overlay5');
overlay5.style.height = '0'; // 모달의 height를 변경하여 아래로 슬라이드
setTimeout(function() {
overlay5.style.display = 'none';
document.body.style.overflowY = 'auto'; // 닫힐 때 스크롤 허용
}, 500); // 모달이 완전히 닫힌 후에 display를 none으로 변경
var newPopupBackground5 = document.getElementById("newPopupBackground5");
newPopupBackground5.style.display = "none";
}
let inputElement5 = document.getElementById('textInput5');
let outputElement5 = document.getElementById('output5');
let textArray5 = [];
function handleKeyPress(event) {
// 엔터 키를 눌렀을 때만 처리
if (event.key === 'Enter') {
saveText();
}
}
function saveText5() {
let text5 = inputElement5.value;
// 입력된 텍스트를 배열에 저장
textArray5.push(text);
// 배열에 저장된 텍스트를 화면에 표시
displayText5();
// 입력 박스 비우기
inputElement5.value = '';
}
function displayText5() {
// 배열에 저장된 텍스트를 화면에 표시
outputElement5.innerHTML = '<h3></h3>';
outputElement5.innerHTML += '<ul>';
textArray5.forEach(function (text) {
outputElement5.innerHTML += '<li class="list">' + text + '<img src="img/x.png" alt="x" class="list-remove"></li>';
});
outputElement5.innerHTML += '</ul>';
}
function toggleKeyboard5() {
var keyboardImage5 = document.getElementById('keyboardImage5');
var modal5 = document.querySelector('.modal5');
var keyboardIcon5 = document.getElementById('modal-header5-contents-icon');
keyboardIcon5.style.display = 'none';
// 키보드 이미지가 현재 보이는지 여부에 따라 작업을 수행합니다.
if (keyboardImage5.style.display === 'none') {
// 키보드 이미지가 숨겨져 있다면 보이도록 설정하고, 모달 높이를 조절합니다.
keyboardImage5.style.display = 'block';
modal5.style.height = (modal5.offsetHeight + 288) + 'px';
} else {
// 키보드 이미지가 보이고 있다면 숨기도록 설정하고, 모달 높이를 조절합니다.
keyboardImage5.style.display = 'none';
modal5.style.height = (modal5.offsetHeight - 288) + 'px';
}
}
function openModal4() {
var overlay4 = document.getElementById('overlay4');
overlay4.style.display = 'flex';
overlay4.style.height = '100%'; // 모달의 height를 변경하여 위로 슬라이드
document.body.style.overflowY = 'hidden'; // 열릴 때 스크롤 숨김
var newPopupBackground4 = document.getElementById("newPopupBackground4");
newPopupBackground4.style.display = "block";
}
function closeModal4() {
var overlay4 = document.getElementById('overlay4');
overlay4.style.height = '0'; // 모달의 height를 변경하여 아래로 슬라이드
setTimeout(function() {
overlay4.style.display = 'none';
document.body.style.overflowY = 'auto'; // 닫힐 때 스크롤 허용
}, 500); // 모달이 완전히 닫힌 후에 display를 none으로 변경
var newPopupBackground4 = document.getElementById("newPopupBackground4");
newPopupBackground4.style.display = "none";
}
let inputElementH = document.getElementById('textInput-h');
let outputElementH = document.getElementById('output-h');
let textArrayH = [];
function handleKeyPressH(eventH) {
// 엔터 키를 눌렀을 때만 처리
if (eventH.key === 'Enter') {
saveTextH();
}
}
// 저장 함수
function saveTextH() {
let text = inputElementH.value;
// 입력된 텍스트를 배열에 저장
textArrayH.push(text);
// 배열에 저장된 텍스트를 화면에 표시
displayTextH();
// 입력 박스 비우기
inputElementH.value = '';
}
// 텍스트 표시 함수
function displayTextH() {
// 출력 엘리먼트를 초기화합니다.
outputElementH.innerHTML = '';
// 헤딩 엘리먼트를 생성합니다.
let headingElement = document.createElement('h3');
outputElementH.appendChild(headingElement);
// 리스트 엘리먼트를 생성합니다.
let listElement = document.createElement('ul');
listElement.classList.add('ul2');
outputElementH.appendChild(listElement);
// 각 텍스트를 리스트 아이템으로 표시합니다.
textArrayH.forEach(function (text) {
// 메인 리스트 아이템 컨테이너를 생성합니다.
let listItem = document.createElement('li');
listItem.classList.add('li2');
// span, text, 그리고 img를 포함할 컨테이너를 생성합니다.
let containerElement = document.createElement('div');
containerElement.classList.add('li2-container');
// span 엘리먼트를 생성합니다.
let spanElement = document.createElement('span');
spanElement.innerText = '#';
// text 노드를 생성합니다.
let textNode = document.createTextNode(text);
// img 엘리먼트를 생성합니다.
let imgElement = document.createElement('img');
imgElement.src = 'img/remove-hashtag.png';
imgElement.alt = '';
imgElement.classList.add('remove-hashtag');
// 각 엘리먼트를 부모에 추가합니다.
containerElement.appendChild(spanElement);
containerElement.appendChild(textNode);
containerElement.appendChild(imgElement);
listItem.appendChild(containerElement);
// 텍스트 길이를 기반으로 동적으로 너비를 계산하고 설정합니다.
let calculatedWidth = 53 + getTextWidth(text) + 'px';
listItem.style.minWidth = calculatedWidth;
listElement.appendChild(listItem);
});
}
// Function to calculate the text width using canvas
function getTextWidth(text) {
let canvas = document.createElement('canvas');
let context = canvas.getContext('2d');
context.font = window.getComputedStyle(outputElementH).font; // Use the computed font style
let textMetrics = context.measureText(text);
return textMetrics.width;
}
inputElementH.addEventListener('keydown', handleKeyPressH);
function openSecondPopup() {
var popupBackground = document.getElementById("popupBackground");
var secondPopup = document.getElementById("secondPopup");
var newPopupBackground = document.getElementById("newPopupBackground");
var newSecondPopup = document.getElementById("newSecondPopup");
popupBackground.style.display = "block";
secondPopup.style.display = "block";
// 5초 후에 첫 번째 팝업을 자동으로 닫고 두 번째 팝업을 열기
setTimeout(function () {
closeSecondPopup(); // 첫 번째 팝업을 닫음
newSecondPopup.style.display = "block";
}, 1500);
}
function closeSecondPopup() {
var popupBackground = document.getElementById("popupBackground");
var secondPopup = document.getElementById("secondPopup");
var newPopupBackground = document.getElementById("newPopupBackground");
popupBackground.style.display = "none";
secondPopup.style.display = "none";
newPopupBackground.style.display="none";
}