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

Add a pop up dialog box for Polls/Survey done ! #1765 🌟🌟🌟 #1766

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
171 changes: 170 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3244,6 +3244,175 @@ <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 */
}

poll
.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>
main
</html>
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,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