Skip to content

Commit

Permalink
Merge pull request Its-Aman-Yadav#1333 from TBorundia/main
Browse files Browse the repository at this point in the history
Added Cookie pop-up
  • Loading branch information
Its-Aman-Yadav authored Aug 4, 2024
2 parents 8143e9f + 88d9e2e commit b6dc0d0
Showing 1 changed file with 165 additions and 0 deletions.
165 changes: 165 additions & 0 deletions about us.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,87 @@
transform: rotate(-90deg);
transform-origin: 50% 50%;
}

/* cookie-consent */
#cookie-consent {
position: fixed;
bottom: 8px;
background-color: #fefab1;
padding: 20px;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
width: 300px;
height: fit-content;
z-index: 10000;
border-radius: 10px;
margin-bottom: 5px;
margin: 20px;
border-right: 4px solid transparent;
border-bottom: 4px solid transparent;
transition: border-color 0.3s;
border: 1px solid rgb(249, 62, 4);
border-bottom: #f33404;
}

#cookie-consent:hover {
border-right:6px solid #fe1f02;
border-bottom:6px solid #f40a02;
}

#cookie-consent p {
color: black; /* Make the text black for better visibility */
text-align: center; /* Center align the text */
}

.accept-cookies,
.reject-cookies {
width: 260px; /* Decrease the button width */
height: 35px; /* Decrease the button height */
color: white;
background-color: #fd1706;
border: none;
border-radius: 5px; /* Add rounded corners */
cursor: pointer;
transition: transform 0.3s, box-shadow 0.3s, background-color 0.3s, color 0.3s; /* Smooth transition for effects */
}

.reject-cookies {
margin-top: 10px;
}

.accept-cookies:hover,
.reject-cookies:hover {
transform: scale(0.95);
box-shadow: 0 0 15px rgba(241, 165, 65, 0.6); /* Reduce the shadow size */
}

.accept-cookies:hover {
background-color: rgb(250, 206, 7);
color: #0d0b0b;
border: 1px solid rgb(251, 18, 2);
}

.reject-cookies:hover {
background-color: rgb(250, 206, 7);
color: #0d0b0b;
border: 1px solid rgb(251, 18, 2);
}

#learn-more-link,
#show-less-link {
color: #f90814;
text-decoration: none;
cursor: pointer;
font-size: 16px;
}

#cookie-content {
display: none;
margin-top: 10px;
}

</style>
</head>

Expand Down Expand Up @@ -168,6 +249,90 @@
});
</script>


<div id="cookie-consent">
<p>
We use cookies to enhance your experience on our website. By continuing to browse, you agree to our use of cookies as described in our Cookie Policy.
<a href="#" id="learn-more-link">Learn More</a>

</p>
<div id="learn-more-content" style="display: none;">
<p>Cookies are small text files used by websites to enhance user experience. According to the law, we can store cookies on your device if they are essential for the operation of this site. For other types of cookies, we need your consent.</p>
<p>This site employs various types of cookies. Some cookies are set by third-party services that appear on our pages.</p>
</div>

<a href="#" id="show-less-link" style="display: none;">Show Less</a>
<button class="accept-cookies">Accept</button>
<button class="reject-cookies">Reject</button>
</div>


<script>



document.addEventListener('DOMContentLoaded', function() {
const cookieConsent = document.getElementById('cookie-consent');
const acceptButton = document.querySelector('.accept-cookies');
const rejectButton = document.querySelector('.reject-cookies');
const learnMoreLink = document.getElementById('learn-more-link');
const learnMoreContent = document.getElementById('learn-more-content');

// Hide preloader after page load
window.addEventListener('load', function() {
const preloader = document.getElementById('preloader');
if (preloader) {
preloader.style.display = 'none';
}
cookieConsent.style.display = 'block';
});

// Check if localStorage is available
function localStorageAvailable() {
try {
const test = '__localStorage_test__';
localStorage.setItem(test, test);
localStorage.removeItem(test);
return true;
} catch (e) {
return false;
}
}

if (localStorageAvailable()) {
// Check if the user has already made a choice
if (localStorage.getItem('cookieConsent')) {
cookieConsent.style.display = 'none';
}

// Function to handle cookie consent choice
function handleConsent(choice) {
localStorage.setItem('cookieConsent', choice);
cookieConsent.style.display = 'none';
}

// Add event listeners to buttons
acceptButton.addEventListener('click', function() {
handleConsent('accepted');
});

rejectButton.addEventListener('click', function() {
handleConsent('rejected');
});
} else {
// Hide consent if localStorage is not available
cookieConsent.style.display = 'none';
}

// Add event listener to "Learn More" link
learnMoreLink.addEventListener('click', function(event) {
event.preventDefault();
learnMoreContent.style.display = 'block';
learnMoreLink.style.display = 'none';
});
});
</script>

<!-- Navbar -->
<div class="navbar">
<nav>
Expand Down

0 comments on commit b6dc0d0

Please sign in to comment.