973 lines
28 KiB
HTML
973 lines
28 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Kodepilot Clone</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
font-family: Arial, sans-serif;
|
|
background: #fff;
|
|
color: #333;
|
|
}
|
|
|
|
.navbar {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 12px 30px;
|
|
background: #fff;
|
|
border-bottom: 1px solid #eee;
|
|
}
|
|
|
|
.logo {
|
|
font-size: 22px;
|
|
font-weight: bold;
|
|
color: #003366;
|
|
}
|
|
|
|
.search {
|
|
flex: 1;
|
|
margin: 0 20px;
|
|
padding: 8px 12px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 20px;
|
|
}
|
|
|
|
nav a {
|
|
margin: 0 10px;
|
|
text-decoration: none;
|
|
color: #333;
|
|
}
|
|
|
|
.buttons button {
|
|
margin-left: 10px;
|
|
padding: 8px 15px;
|
|
border: none;
|
|
border-radius: 20px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.host {
|
|
background: #eee;
|
|
}
|
|
|
|
.business {
|
|
background: #ffcc00;
|
|
}
|
|
|
|
.login {
|
|
background: #007bff;
|
|
color: #fff;
|
|
}
|
|
|
|
.hero {
|
|
text-align: start;
|
|
padding: 50px 20px;
|
|
line-height: 20px;
|
|
}
|
|
|
|
.hero h1 {
|
|
font-size: 42px;
|
|
color: #383838;
|
|
}
|
|
|
|
.hero h1 .blue_text {
|
|
color: #1c4980;
|
|
}
|
|
|
|
.hero p {
|
|
font-size: 18px;
|
|
color: #717171;
|
|
font-size: 16px;
|
|
line-height: 140%;
|
|
margin-top: 12px;
|
|
margin-bottom: 0;
|
|
width: 470px;
|
|
}
|
|
|
|
.hero_container {
|
|
display: flex;
|
|
gap: 40px;
|
|
max-width: 1200px;
|
|
margin: auto;
|
|
padding: 20px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.cards_box {
|
|
margin-top: 80px;
|
|
flex: 1 1 300px;
|
|
}
|
|
|
|
.cards {
|
|
flex: 2 1 60px;
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
|
gap: 20px;
|
|
}
|
|
|
|
.card {
|
|
position: relative;
|
|
border-radius: 12px;
|
|
cursor: pointer;
|
|
padding: 12px 16px;
|
|
overflow: hidden;
|
|
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
|
height: 90px;
|
|
}
|
|
|
|
.card:hover {
|
|
transform: translateY(-10px);
|
|
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
|
|
}
|
|
|
|
|
|
.card small {
|
|
display: block;
|
|
margin-top: 10px;
|
|
font-weight: normal;
|
|
}
|
|
|
|
.green {
|
|
background: #9BE6C1;
|
|
}
|
|
|
|
.orange {
|
|
background: #fec192;
|
|
}
|
|
|
|
.blue {
|
|
background: #9bc9ff;
|
|
background-image: url('https://d8it4huxumps7.cloudfront.net/uploads/images/67724b0c0d0f7_img1.png?d=211x163');
|
|
background-size: 140px;
|
|
background-repeat: no-repeat;
|
|
background-position: bottom right;
|
|
}
|
|
|
|
|
|
.purple {
|
|
background: #c8bbff;
|
|
}
|
|
|
|
.yellow {
|
|
background: #ffdd80;
|
|
color: #333;
|
|
}
|
|
|
|
.pink {
|
|
background: #ffb1cc;
|
|
}
|
|
|
|
.users {
|
|
padding: 0px 20px;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
text-align: start;
|
|
}
|
|
|
|
.users_box {
|
|
max-width: 1200px;
|
|
}
|
|
|
|
.know-cards {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.user-cards {
|
|
display: flex;
|
|
justify-content: center;
|
|
gap: 20px;
|
|
margin-top: 30px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.button_blue_box {
|
|
margin-top: 24px;
|
|
padding: 8px 25px 8px 10px;
|
|
border: 0px solid #717171;
|
|
background-color: #ebe8fd;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
border-radius: 50px;
|
|
}
|
|
|
|
.nameContainer {
|
|
display: flex;
|
|
color: #717171;
|
|
}
|
|
|
|
.crd {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 16px;
|
|
padding: 16px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 12px;
|
|
background: #fff;
|
|
max-width: 600px;
|
|
margin-left: 10px;
|
|
margin-right: 10px;
|
|
}
|
|
|
|
.crd img {
|
|
flex-shrink: 0;
|
|
border-radius: 8px;
|
|
padding: 8px;
|
|
height: 79px;
|
|
width: auto;
|
|
}
|
|
|
|
.crd .h4 {
|
|
font-size: 16px;
|
|
font-weight: 500;
|
|
line-height: 140%;
|
|
color: #383838;
|
|
margin-bottom: 6px;
|
|
}
|
|
|
|
.crd p {
|
|
font-size: 12px;
|
|
line-height: 140%;
|
|
color: #383838;
|
|
}
|
|
|
|
.knon_more {
|
|
margin-left: 50%;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.user-card {
|
|
background: #f9f9f9;
|
|
padding: 20px;
|
|
border-radius: 12px;
|
|
width: 280px;
|
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.mnc {
|
|
padding: 40px 20px;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
text-align: start;
|
|
}
|
|
|
|
.mnc-box {
|
|
display: flex;
|
|
align-items: center;
|
|
max-width: 1200px;
|
|
|
|
}
|
|
|
|
.mnc-row {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 40px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.mnc h2 {
|
|
font-size: 22px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.mnc h2 .gray,
|
|
.mnc h2 .blue_text {
|
|
display: block;
|
|
}
|
|
|
|
.mnc h2 .blue_text {
|
|
color: #1c4980;
|
|
}
|
|
|
|
|
|
.mnc-logos {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 40px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.mnc-logos img {
|
|
height: 40px;
|
|
object-fit: contain;
|
|
transition: transform 0.3s ease;
|
|
}
|
|
|
|
.mnc-logos img:hover {
|
|
transform: scale(1.1);
|
|
}
|
|
|
|
.our-numbers {
|
|
max-width: 1200px;
|
|
margin: 0 auto 47px auto;
|
|
}
|
|
|
|
.our-numbers h2 {
|
|
text-align: center;
|
|
font-size: 2.5rem;
|
|
color: #2d3748;
|
|
margin-bottom: 20px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.stats-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(6, 1fr);
|
|
gap: 20px;
|
|
justify-items: center;
|
|
align-items: stretch;
|
|
}
|
|
|
|
.stat-item {
|
|
background: HSL(0, 0%, 96.5%);
|
|
text-align: center;
|
|
padding: 20px 10px;
|
|
border-radius: 14px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: center;
|
|
min-height: 120px;
|
|
width: 100%;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.stat-number {
|
|
display: block;
|
|
font-size: clamp(1.8rem, 2.5vw, 3rem);
|
|
font-weight: 700;
|
|
color: #2d3748;
|
|
margin-bottom: 10px;
|
|
line-height: 1;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.stat-number .highlight {
|
|
color: #3182ce;
|
|
}
|
|
|
|
.highlight {
|
|
color: #1c4980;
|
|
}
|
|
|
|
.stat-label {
|
|
font-size: clamp(0.8rem, 1vw, 1rem);
|
|
color: #718096;
|
|
font-weight: 500;
|
|
text-transform: capitalize;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
width: 100%;
|
|
}
|
|
|
|
@media (max-width: 1024px) {
|
|
.stats-grid {
|
|
grid-template-columns: repeat(3, 1fr);
|
|
gap: 15px;
|
|
}
|
|
|
|
.stat-item {
|
|
min-height: 100px;
|
|
padding: 15px 8px;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.our-numbers {
|
|
padding: 40px 20px;
|
|
}
|
|
|
|
.our-numbers h2 {
|
|
font-size: 2rem;
|
|
margin-bottom: 40px;
|
|
}
|
|
|
|
.stats-grid {
|
|
grid-template-columns: repeat(2, 1fr);
|
|
gap: 30px;
|
|
}
|
|
|
|
.stat-number {
|
|
font-size: 2.5rem;
|
|
}
|
|
|
|
.stat-item {
|
|
min-height: 110px;
|
|
padding: 20px;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 480px) {
|
|
.stats-grid {
|
|
grid-template-columns: 1fr;
|
|
gap: 25px;
|
|
}
|
|
|
|
.stat-number {
|
|
font-size: 2.2rem;
|
|
}
|
|
}
|
|
|
|
@keyframes fadeInUp {
|
|
from {
|
|
opacity: 0;
|
|
transform: translateY(30px);
|
|
}
|
|
|
|
to {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
}
|
|
|
|
.stat-item {
|
|
animation: fadeInUp 0.6s ease forwards;
|
|
}
|
|
|
|
.stat-item:nth-child(1) {
|
|
animation-delay: 0.1s;
|
|
}
|
|
|
|
.stat-item:nth-child(2) {
|
|
animation-delay: 0.2s;
|
|
}
|
|
|
|
.stat-item:nth-child(3) {
|
|
animation-delay: 0.3s;
|
|
}
|
|
|
|
.stat-item:nth-child(4) {
|
|
animation-delay: 0.4s;
|
|
}
|
|
|
|
.stat-item:nth-child(5) {
|
|
animation-delay: 0.5s;
|
|
}
|
|
|
|
.stat-item:nth-child(6) {
|
|
animation-delay: 0.6s;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<header class="navbar">
|
|
<div class="logo">Kodepilot</div>
|
|
<input type="text" class="search" placeholder="Search Opportunities">
|
|
<nav>
|
|
<a href="#">Internships</a>
|
|
<a href="#">Jobs</a>
|
|
<a href="#">Competitions</a>
|
|
<a href="#">Mentorships</a>
|
|
<a href="#">Practice</a>
|
|
<a href="#">More ▾</a>
|
|
</nav>
|
|
<div class="buttons">
|
|
<button class="host">+ Host</button>
|
|
<button class="business">For Business</button>
|
|
<button class="login" onclick="goToLogin()">Login</button>
|
|
</div>
|
|
</header>
|
|
|
|
<section class="hero">
|
|
<div class="hero_container">
|
|
<div class="cards_box">
|
|
<h1><span class="blue_text">Unlock</span> Your Career</h1>
|
|
<p>Explore opportunities from across the globe to grow, showcase skills, gain CV points & get hired by
|
|
your
|
|
dream company.</p>
|
|
<button class="button_blue_box"><img
|
|
src="https://d8it4huxumps7.cloudfront.net/uploads/images/655edc8c1fab9_diamond_1.png?d=82x84"
|
|
width="41" height="42" alt="diamond" loading="lazy"><span><span
|
|
class="nameContainer">Aditya</span><strong> Just Went
|
|
Kodepilot!</strong></span></button>
|
|
</div>
|
|
<div class="cards">
|
|
<div class="card green">Internships<br><small>Gain Practical Experience</small></div>
|
|
<div class="card orange">Mentorships<br><small>Guidance From Top Mentors</small></div>
|
|
<div class="card blue">Jobs<br><small>Explore Diverse Careers</small></div>
|
|
<div class="card purple">Practice<br><small>Refine Skills Daily</small></div>
|
|
<div class="card yellow">Competitions<br><small>Battle For Excellence</small></div>
|
|
<div class="card pink">More<br><small>Explore More Options</small></div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="users">
|
|
<div class="users_box">
|
|
<h2>Who's using Kodepilot?</h2>
|
|
<div class="know-cards">
|
|
<div>
|
|
<div class="crd">
|
|
<div class="d-flex flex-column">
|
|
<div class="h4">Students and Professionals</div>
|
|
<p><strong>Unlock
|
|
Your
|
|
Potential:</strong> Compete, Build Resume, Grow and get Hired! </p>
|
|
</div><img
|
|
src="https://d8it4huxumps7.cloudfront.net/uploads/images/67724b0c0d0f7_img1.png?d=211x163"
|
|
alt="Students and Professionals" width="105" height="81" loading="lazy">
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="crd">
|
|
<div class="d-flex flex-column">
|
|
<div class="h4">Companies and Recruiters</div>
|
|
<p><strong>Discover
|
|
Right
|
|
Talent:</strong> Hire, Engage, and Brand Like Never Before! </p>
|
|
</div><img
|
|
src="https://d8it4huxumps7.cloudfront.net/uploads/images/67727626b861a_img2.png?d=211x163"
|
|
alt="Companies and Recruiters" width="105" height="81" loading="lazy">
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="crd">
|
|
<div class="d-flex flex-column">
|
|
<div class="h4">Colleges</div>
|
|
<p><strong>Bridge
|
|
Academia
|
|
and Industry:</strong> Empower Students with Real-World Opportunities! </p>
|
|
</div><img
|
|
src="https://d8it4huxumps7.cloudfront.net/uploads/images/67724b2a99511_img3.png?d=211x163"
|
|
alt="ridge Academia and Industry" width="105" height="81" loading="lazy">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div role="button" tabindex="0" class="knon_more"> Know How <un-icon _nghost-serverapp-c3674528818=""><img
|
|
style="--size: 18px;" src="https://cdn.Kodepilot.com/assets/icons/chevron_down.svg" height="18"
|
|
width="18" alt="chevron_down" class="ng-star-inserted"></un-icon>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="mnc">
|
|
<div class="mnc-box">
|
|
<div class="mnc-row">
|
|
<h2>
|
|
<span class="gray">Industry veterans</span>
|
|
<span class="blue_text">trust us</span>
|
|
</h2>
|
|
<div class="mnc-logos">
|
|
<img src="https://repo.dhanu.cloud/ico/hcl.svg" alt="hcl">
|
|
<img src="https://repo.dhanu.cloud/ico/ebmpapst.svg" alt="ebmpapst">
|
|
<img src="https://repo.dhanu.cloud/ico/infosys.svg" alt="infosys">
|
|
<img src="https://repo.dhanu.cloud/ico/jbl.svg" alt="jbl">
|
|
<img src="https://repo.dhanu.cloud/ico/ust.svg" alt="ust">
|
|
<img src="https://repo.dhanu.cloud/ico/accenture.svg" alt="accenture">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
|
|
<style>
|
|
.opportunity-section {
|
|
padding: 0 0 50px 0;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1152px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.header {
|
|
text-align: start;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.title {
|
|
font-size: 35px;
|
|
font-weight: bold;
|
|
color: #111827;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.header-content {
|
|
display: flex;
|
|
align-items: start;
|
|
justify-content: start;
|
|
gap: 16px;
|
|
}
|
|
|
|
.subtitle {
|
|
color: #6b7280;
|
|
line-height: 0px;
|
|
}
|
|
|
|
.arrow-icon {
|
|
width: 16px;
|
|
height: 16px;
|
|
}
|
|
|
|
.cards-grid {
|
|
display: grid;
|
|
grid-template-columns: 1fr;
|
|
gap: 24px;
|
|
}
|
|
|
|
@media (min-width: 768px) {
|
|
.cards-grid {
|
|
grid-template-columns: repeat(3, 1fr);
|
|
}
|
|
}
|
|
|
|
@media (min-width: 1024px) {
|
|
.cards-grid {
|
|
grid-template-columns: repeat(5, 1fr);
|
|
}
|
|
}
|
|
|
|
.card-add {
|
|
border-radius: 24px;
|
|
padding: 24px;
|
|
position: relative;
|
|
overflow: hidden;
|
|
min-height: 160px;
|
|
cursor: pointer;
|
|
transition: transform 0.3s ease;
|
|
}
|
|
|
|
.card-add:hover {
|
|
transform: scale(1.05);
|
|
}
|
|
|
|
.card-add h3 {
|
|
font-size: 20px;
|
|
font-weight: bold;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.card-quizzes {
|
|
background: linear-gradient(to bottom right, #60a5fa, #2563eb);
|
|
color: white;
|
|
}
|
|
|
|
.card-hackathons {
|
|
background: linear-gradient(to bottom right, #4ade80, #22c55e);
|
|
color: white;
|
|
}
|
|
|
|
.card-scholarships {
|
|
background: linear-gradient(to bottom right, #a855f7, #7c3aed);
|
|
color: white;
|
|
}
|
|
|
|
.card-conferences {
|
|
background: linear-gradient(to bottom right, #fed7aa, #fdba74);
|
|
color: #1f2937;
|
|
}
|
|
|
|
.card-festivals {
|
|
background: linear-gradient(to bottom right, #facc15, #eab308);
|
|
color: #1f2937;
|
|
}
|
|
</style>
|
|
|
|
<section class="opportunity-section">
|
|
<div class="container">
|
|
<div class="header">
|
|
<h2 class="title">
|
|
Pick <span class="highlight">The Right Opportunity!</span>
|
|
</h2>
|
|
<div class="header-content">
|
|
<p class="subtitle">Explore opportunities that best suits your skills and interests!</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="cards-grid">
|
|
<div class="card-add card-quizzes">
|
|
<h3>Quizzes</h3>
|
|
</div>
|
|
|
|
<div class="card-add card-hackathons">
|
|
<h3>Hackathons</h3>
|
|
</div>
|
|
|
|
<div class="card-add card-scholarships">
|
|
<h3>Scholarships</h3>
|
|
</div>
|
|
|
|
<div class="card-add card-conferences">
|
|
<h3>Conferences</h3>
|
|
</div>
|
|
|
|
<div class="card-add card-festivals">
|
|
<h3>College Festivals</h3>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<div id="slider"></div>
|
|
<div id="slide"></div>
|
|
|
|
<section class="our-numbers">
|
|
<h2>Our Numbers</h2>
|
|
|
|
<div class="stats-grid">
|
|
<div class="stat-item">
|
|
<span class="stat-number">25 <span class="highlight">M+</span></span>
|
|
<span class="stat-label">Active Users</span>
|
|
</div>
|
|
|
|
<div class="stat-item">
|
|
<span class="stat-number">22.3 <span class="highlight">M+</span></span>
|
|
<span class="stat-label">Assessments</span>
|
|
</div>
|
|
|
|
<div class="stat-item">
|
|
<span class="stat-number">130 <span class="highlight">K+</span></span>
|
|
<span class="stat-label">Opportunities</span>
|
|
</div>
|
|
|
|
<div class="stat-item">
|
|
<span class="stat-number">800 <span class="highlight">+</span></span>
|
|
<span class="stat-label">Brands trust us</span>
|
|
</div>
|
|
|
|
<div class="stat-item">
|
|
<span class="stat-number">42 <span class="highlight">K+</span></span>
|
|
<span class="stat-label">Organisations</span>
|
|
</div>
|
|
|
|
<div class="stat-item">
|
|
<span class="stat-number">78 <span class="highlight">+</span></span>
|
|
<span class="stat-label">Countries</span>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<div id="footer-placeholder"></div>
|
|
<script>
|
|
fetch("footer.html")
|
|
.then(res => res.text())
|
|
.then(data => {
|
|
document.getElementById("footer-placeholder").innerHTML = data;
|
|
})
|
|
.catch(err => console.error("Failed to load footer:", err));
|
|
fetch("slider.html")
|
|
.then(res => res.text())
|
|
.then(data => {
|
|
document.getElementById("slider").innerHTML = data;
|
|
})
|
|
.catch(err => console.error("Failed to load slider:", err));
|
|
fetch("slide.html")
|
|
.then(res => res.text())
|
|
.then(data => {
|
|
document.getElementById("slide").innerHTML = data;
|
|
})
|
|
.catch(err => console.error("Failed to load footer:", err));
|
|
function goToLogin() {
|
|
window.location.href = "/login";
|
|
}
|
|
|
|
(function () {
|
|
// Prevent multiple instances
|
|
if (window.Slide1rSliderLoaded) {
|
|
return;
|
|
}
|
|
window.Slide1rSliderLoaded = true;
|
|
|
|
class Slide1rSlider {
|
|
constructor() {
|
|
// Add a small delay to ensure DOM is fully rendered
|
|
setTimeout(() => {
|
|
this.initSlider();
|
|
}, 100);
|
|
}
|
|
|
|
initSlider() {
|
|
try {
|
|
this.track = document.getElementById('slide1rTrack');
|
|
this.slides = document.querySelectorAll('.slide1');
|
|
this.prevBtn = document.getElementById('prevBtn');
|
|
this.nextBtn = document.getElementById('nextBtn');
|
|
|
|
if (!this.track || this.slides.length === 0) {
|
|
console.warn("Slider DOM elements not found. Retrying...");
|
|
// Retry after a short delay
|
|
setTimeout(() => this.initSlider(), 200);
|
|
return;
|
|
}
|
|
|
|
this.currentIndex = 0;
|
|
this.totalSlides = this.slides.length;
|
|
this.autoPlayDuration = 5000; // 5 seconds
|
|
|
|
this.init();
|
|
} catch (err) {
|
|
console.error("Slider initialization failed:", err);
|
|
}
|
|
}
|
|
|
|
init() {
|
|
try {
|
|
this.updateSlider();
|
|
this.bindEvents();
|
|
this.startAutoPlay();
|
|
this.bindKeyboardEvents();
|
|
} catch (err) {
|
|
console.error("Slider init error:", err);
|
|
}
|
|
}
|
|
|
|
|
|
updateSlider() {
|
|
try {
|
|
const translateX = -this.currentIndex * 100;
|
|
this.track.style.transform = `translateX(${translateX}%)`;
|
|
|
|
} catch (err) {
|
|
console.error("Error updating slider:", err);
|
|
}
|
|
}
|
|
|
|
nextSlide() {
|
|
try {
|
|
this.currentIndex = (this.currentIndex + 1) % this.totalSlides;
|
|
this.updateSlider();
|
|
this.restartAutoPlay();
|
|
} catch (err) {
|
|
console.error("Error going to next slide:", err);
|
|
}
|
|
}
|
|
|
|
prevSlide() {
|
|
try {
|
|
this.currentIndex = this.currentIndex === 0 ? this.totalSlides - 1 : this.currentIndex - 1;
|
|
this.updateSlider();
|
|
this.restartAutoPlay();
|
|
} catch (err) {
|
|
console.error("Error going to previous slide:", err);
|
|
}
|
|
}
|
|
|
|
goToSlide(index) {
|
|
try {
|
|
this.currentIndex = index;
|
|
this.updateSlider();
|
|
this.restartAutoPlay();
|
|
} catch (err) {
|
|
console.error("Error going to slide:", err);
|
|
}
|
|
}
|
|
|
|
startAutoPlay() {
|
|
try {
|
|
this.stopAutoPlay();
|
|
|
|
this.autoPlayInterval = setInterval(() => {
|
|
this.nextSlide();
|
|
}, this.autoPlayDuration);
|
|
|
|
} catch (err) {
|
|
console.error("Error starting autoplay:", err);
|
|
}
|
|
}
|
|
|
|
stopAutoPlay() {
|
|
if (this.autoPlayInterval) {
|
|
clearInterval(this.autoPlayInterval);
|
|
this.autoPlayInterval = null;
|
|
}
|
|
}
|
|
|
|
restartAutoPlay() {
|
|
this.stopAutoPlay();
|
|
this.startAutoPlay();
|
|
}
|
|
|
|
bindEvents() {
|
|
try {
|
|
if (this.nextBtn) {
|
|
this.nextBtn.addEventListener('click', () => this.nextSlide());
|
|
}
|
|
|
|
if (this.prevBtn) {
|
|
this.prevBtn.addEventListener('click', () => this.prevSlide());
|
|
}
|
|
|
|
// Pause on hover
|
|
const container = document.querySelector('.slide1r-container');
|
|
if (container) {
|
|
container.addEventListener('mouseenter', () => this.stopAutoPlay());
|
|
container.addEventListener('mouseleave', () => this.startAutoPlay());
|
|
}
|
|
|
|
// Touch support
|
|
let startX = 0;
|
|
let endX = 0;
|
|
|
|
if (this.track) {
|
|
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 deltaX = startX - endX;
|
|
if (Math.abs(deltaX) > 50) {
|
|
if (deltaX > 0) {
|
|
this.nextSlide();
|
|
} else {
|
|
this.prevSlide();
|
|
}
|
|
}
|
|
this.startAutoPlay();
|
|
});
|
|
}
|
|
} catch (err) {
|
|
console.error("Error binding events:", err);
|
|
}
|
|
}
|
|
|
|
bindKeyboardEvents() {
|
|
// Use a more specific event listener to avoid conflicts
|
|
const keyHandler = (e) => {
|
|
// Only respond if the slider container is visible
|
|
const container = document.querySelector('.slide1r-container');
|
|
if (container && this.isElementInViewport(container)) {
|
|
if (e.key === 'ArrowLeft') {
|
|
this.prevSlide();
|
|
} else if (e.key === 'ArrowRight') {
|
|
this.nextSlide();
|
|
}
|
|
}
|
|
};
|
|
|
|
document.addEventListener('keydown', keyHandler);
|
|
}
|
|
|
|
isElementInViewport(el) {
|
|
const rect = el.getBoundingClientRect();
|
|
return (
|
|
rect.top >= 0 &&
|
|
rect.left >= 0 &&
|
|
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
|
|
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
|
|
);
|
|
}
|
|
}
|
|
|
|
// Initialize the slider immediately
|
|
new Slide1rSlider();
|
|
})();
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html> |