-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
304 lines (270 loc) · 10.5 KB
/
script.js
File metadata and controls
304 lines (270 loc) · 10.5 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
// Academic Project Page JavaScript
document.addEventListener('DOMContentLoaded', function() {
// Smooth scrolling for anchor links
const links = document.querySelectorAll('a[href^="#"]');
links.forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Add scroll-based animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Observe sections for animation
const sections = document.querySelectorAll('section');
sections.forEach(section => {
section.style.opacity = '0';
section.style.transform = 'translateY(30px)';
section.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(section);
});
// Copy citation to clipboard
const citationBox = document.querySelector('.citation-box');
if (citationBox) {
citationBox.addEventListener('click', function() {
const text = this.textContent;
navigator.clipboard.writeText(text).then(function() {
// Show feedback
const originalBg = citationBox.style.backgroundColor;
citationBox.style.backgroundColor = '#d4edda';
citationBox.style.transition = 'background-color 0.3s ease';
setTimeout(() => {
citationBox.style.backgroundColor = originalBg;
}, 1000);
// Optional: Show tooltip or notification
showNotification('Citation copied to clipboard!');
});
});
// Add cursor pointer style
citationBox.style.cursor = 'pointer';
citationBox.title = 'Click to copy citation';
}
// Show notification function
function showNotification(message) {
const notification = document.createElement('div');
notification.textContent = message;
notification.style.cssText = `
position: fixed;
top: 20px;
right: 20px;
background: #667eea;
color: white;
padding: 12px 20px;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
z-index: 1000;
font-weight: 500;
opacity: 0;
transform: translateY(-20px);
transition: all 0.3s ease;
`;
document.body.appendChild(notification);
// Animate in
setTimeout(() => {
notification.style.opacity = '1';
notification.style.transform = 'translateY(0)';
}, 100);
// Remove after 3 seconds
setTimeout(() => {
notification.style.opacity = '0';
notification.style.transform = 'translateY(-20px)';
setTimeout(() => {
document.body.removeChild(notification);
}, 300);
}, 3000);
}
// Add hover effects to result cards
const resultCards = document.querySelectorAll('.result-card');
resultCards.forEach(card => {
card.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-5px)';
this.style.boxShadow = '0 15px 35px rgba(0, 0, 0, 0.15)';
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0)';
this.style.boxShadow = '0 5px 20px rgba(0, 0, 0, 0.08)';
});
});
// Parallax effect for header
window.addEventListener('scroll', function() {
const scrolled = window.pageYOffset;
const header = document.querySelector('header');
if (header) {
const rate = scrolled * -0.5;
header.style.transform = `translateY(${rate}px)`;
}
});
// Add loading animation for method diagram
const methodDiagram = document.querySelector('.method-diagram');
if (methodDiagram) {
methodDiagram.addEventListener('click', function() {
this.innerHTML = `
<div style="display: flex; flex-direction: column; align-items: center;">
<div style="width: 40px; height: 40px; border: 4px solid #f3f3f3; border-top: 4px solid #667eea; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 20px;"></div>
<div>Loading method diagram...</div>
</div>
`;
// Add CSS for spin animation
const style = document.createElement('style');
style.textContent = `
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
`;
document.head.appendChild(style);
// Simulate loading
setTimeout(() => {
this.innerHTML = 'Method Architecture Diagram<br>(Replace with actual diagram)';
}, 2000);
});
}
// Enhanced button hover effects
const buttons = document.querySelectorAll('.btn');
buttons.forEach(button => {
button.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-3px) scale(1.05)';
this.style.boxShadow = '0 8px 25px rgba(102, 126, 234, 0.3)';
});
button.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(-2px) scale(1)';
this.style.boxShadow = 'none';
});
});
// Special animation for motivation and method images
const motivationImg = document.querySelector('#motivation img');
const methodImg = document.querySelector('#method .method-figure img');
// Reusable function for creating image modal
function createImageModal(event) {
const sourceImg = event.target;
// Create modal for better image viewing
const modal = document.createElement('div');
modal.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.95);
z-index: 1000;
display: flex;
align-items: center;
justify-content: center;
cursor: zoom-out;
padding: 20px;
box-sizing: border-box;
backdrop-filter: blur(5px);
`;
const modalImg = document.createElement('img');
modalImg.src = sourceImg.src;
modalImg.style.cssText = `
max-width: 95%;
max-height: 95%;
object-fit: contain;
border-radius: 10px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
background: white;
border: 1px solid #e1e8ed;
`;
const closeBtn = document.createElement('div');
closeBtn.innerHTML = '×';
closeBtn.style.cssText = `
position: absolute;
top: 20px;
right: 30px;
color: #333;
font-size: 40px;
font-weight: bold;
cursor: pointer;
z-index: 1001;
background: rgba(255, 255, 255, 0.9);
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
transition: all 0.3s ease;
`;
// Add hover effect for close button
closeBtn.addEventListener('mouseenter', () => {
closeBtn.style.background = 'rgba(255, 255, 255, 1)';
closeBtn.style.transform = 'scale(1.1)';
});
closeBtn.addEventListener('mouseleave', () => {
closeBtn.style.background = 'rgba(255, 255, 255, 0.9)';
closeBtn.style.transform = 'scale(1)';
});
modal.appendChild(modalImg);
modal.appendChild(closeBtn);
document.body.appendChild(modal);
// Add fade-in animation
modal.style.opacity = '0';
setTimeout(() => {
modal.style.transition = 'opacity 0.3s ease';
modal.style.opacity = '1';
}, 10);
// Close on click
[modal, closeBtn].forEach(element => {
element.addEventListener('click', (e) => {
if (e.target === modal || e.target === closeBtn) {
modal.style.opacity = '0';
setTimeout(() => {
if (document.body.contains(modal)) {
document.body.removeChild(modal);
}
}, 300);
}
});
});
// Close on escape key
const escapeHandler = (e) => {
if (e.key === 'Escape') {
modal.style.opacity = '0';
setTimeout(() => {
if (document.body.contains(modal)) {
document.body.removeChild(modal);
}
}, 300);
document.removeEventListener('keydown', escapeHandler);
}
};
document.addEventListener('keydown', escapeHandler);
}
// Apply modal functionality to images
if (motivationImg) {
motivationImg.style.cursor = 'zoom-in';
motivationImg.title = 'Click to enlarge';
motivationImg.addEventListener('click', createImageModal);
}
if (methodImg) {
methodImg.style.cursor = 'zoom-in';
methodImg.title = 'Click to enlarge';
methodImg.addEventListener('click', createImageModal);
}
// Add click-to-enlarge for result GIFs
const resultGifs = document.querySelectorAll('.result-gif');
resultGifs.forEach(gif => {
gif.style.cursor = 'zoom-in';
gif.title = 'Click to enlarge';
gif.addEventListener('click', createImageModal);
});
});