-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
213 lines (189 loc) · 7.03 KB
/
script.js
File metadata and controls
213 lines (189 loc) · 7.03 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
const newsData = [
{
date: "Jan 2026",
content: "Our work <em>Analyzing and Optimizing NoSQL Workloads for Cosmos DB using Distressed Resource Volume Metric</em> is accepted at <em>VLDB 2026</em>"
},
{
date: "Dec 2025",
content: "I have joined <em>Dr. James Hays' Lab</em> as a Graduate Student Researcher, working on Diffusion Models for 3D Scene Reconstruction."
},
{
date: "Dec 2025",
content: "I have joined the C21U Lab at Georgia Tech as a Graduate Research Assistant under Dr. <em>Jeonghyun (Jonna) Lee</em>"
},
{
date: "Sep 2025",
content: "Our work <em>Narrating For You</em> is accepted at <em>WACV 2026</em>"
},
{
date: "Aug 2025",
content: "Started my MS in Computer Science at Georgia Tech"
},
{
date: "Jun 2025",
content: "Graduated from BITS Pilani with Distinction"
},
{
date: "Jul 2025",
content: "Concluded my research internship at Microsoft Research"
},
{
date: "Dec 2024",
content: "Concluded my work for my Undergraduate Thesis on learning representations for Vision-Language Models"
},
{
date: "May 2024",
content: "Our work <em>Latent Flow Diffusion for Deepfake Video Generation</em> was accepted at <em>CVPRW 2024</em>."
},
{
date: "Jun 2023",
content: "Started my Undergraduate Research Assistantship at the Machine Intelligence Group"
},
{
date: "Aug 2021",
content: "Started my Bachelors in Computer Science at BITS Pilani"
},
];
// Pagination settings
const ITEMS_PER_PAGE = 3;
let currentPage = 1;
// Function to parse date string and return a sortable date
function parseDate(dateString) {
const [month, year] = dateString.split(' ');
const monthMap = {
'Jan': 0, 'Feb': 1, 'Mar': 2, 'Apr': 3, 'May': 4, 'Jun': 5,
'Jul': 6, 'Aug': 7, 'Sep': 8, 'Oct': 9, 'Nov': 10, 'Dec': 11
};
return new Date(parseInt(year), monthMap[month]);
}
// Sort news data by date (latest first)
const sortedNewsData = [...newsData].sort((a, b) => {
return parseDate(b.date) - parseDate(a.date);
});
// Theme toggle functionality
// Theme toggle functionality
document.addEventListener('DOMContentLoaded', function () {
const themeToggle = document.getElementById('theme-toggle');
const themeIcon = document.getElementById('theme-icon');
// We target the <html> tag now
const htmlElement = document.documentElement;
const currentTheme = localStorage.getItem('theme') || 'dark';
// Apply the saved theme on load
if (currentTheme === 'dark') {
htmlElement.setAttribute('data-theme', 'dark');
themeIcon.className = 'fas fa-sun';
} else {
htmlElement.setAttribute('data-theme', 'light');
themeIcon.className = 'fas fa-moon';
}
// Theme toggle event listener
themeToggle.addEventListener('click', function () {
const currentTheme = htmlElement.getAttribute('data-theme');
if (currentTheme === 'dark') {
// Switch to light mode
htmlElement.setAttribute('data-theme', 'light'); // FIXED: Changed body -> htmlElement
themeIcon.className = 'fas fa-moon';
localStorage.setItem('theme', 'light');
} else {
// Switch to dark mode
htmlElement.setAttribute('data-theme', 'dark'); // FIXED: Changed body -> htmlElement
themeIcon.className = 'fas fa-sun';
localStorage.setItem('theme', 'dark');
}
});
// Initialize news section
initializeNews();
// Smooth scrolling for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
});
// News functionality
function initializeNews() {
renderNews();
renderPagination();
}
function renderNews() {
const newsContainer = document.getElementById('news-container');
const startIndex = (currentPage - 1) * ITEMS_PER_PAGE;
const endIndex = startIndex + ITEMS_PER_PAGE;
const currentNews = sortedNewsData.slice(startIndex, endIndex);
newsContainer.innerHTML = '';
currentNews.forEach(item => {
const newsItem = document.createElement('div');
newsItem.className = 'news-item';
// Convert <italic> tags to proper HTML <em> tags
const processedContent = item.content.replace(/<italic>/g, '<em>').replace(/<\/italic>/g, '</em>');
newsItem.innerHTML = `
<div class="news-date">${item.date}</div>
<div class="news-content">${processedContent}</div>
`;
newsContainer.appendChild(newsItem);
});
}
function renderPagination() {
const paginationContainer = document.getElementById('news-pagination');
const totalPages = Math.ceil(sortedNewsData.length / ITEMS_PER_PAGE);
if (totalPages <= 1) {
paginationContainer.innerHTML = '';
return;
}
paginationContainer.innerHTML = '';
// Previous button
const prevBtn = document.createElement('button');
prevBtn.className = 'pagination-btn';
prevBtn.innerHTML = '<i class="fas fa-chevron-left"></i>';
prevBtn.disabled = currentPage === 1;
prevBtn.addEventListener('click', () => {
if (currentPage > 1) {
currentPage--;
renderNews();
renderPagination();
}
});
paginationContainer.appendChild(prevBtn);
// Page numbers
for (let i = 1; i <= totalPages; i++) {
const pageBtn = document.createElement('button');
pageBtn.className = `pagination-btn ${i === currentPage ? 'active' : ''}`;
pageBtn.textContent = i;
pageBtn.addEventListener('click', () => {
currentPage = i;
renderNews();
renderPagination();
});
paginationContainer.appendChild(pageBtn);
}
// Next button
const nextBtn = document.createElement('button');
nextBtn.className = 'pagination-btn';
nextBtn.innerHTML = '<i class="fas fa-chevron-right"></i>';
nextBtn.disabled = currentPage === totalPages;
nextBtn.addEventListener('click', () => {
if (currentPage < totalPages) {
currentPage++;
renderNews();
renderPagination();
}
});
paginationContainer.appendChild(nextBtn);
}
// Function to add new news items (you can call this to add news dynamically)
function addNewsItem(date, content) {
newsData.unshift({ date, content }); // Add to beginning of array
// Re-sort the data after adding new item
sortedNewsData.length = 0; // Clear the array
sortedNewsData.push(...newsData.sort((a, b) => parseDate(b.date) - parseDate(a.date)));
currentPage = 1; // Reset to first page
renderNews();
renderPagination();
}