Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
Subhajit-2023-44 committed Oct 29, 2024
1 parent 3435771 commit d1f8028
Show file tree
Hide file tree
Showing 2 changed files with 170 additions and 3 deletions.
171 changes: 169 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3140,6 +3140,173 @@ <h2>Exclusive Deals and Offers!</h2>
<script src="visi.js"></script>
<script src="script.js"></script>

</body>
<style>
body {
font-family: Arial, sans-serif;
}

/* Polls Popup Styles */
.popups {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
background-color: rgba(0, 0, 0, 0.5); /* Black background with opacity */
justify-content: center; /* Center the popup */
align-items: center; /* Center the popup */
z-index: 1000; /* Sit on top */
}

.popups-content {
background: linear-gradient(#0c5769, #5ac8e4);
padding: 20px;
border-radius: 5px;
max-width: 400px;
text-align: center;
}

/* Set poll options to stack vertically */
#pollOptions {
display: flex;
flex-direction: column; /* Stack buttons vertically */
align-items: center; /* Center the buttons */
}

.poll-button,
.vote-button {
display: block; /* Change to block for full-width */
margin: 5px 0; /* Add vertical margin */
padding: 10px 15px;
border: none;
border-radius: 5px;
color: white;
cursor: pointer;
transition: background-color 0.3s;
width: 100%; /* Full width */
text-align: center;
font-size: 15px;
}

.poll-button {
background-color: rgba(16, 22, 26, .4); /* Green */
}

</html>
.poll-button:hover {
background-color: #095493; /* Darker green */
}

.poll-button.selected {
background-color: #095493; /* Blue for selected */
}

.vote-button {
background-color: #f44336; /* Red */
}

.vote-button:hover {
background-color: #d32f2f; /* Darker red */
}

.uppercase {
text-transform: uppercase;
font-size: 16px;
color: #000000;
}

#result {
margin-top: 10px; /* Space above result text */
word-wrap: break-word; /* Allow long text to wrap */
overflow: hidden; /* Prevent overflow */
max-height: 50px; /* Limit height */
color: #000000; /* Text color */
text-align: center; /* Center align the text */
font-size: 15px;
}
</style>
</head>
<body>

<!-- Poll Pop-up -->
<div class="popups" id="pollPopup">
<div class="popups-content">
<h2 class="uppercase">What is your main priority when choosing a hotel?</h2>
<div id="pollOptions">
<button class="poll-button" data-value="Price and discounts">Price and discounts</button>
<button class="poll-button" data-value="Location and accessibility">Location and accessibility</button>
<button class="poll-button" data-value="Amenities and services offered">Amenities and services offered</button>
<button class="poll-button" style="display: none;" data-value="Option4">Option4</button>
<button class="poll-button" style="display: none;" data-value="Option5">Option5</button>
</div>
<button id="voteButton" class="vote-button">Vote</button>
<p id="result"></p> <!-- Result display -->
</div>
</div>

<script>
// Check if the user has already voted in this session
const hasVoted = sessionStorage.getItem('hasVoted');

// Show the poll popup after a delay, only if the user hasn't voted
function checkAndDisplayPollPopup() {
if (!hasVoted) {
document.getElementById('pollPopup').style.display = 'flex'; // Show poll
}
}

// Set timeout for poll display
setTimeout(checkAndDisplayPollPopup, 10000);

// Manage user selections and votes
const pollButtons = document.querySelectorAll('.poll-button[data-value]');
let selectedValue = '';

// Handle clicks on poll buttons
pollButtons.forEach(button => {
button.addEventListener('click', function() {
pollButtons.forEach(btn => btn.classList.remove('selected')); // Clear previous selections
button.classList.add('selected'); // Highlight selected button
selectedValue = button.getAttribute('data-value'); // Store selected value
});
});

// Handle voting process
document.getElementById('voteButton').addEventListener('click', function() {
if (selectedValue) {
document.getElementById('result').innerHTML = `You voted for: ${selectedValue}<br>Thank you!`; // Show result
sessionStorage.setItem('hasVoted', 'true'); // Save voting status
setTimeout(() => {
document.getElementById('pollPopup').style.display = 'none'; // Hide poll
}, 2000);
} else {
alert("Please select an option!"); // Alert if no option is selected
}
});

// Function to manage button focus for accessibility
function handleFocus(event) {
event.target.style.border = '2px solid #0058ff'; // Optional highlight effect
}

// Attach focus event for accessibility improvement
pollButtons.forEach(button => {
button.addEventListener('focus', handleFocus);
});

// Function to remove focus style
function handleBlur(event) {
event.target.style.border = ''; // Remove highlight effect
}

// Attach blur event for accessibility improvement
pollButtons.forEach(button => {
button.addEventListener('blur', handleBlur);
});

// Log when the script has loaded
console.log("Poll script initialized and ready!");
</script>

</body>
</html>
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ textarea:focus {
background-color: rgba(18, 18, 18, 0.9); /* Dark background for section */
}
.dark-mode h2 {
color: #ffa500; /* Bright color for heading */
color: #000000; /* Bright color for heading */
}

/**** FOOTER ****/
Expand Down

0 comments on commit d1f8028

Please sign in to comment.