-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
140 lines (123 loc) · 4.99 KB
/
script.js
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
// Countdown Timer
function updateCountdown() {
const eventDate = new Date('June 7, 2025 09:00:00').getTime();
const now = new Date().getTime();
const distance = eventDate - now;
const days = Math.floor(distance / (1000 * 60 * 60 * 24));
const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById('days').innerText = String(days).padStart(2, '0');
document.getElementById('hours').innerText = String(hours).padStart(2, '0');
document.getElementById('minutes').innerText = String(minutes).padStart(2, '0');
document.getElementById('seconds').innerText = String(seconds).padStart(2, '0');
}
setInterval(updateCountdown, 1000);
// Slideshow functionality
let currentSlide = 0;
const slides = document.querySelectorAll('.slide');
function showSlide(n) {
slides[currentSlide].classList.remove('active');
currentSlide = (n + slides.length) % slides.length;
slides[currentSlide].classList.add('active');
}
setInterval(() => {
showSlide(currentSlide + 1);
}, 5000);
// FAQ Accordion
const faqs = [
{
question: "What is HackPrix?",
answer: "HackPrix is a 36-hour hackathon where students can collaborate, innovate, and build amazing projects."
},
{
question: "Who can participate?",
answer: "Any college student with a valid ID card can participate in HackPrix 2025."
},
{
question: "What's the team size?",
answer: "Teams can have 2-4 members. Solo participation is also allowed."
},
{
question:"If your question isn't listed, what's your move?",
answer:"For assistance, reach out to us at Discord or email us at."
},
{
question:"Will food & stay be provided?",
answer:"We've got lots of food and snacks for everyone, stay hacky and hydrated.Rooms for resting/sleeping will be arranged at the Campus (separately for opposite genders)."
}
];
const faqContainer = document.getElementById('faqContainer');
faqs.forEach((faq, index) => {
const div = document.createElement('div');
div.className = 'bg-red rounded-lg shadow-sm';
div.innerHTML = `
<button class="w-full px-6 py-4 text-left focus:outline-none" onclick="toggleFaq(${index})">
<div class="flex justify-between items-center">
<span class="font-semibold">${faq.question}</span>
<i class="bi bi-chevron-down transition-transform duration-300" id="faqIcon${index}"></i>
</div>
</button>
<div class="px-6 py-4 border-t hidden" id="faqAnswer${index}">
${faq.answer}
</div>
`;
faqContainer.appendChild(div);
});
function toggleFaq(index) {
const answer = document.getElementById(`faqAnswer${index}`);
const icon = document.getElementById(`faqIcon${index}`);
answer.classList.toggle('hidden');
icon.style.transform = answer.classList.contains('hidden') ? 'rotate(0deg)' : 'rotate(180deg)';
}
// Chat Bot
let chatOpen = false;
function toggleChat() {
const chatBot = document.getElementById('chatBot');
chatOpen = !chatOpen;
chatBot.style.display = chatOpen ? 'block' : 'none';
}
async function sendMessage() {
const userInput = document.getElementById('userInput');
const message = userInput.value.trim();
if (!message) return;
appendMessage('user', message);
userInput.value = '';
// Call the AI endpoint
try {
const response = await fetch('https://r0c8kgwocscg8gsokogwwsw4.zetaverse.one/ai', {
method: 'POST',
headers: {
'Authorization': 'Bearer wDSwxwAAKeTUswqV9QgLFjONQ6f1',
'Content-Type': 'application/json'
},
body: JSON.stringify({
messages: [{
role: 'user',
content: [{
type: 'text',
text: message
}]
}]
})
});
const data = await response.json();
appendMessage('bot', data.message);
} catch (error) {
appendMessage('bot', 'Sorry, I encountered an error. Please try again later.');
}
}
function appendMessage(sender, message) {
const chatMessages = document.getElementById('chatMessages');
const messageDiv = document.createElement('div');
messageDiv.className = `mb-4 ${sender === 'user' ? 'text-right' : 'text-left'}`;
messageDiv.innerHTML = `
<div class="${sender === 'user' ? 'bg-indigo-600 text-white' : 'bg-gray-100'} inline-block px-4 py-2 rounded-lg max-w-[80%]">
${message}
</div>
`;
chatMessages.appendChild(messageDiv);
chatMessages.scrollTop = chatMessages.scrollHeight;
}
// Initialize the page
updateCountdown();