Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Star Rating is added #1411

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion new-website/feedback.css
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,30 @@ body.dark #form-messages .alert-danger {
background-color: #333; /* Darker background color for messages */
color: #fff; /* Light text color for messages */
border-color: #333; /* Darker border color for messages */
}
}




/*star rating*/
.star-rating {
direction: ltr; /* Optional: this can change star direction */
}

.star-rating ul {
list-style-type: none;
padding: 0;
display: inline-block;
}

.star-rating .star {
display: inline-block;
font-size: 2em;
color: lightgrey;
cursor: pointer;
}

.star-rating .star.selected,
.star-rating .star.hover {
color: gold;
}
64 changes: 63 additions & 1 deletion new-website/feedback.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<title>ResourceHub</title>
</head>
<body>

<div class="col-md-10">
<a href="index.html" class="home-link"><i class="fas fa-arrow-left"> </i></a>
</div>
Expand All @@ -35,7 +36,18 @@
<div class="col-lg-7 mb-5 mb-lg-0">
<h2 class="mb-5">Fill this feedback form</h2><h3>Reach out to us.</h3>
<form action="" class="border-right pr-5 mb-5" method="post" id="contactForm" name="contactForm">
<!-- replace email id accordingly -->
<!--Star rating-->
<div class="star-rating">
<ul>
<li class="star" data-value="1">&#9733;</li>
<li class="star" data-value="2">&#9733;</li>
<li class="star" data-value="3">&#9733;</li>
<li class="star" data-value="4">&#9733;</li>
<li class="star" data-value="5">&#9733;</li>
</ul>
</div>

<!--Replace email accordingly-->
<div class="row">
<div class="col-md-6 form-group">
<input type="text" class="form-control" name="fname" id="fname" placeholder="First name">
Expand Down Expand Up @@ -81,7 +93,57 @@ <h3 class="mb-4">We value your feedback</h3>
<script src="cursorAnimation.js"></script>
<script src="scripts.js"></script>
<script src="home.js"></script>
<script>

document.addEventListener('DOMContentLoaded', () => {
const stars = document.querySelectorAll('.star-rating .star');

console.log('Stars:', stars); // Debugging

if (stars.length === 0) {
console.error('No stars found!'); // Debugging
return;
}

stars.forEach(star => {
star.addEventListener('mouseover', handleMouseOver);
star.addEventListener('mouseout', handleMouseOut);
star.addEventListener('click', handleClick);
});

function handleMouseOver(event) {
console.log('Mouse Over:', event.target); // Debugging
const value = event.target.dataset.value;
highlightStars(value);
}

function handleMouseOut() {
console.log('Mouse Out'); // Debugging
highlightStars(0);
}

function handleClick(event) {
console.log('Click:', event.target); // Debugging
const value = event.target.dataset.value;
setRating(value);
}

function highlightStars(value) {
stars.forEach(star => {
star.classList.toggle('hover', star.dataset.value <= value);
});
}

function setRating(value) {
stars.forEach(star => {
star.classList.toggle('selected', star.dataset.value <= value);
});
}
});



</script>

</body>
</html>
3 changes: 2 additions & 1 deletion new-website/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ function toggleDarkMode() {

particlesJS.load('particles-js', './assets/homeparticles.json', function () {
console.log('callback - particles.js config loaded');
});
});