575 lines
18 KiB
JavaScript
575 lines
18 KiB
JavaScript
function goToLogin() {
|
|
window.location.href = "/login";
|
|
}
|
|
|
|
function goToApplay() {
|
|
window.location.href = "/apply/";
|
|
}
|
|
|
|
|
|
function getInTouch(vall) {
|
|
window.open(vall, "_blank");
|
|
}
|
|
|
|
|
|
|
|
function getInZoho() {
|
|
window.open("https://forms.zohopublic.in/krishnakode1/form/KodePilotRegistrationForm/formperma/A2L8xK6T13A9-s5Kxj8BqRTGsgmpKDHM0DDcZQWye5E");
|
|
}
|
|
|
|
|
|
class Slide1rSlider {
|
|
constructor({ trackId = 'slide1rTrack', prevId = 'prevBtn', nextId = 'nextBtn', autoPlayDuration = 5000, invert = true } = {}) {
|
|
this.trackId = trackId;
|
|
this.prevId = prevId;
|
|
this.nextId = nextId;
|
|
this.autoPlayDuration = autoPlayDuration;
|
|
this.invert = invert;
|
|
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => this.initSlider());
|
|
else this.initSlider();
|
|
}
|
|
|
|
initSlider() {
|
|
this.track = document.getElementById(this.trackId);
|
|
if (!this.track) return console.warn('slide track not found:', this.trackId);
|
|
|
|
this.originalSlides = Array.from(this.track.querySelectorAll('.slide1'));
|
|
if (this.originalSlides.length === 0) return console.warn('no .slide1 found');
|
|
|
|
this.prevBtn = document.getElementById(this.prevId);
|
|
this.nextBtn = document.getElementById(this.nextId);
|
|
|
|
this.setupStructure();
|
|
this.bindEvents();
|
|
|
|
this.currentIndex = 1;
|
|
this.updateSlider(false);
|
|
this.startAutoPlay();
|
|
}
|
|
|
|
setupStructure() {
|
|
this.track.style.display = 'flex';
|
|
this.track.style.transition = 'transform 0.5s ease';
|
|
this.track.querySelectorAll('.slide1').forEach(s => {
|
|
s.style.minWidth = '100%';
|
|
s.style.boxSizing = 'border-box';
|
|
});
|
|
|
|
const first = this.originalSlides[0].cloneNode(true);
|
|
const last = this.originalSlides[this.originalSlides.length - 1].cloneNode(true);
|
|
|
|
this.track.insertBefore(last, this.track.firstChild);
|
|
this.track.appendChild(first);
|
|
|
|
this.slides = Array.from(this.track.querySelectorAll('.slide1'));
|
|
this.totalSlides = this.slides.length;
|
|
}
|
|
|
|
updateSlider(animate = true) {
|
|
this.track.style.transition = animate ? 'transform 0.5s ease' : 'none';
|
|
this.track.style.transform = `translateX(-${this.currentIndex * 100}%)`;
|
|
}
|
|
|
|
nextSlide() {
|
|
if (this.invert) {
|
|
this.currentIndex--;
|
|
this.updateSlider(true);
|
|
if (this.currentIndex === 0) {
|
|
setTimeout(() => {
|
|
this.track.style.transition = 'none';
|
|
this.currentIndex = this.slides.length - 2;
|
|
this.updateSlider(false);
|
|
}, 500);
|
|
}
|
|
} else {
|
|
this.currentIndex++;
|
|
this.updateSlider(true);
|
|
if (this.currentIndex === this.slides.length - 1) {
|
|
setTimeout(() => {
|
|
this.track.style.transition = 'none';
|
|
this.currentIndex = 1;
|
|
this.updateSlider(false);
|
|
}, 500);
|
|
}
|
|
}
|
|
this.restartAutoPlay();
|
|
}
|
|
|
|
prevSlide() {
|
|
if (this.invert) {
|
|
this.currentIndex++;
|
|
this.updateSlider(true);
|
|
if (this.currentIndex === this.slides.length - 1) {
|
|
setTimeout(() => {
|
|
this.track.style.transition = 'none';
|
|
this.currentIndex = 1;
|
|
this.updateSlider(false);
|
|
}, 500);
|
|
}
|
|
} else {
|
|
this.currentIndex--;
|
|
this.updateSlider(true);
|
|
if (this.currentIndex === 0) {
|
|
setTimeout(() => {
|
|
this.track.style.transition = 'none';
|
|
this.currentIndex = this.slides.length - 2;
|
|
this.updateSlider(false);
|
|
}, 500);
|
|
}
|
|
}
|
|
this.restartAutoPlay();
|
|
}
|
|
|
|
startAutoPlay() {
|
|
this.stopAutoPlay();
|
|
this.autoPlayInterval = setInterval(() => this.nextSlide(), this.autoPlayDuration);
|
|
}
|
|
|
|
stopAutoPlay() {
|
|
if (this.autoPlayInterval) {
|
|
clearInterval(this.autoPlayInterval);
|
|
this.autoPlayInterval = null;
|
|
}
|
|
}
|
|
|
|
restartAutoPlay() {
|
|
this.stopAutoPlay();
|
|
this.startAutoPlay();
|
|
}
|
|
|
|
bindEvents() {
|
|
if (this.nextBtn) this.nextBtn.addEventListener('click', () => this.nextSlide());
|
|
if (this.prevBtn) this.prevBtn.addEventListener('click', () => this.prevSlide());
|
|
|
|
const container = this.track.closest('.slide1r-container') || this.track.parentElement;
|
|
if (container) {
|
|
container.addEventListener('mouseenter', () => this.stopAutoPlay());
|
|
container.addEventListener('mouseleave', () => this.startAutoPlay());
|
|
}
|
|
|
|
let startX = 0, endX = 0;
|
|
this.track.addEventListener('touchstart', (e) => { startX = e.touches[0].clientX; this.stopAutoPlay(); });
|
|
this.track.addEventListener('touchmove', (e) => { endX = e.touches[0].clientX; });
|
|
this.track.addEventListener('touchend', () => {
|
|
const delta = startX - endX;
|
|
if (Math.abs(delta) > 50) {
|
|
if (delta > 0) this.nextSlide(); else this.prevSlide();
|
|
}
|
|
this.startAutoPlay();
|
|
});
|
|
|
|
document.addEventListener('keydown', (e) => {
|
|
const containerEl = document.querySelector('.slide1r-container');
|
|
if (!containerEl) return;
|
|
if (e.key === 'ArrowLeft') this.prevSlide();
|
|
if (e.key === 'ArrowRight') this.nextSlide();
|
|
});
|
|
}
|
|
}
|
|
|
|
new Slide1rSlider({ invert: true, autoPlayDuration: 4000 });
|
|
|
|
const statItems = document.querySelectorAll('.stat-item');
|
|
|
|
const observer = new IntersectionObserver((entries) => {
|
|
entries.forEach(entry => {
|
|
if (entry.isIntersecting) {
|
|
const index = Array.from(statItems).indexOf(entry.target);
|
|
entry.target.style.transitionDelay = `${(index + 1) * 0.1}s`;
|
|
entry.target.classList.add('visible');
|
|
}
|
|
});
|
|
}, { threshold: 0.2 });
|
|
|
|
console.log("test");
|
|
document.addEventListener('DOMContentLoaded', async () => {
|
|
const allCourses = [];
|
|
|
|
const baseUrl = 'https://kodepilot.in/course/index.php';
|
|
const res = await fetch(baseUrl);
|
|
const html = await res.text();
|
|
|
|
const categoryRegex = /<h3 class="categoryname aabtn"><a href="([^"]+)">([^<]+)<\/a><\/h3>/g;
|
|
const categories = [];
|
|
let match;
|
|
while ((match = categoryRegex.exec(html)) !== null) {
|
|
categories.push({ url: match[1], name: match[2] });
|
|
}
|
|
|
|
for (const category of categories) {
|
|
const resCat = await fetch(category.url);
|
|
const catHtml = await resCat.text();
|
|
const cleanHtml = catHtml.replace(/\n/g, ' ');
|
|
|
|
const courseRegex = /<div class="card dashboard-card [^"]*"[^>]*>.*?<a href="([^"]+)"[^>]*>.*?background-image: url\(([^)]+)\);".*?<span class="sr-only">(.*?)<\/span>.*?<div class="course-category">\s*([^<]+)<\/div>.*?<div class="course-summary">.*?<p>(.*?)<\/p>/g;
|
|
|
|
while ((match = courseRegex.exec(cleanHtml)) !== null) {
|
|
allCourses.push({
|
|
category: match[4].trim(),
|
|
link: match[1].trim(),
|
|
image: match[2].trim(),
|
|
name: match[3].trim(),
|
|
description: match[5].replace(/<br\s*\/?>/g, ' ').trim()
|
|
});
|
|
}
|
|
}
|
|
console.table(allCourses);
|
|
|
|
|
|
renderCourses(allCourses);
|
|
});
|
|
|
|
function renderCourses(allCourses) {
|
|
const container = document.querySelector('.corces');
|
|
if (!container) return;
|
|
|
|
container.innerHTML = '';
|
|
|
|
const grouped = {};
|
|
allCourses.forEach(course => {
|
|
if (!grouped[course.category]) grouped[course.category] = [];
|
|
grouped[course.category].push(course);
|
|
});
|
|
|
|
let sections = Object.entries(grouped).map(([category, courses]) => ({ category, courses }));
|
|
|
|
let mergedSections = [];
|
|
let temp = { category: '', courses: [] };
|
|
|
|
sections.forEach(section => {
|
|
if (section.courses.length >= 4) {
|
|
mergedSections.push(section);
|
|
} else {
|
|
if (temp.category) temp.category += '/' + section.category;
|
|
else temp.category = section.category;
|
|
temp.courses.push(...section.courses);
|
|
|
|
if (temp.courses.length >= 4) {
|
|
mergedSections.push({ category: temp.category, courses: temp.courses });
|
|
temp = { category: '', courses: [] };
|
|
}
|
|
}
|
|
});
|
|
|
|
if (temp.courses.length >= 4) {
|
|
mergedSections.push(temp);
|
|
}
|
|
|
|
mergedSections.forEach(sectionData => {
|
|
const section = document.createElement('div');
|
|
section.className = 'course-section';
|
|
section.innerHTML = `
|
|
<h2 class="course-category-title">${sectionData.category}</h2>
|
|
<div class="course-slider-box">
|
|
<div class="course-slider">
|
|
<button class="prev-btn nav-button"></button>
|
|
<div class="course-track"></div>
|
|
<button class="next-btn nav-button"></button>
|
|
</div>
|
|
</div>
|
|
`;
|
|
|
|
const track = section.querySelector('.course-track');
|
|
const prevBtn = section.querySelector('.prev-btn');
|
|
const nextBtn = section.querySelector('.next-btn');
|
|
|
|
sectionData.courses.forEach(course => {
|
|
const courseDiv = document.createElement('div');
|
|
courseDiv.className = 'course-card';
|
|
courseDiv.innerHTML = `
|
|
<a href="${course.link}" target="_blank">
|
|
<div class="course-image" style="background-image: url(${course.image});"></div>
|
|
</a>
|
|
<div class="course-content">
|
|
<a href="/apply" class="course-name" target="_blank">${course.name}</a>
|
|
<div class="course-description">${course.description}</div>
|
|
</div>
|
|
`;
|
|
track.appendChild(courseDiv);
|
|
});
|
|
|
|
|
|
const scrollAmount = 300;
|
|
prevBtn.addEventListener('click', () => track.scrollBy({ left: -scrollAmount, behavior: 'smooth' }));
|
|
nextBtn.addEventListener('click', () => track.scrollBy({ left: scrollAmount, behavior: 'smooth' }));
|
|
|
|
|
|
let startX = 0;
|
|
let isDragging = false;
|
|
|
|
track.addEventListener('touchstart', e => {
|
|
startX = e.touches[0].clientX;
|
|
isDragging = true;
|
|
});
|
|
|
|
track.addEventListener('touchmove', e => {
|
|
if (!isDragging) return;
|
|
const x = e.touches[0].clientX;
|
|
const walk = (startX - x) * 10;
|
|
track.scrollLeft += walk;
|
|
startX = x;
|
|
});
|
|
|
|
|
|
track.addEventListener('touchend', () => {
|
|
isDragging = false;
|
|
});
|
|
|
|
container.appendChild(section);
|
|
});
|
|
|
|
}
|
|
|
|
|
|
statItems.forEach(item => observer.observe(item));
|
|
|
|
|
|
const track = document.querySelector('.mnc-logos-track');
|
|
const gap = 40;
|
|
let index = 0;
|
|
|
|
function stepScroll() {
|
|
const items = track.children;
|
|
const first = items[0];
|
|
const moveWidth = first.offsetWidth + gap;
|
|
|
|
track.style.transform = `translateX(-${moveWidth}px)`;
|
|
|
|
track.addEventListener('transitionend', function handler() {
|
|
track.appendChild(first);
|
|
track.style.transition = 'none';
|
|
track.style.transform = 'translateX(0)';
|
|
void track.offsetWidth;
|
|
track.style.transition = 'transform 0.5s ease';
|
|
track.removeEventListener('transitionend', handler);
|
|
});
|
|
}
|
|
|
|
setInterval(stepScroll, 3000);
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const cards = document.querySelectorAll('.practice-card');
|
|
let activeCard = document.querySelector('.practice-card.active');
|
|
let lastActiveCard = activeCard;
|
|
|
|
function setActiveCard(card) {
|
|
cards.forEach(c => {
|
|
c.classList.remove('active');
|
|
});
|
|
|
|
card.classList.add('active');
|
|
|
|
lastActiveCard = card;
|
|
}
|
|
|
|
if (!activeCard && cards.length > 0) {
|
|
setActiveCard(cards[0]);
|
|
}
|
|
|
|
cards.forEach(card => {
|
|
card.addEventListener('click', function () {
|
|
setActiveCard(this);
|
|
});
|
|
});
|
|
});
|
|
|
|
const data = [
|
|
{ name: "Ben", text: "Just Went HCL!" },
|
|
{ name: "Rakul", text: "Just Went Accenture!" },
|
|
{ name: "Anjali", text: "Joined a Ebmpapst!" },
|
|
{ name: "Sneha", text: "joined a Infosys!" },
|
|
{ name: "Amit", text: "Just Went JBL!" },
|
|
{ name: "Vikram", text: "Just Went UST!" },
|
|
{ name: "Priya", text: "Just Went Serviceplaingroup!" }
|
|
];
|
|
let index1 = 0;
|
|
const nameEl1 = document.querySelector(".nameContainer");
|
|
const descEl1 = document.querySelector(".descContainer");
|
|
setInterval(() => {
|
|
nameEl1.classList.add("fade-out");
|
|
descEl1.classList.add("fade-out");
|
|
setTimeout(() => {
|
|
index1 = (index1 + 1) % data.length;
|
|
nameEl1.textContent = data[index1].name;
|
|
descEl1.textContent = " " + data[index1].text;
|
|
nameEl1.classList.remove("fade-out");
|
|
descEl1.classList.remove("fade-out");
|
|
nameEl1.classList.add("fade-in");
|
|
descEl1.classList.add("fade-in");
|
|
setTimeout(() => {
|
|
nameEl1.classList.remove("fade-in");
|
|
descEl1.classList.remove("fade-in");
|
|
}, 500);
|
|
}, 500);
|
|
}, 5000);
|
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
document.querySelectorAll(".footer a").forEach(link => {
|
|
link.setAttribute("href", "/apply");
|
|
});
|
|
|
|
document.querySelectorAll(".practice-container a").forEach(link => {
|
|
link.setAttribute("href", "/apply");
|
|
});
|
|
});
|
|
|
|
|
|
class ModernMobileMenu {
|
|
constructor() {
|
|
this.buttonsContainer = document.querySelector('.buttons');
|
|
this.hamburger = null;
|
|
this.mobileMenu = null;
|
|
this.overlay = null;
|
|
this.isMenuOpen = false;
|
|
|
|
this.init();
|
|
}
|
|
|
|
init() {
|
|
this.createMobileMenu();
|
|
this.bindEvents();
|
|
this.checkScreenSize();
|
|
|
|
|
|
window.addEventListener('resize', () => this.checkScreenSize());
|
|
}
|
|
createMobileMenu() {
|
|
|
|
this.hamburger = document.createElement('div');
|
|
this.hamburger.className = 'mobile-hamburger';
|
|
this.hamburger.innerHTML = `
|
|
<div class="hamburger-line"></div>
|
|
<div class="hamburger-line"></div>
|
|
<div class="hamburger-line"></div>
|
|
`;
|
|
|
|
|
|
this.overlay = document.createElement('div');
|
|
this.overlay.className = 'mobile-menu-overlay';
|
|
|
|
|
|
this.mobileMenu = document.createElement('div');
|
|
this.mobileMenu.className = 'mobile-slide-menu';
|
|
|
|
|
|
const originalButtons = this.buttonsContainer.querySelectorAll('button');
|
|
|
|
|
|
const closeBtn = document.createElement('button');
|
|
closeBtn.className = 'menu-close-btn';
|
|
closeBtn.innerHTML = '×';
|
|
this.mobileMenu.appendChild(closeBtn);
|
|
|
|
|
|
originalButtons.forEach(btn => {
|
|
const mobileBtn = document.createElement('button');
|
|
mobileBtn.className = 'mobile-menu-item';
|
|
mobileBtn.textContent = btn.textContent;
|
|
mobileBtn.onclick = () => {
|
|
btn.click();
|
|
this.closeMenu();
|
|
};
|
|
this.mobileMenu.appendChild(mobileBtn);
|
|
});
|
|
|
|
|
|
this.buttonsContainer.parentNode.insertBefore(this.hamburger, this.buttonsContainer.nextSibling);
|
|
document.body.appendChild(this.overlay);
|
|
document.body.appendChild(this.mobileMenu);
|
|
}
|
|
|
|
bindEvents() {
|
|
this.hamburger.addEventListener('click', () => this.toggleMenu());
|
|
this.overlay.addEventListener('click', () => this.closeMenu());
|
|
this.mobileMenu.querySelector('.menu-close-btn').addEventListener('click', () => this.closeMenu());
|
|
|
|
|
|
document.addEventListener('keydown', (e) => {
|
|
if (e.key === 'Escape' && this.isMenuOpen) {
|
|
this.closeMenu();
|
|
}
|
|
});
|
|
}
|
|
|
|
toggleMenu() {
|
|
this.isMenuOpen ? this.closeMenu() : this.openMenu();
|
|
}
|
|
|
|
openMenu() {
|
|
this.isMenuOpen = true;
|
|
this.hamburger.classList.add('active');
|
|
this.overlay.classList.add('active');
|
|
this.mobileMenu.classList.add('active');
|
|
document.body.style.overflow = 'hidden';
|
|
|
|
|
|
const items = this.mobileMenu.querySelectorAll('.mobile-menu-item');
|
|
items.forEach((item, index) => {
|
|
setTimeout(() => {
|
|
item.style.opacity = '1';
|
|
item.style.transform = 'translateX(0)';
|
|
}, (index + 1) * 100);
|
|
});
|
|
}
|
|
|
|
closeMenu() {
|
|
this.isMenuOpen = false;
|
|
this.hamburger.classList.remove('active');
|
|
this.overlay.classList.remove('active');
|
|
this.mobileMenu.classList.remove('active');
|
|
document.body.style.overflow = '';
|
|
|
|
|
|
const items = this.mobileMenu.querySelectorAll('.mobile-menu-item');
|
|
items.forEach(item => {
|
|
item.style.opacity = '0';
|
|
item.style.transform = 'translateX(30px)';
|
|
});
|
|
}
|
|
|
|
checkScreenSize() {
|
|
if (window.innerWidth <= 480) {
|
|
this.hamburger.style.display = 'flex';
|
|
} else {
|
|
this.hamburger.style.display = 'none';
|
|
this.closeMenu();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', () => new ModernMobileMenu());
|
|
} else {
|
|
new ModernMobileMenu();
|
|
}
|
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
const counters = document.querySelectorAll(".stat-number");
|
|
|
|
const animateCounter = (el, target) => {
|
|
let current = 0;
|
|
const step = Math.ceil(target / 50);
|
|
const interval = setInterval(() => {
|
|
current += step;
|
|
if (current >= target) {
|
|
current = target;
|
|
clearInterval(interval);
|
|
}
|
|
el.innerHTML = current + "<span class='highlight'>+</span>";
|
|
}, 20);
|
|
};
|
|
|
|
const observer = new IntersectionObserver(entries => {
|
|
entries.forEach(entry => {
|
|
if (entry.isIntersecting) {
|
|
const el = entry.target;
|
|
const finalNumber = parseInt(el.textContent);
|
|
animateCounter(el, finalNumber);
|
|
observer.unobserve(el);
|
|
}
|
|
});
|
|
}, { threshold: 0.3 });
|
|
|
|
counters.forEach(counter => observer.observe(counter));
|
|
}); |