-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
147 lines (139 loc) · 5.11 KB
/
Copy pathscript.js
File metadata and controls
147 lines (139 loc) · 5.11 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
//좋아요 기능
document.addEventListener('DOMContentLoaded', () => {
const likeButtons = document.querySelectorAll('.bubbly-button');
const initializeCounts = () => {
likeButtons.forEach(button => {
const id = button.dataset.id;
const count = localStorage.getItem(`like-count-${id}`) || 0;
document.getElementById(`like-count-${id}`).textContent = count;
});
};
likeButtons.forEach(button => {
button.addEventListener('click', () => {
const id = button.dataset.id;
let count = parseInt(localStorage.getItem(`like-count-${id}`) || 0, 10);
button.classList.add('active');
setTimeout(() => {
button.classList.remove('active');
}, 1000);
count += 1;
localStorage.setItem(`like-count-${id}`, count);
document.getElementById(`like-count-${id}`).textContent = count;
});
});
initializeCounts();
});
//스크롤 버튼
document.addEventListener('DOMContentLoaded', function() {
const scrollToTopBtn = document.getElementById('scrollToTopBtn');
window.addEventListener('scroll', function() {
if (window.scrollY > 200) {
scrollToTopBtn.style.display = 'block';
} else {
scrollToTopBtn.style.display = 'none';
}
});
scrollToTopBtn.addEventListener('click', function() {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
});
//게시판 제목 애니메이션
document.addEventListener('DOMContentLoaded', () => {
const targets = [
document.getElementById('highlight_Top'),
document.getElementById('highlight_Middle'),
document.getElementById('highlight_Bottom')
];
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate');
} else {
entry.target.classList.remove('animate');
}
});
}, {
threshold: 0.5
});
targets.forEach(target => observer.observe(target));
});
//숨겨진 카드
$(function() {
$('.btn1').click(function() {
var cardBox = $('.card_box');
var hiddenCards = cardBox.find('.card:nth-child(n+3):lt(4)');
hiddenCards.each(function(index, card) {
$(card).toggleClass('show');
});
cardBox.toggleClass('show');
var buttonText = $(this).text();
$(this).text(buttonText === "더 보 기" ? "접 기" : "더 보 기");
});
});
//숨겨진 박스
$(function() {
$('.btn2').click(function() {
var container = $('.container');
var hiddenBoxes = container.find('.box:nth-child(n+2):lt(2)');
hiddenBoxes.each(function(index, box) {
$(box).toggleClass('show');
});
container.toggleClass('show');
var buttonText = $(this).text();
$(this).text(buttonText === "더 보 기" ? "접 기" : "더 보 기");
});
});
//숨겨진 영상
$(function() {
$('.btn3').click(function() {
var video_section = $('.video_section');
var hiddenVideo = video_section.find('.video_container:nth-child(n+2):lt(3)');
hiddenVideo.each(function(index, video_container) {
$(video_container).toggleClass('show');
});
video_section.toggleClass('show');
var buttonText = $(this).text();
$(this).text(buttonText === "더 보 기" ? "접 기" : "더 보 기");
});
});
//모바일 크기일 때 로고 움직임
document.addEventListener('DOMContentLoaded', function() {
var headerLogo = document.querySelector('.header_Logo h1');
headerLogo.addEventListener('click', function() {
if (window.innerWidth <= 767) {
this.classList.add('clicked');
var element = this;
setTimeout(function() {
element.classList.remove('clicked');
}, 0);
}
});
});
//이미지 보여주고 숨기기
function showImage(imageSrc) {
var imgContainer = document.createElement("div");
imgContainer.className = "image-container";
var closeButton = document.createElement("span");
closeButton.innerHTML = "×";
closeButton.className = "close-button";
closeButton.onclick = function() {
document.body.removeChild(imgContainer);
};
var image = document.createElement("img");
image.src = imageSrc;
imgContainer.appendChild(closeButton);
imgContainer.appendChild(image);
document.body.appendChild(imgContainer);
}
document.addEventListener('DOMContentLoaded', () => {
const headings = document.querySelectorAll('#middle .container .box');
const imageSrcs = ["iimg_1.jpg", "iimg_2.jpg", "iimg_3.jpg"]; // 이미지 경로 배열
headings.forEach((heading, index) => {
heading.addEventListener('click', () => {
showImage(imageSrcs[index]);
});
});
});