document.getElementById('send-btn').addEventListener('click', function() {
const userInput = document.getElementById('user-input').value.trim();
appendMessage('user', userInput);
// Send user input to GPT-3 API
fetch('/your-gpt3-api-endpoint', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ text: userInput })
})
.then(response => response.json())
.then(data => {
const botResponse = data.response; // Assuming API returns { response: "bot's response" }
appendMessage('bot', botResponse);
})
.catch(error => {
console.error('Error:', error);
appendMessage('bot', "I'm sorry, there was an error processing your request.");
});
// Clear input field after sending message
document.getElementById('user-input').value = '';
});
function appendMessage(sender, message) {
const chatMessages = document.getElementById('chat-messages');
const messageElement = document.createElement('div');
messageElement.classList.add('message', sender);
messageElement.innerText = message;
chatMessages.appendChild(messageElement);
}
document.addEventListener("DOMContentLoaded", function () {
const addonOptions = document.querySelectorAll(".addon-option");
addonOptions.forEach(option => {
option.addEventListener("click", function () {
option.classList.toggle("selected");
const checkbox = option.querySelector("input");
checkbox.checked = !checkbox.checked;
});
});
});
document.addEventListener('DOMContentLoaded', function() {
const serviceTypeSelect = document.getElementById('service-type');
const bedroomsSelect = document.getElementById('bedrooms');
const bathroomsSelect = document.getElementById('bathrooms');
const addonsCheckboxes = document.querySelectorAll('input[name="addons"]');
const scheduleCheckboxes = document.querySelectorAll('input[name="schedule-frequency"]');
const priceDisplay = document.getElementById('price-display');
// Base price and additional costs
let basePrice = 100; // Example base price
function updatePrice() {
let totalPrice = basePrice;
// Adjust price based on service type
if (serviceTypeSelect.value === 'one-bedroom-condo') {
totalPrice += 50; // Example additional cost for one-bedroom condo
} else if (serviceTypeSelect.value === 'two-bedroom-condo') {
totalPrice += 75; // Example additional cost for two-bedroom condo
}
// Add more cases for other service types as needed
// Adjust price based on bedrooms and bathrooms
totalPrice += parseInt(bedroomsSelect.value) * 20; // Example cost per bedroom
totalPrice += parseInt(bathroomsSelect.value) * 15; // Example cost per bathroom
// Adjust price based on selected addons
addonsCheckboxes.forEach(function(checkbox) {
if (checkbox.checked) {
// Example: Add specific cost for each selected addon
totalPrice += 10; // Example cost for each addon
}
});
// Adjust price based on scheduling frequency
scheduleCheckboxes.forEach(function(checkbox) {
if (checkbox.checked) {
// Example: Apply discount based on scheduling frequency
if (checkbox.value === 'weekly') {
totalPrice *= 0.7; // Example: 30% off for Weekly Cleanings
} else if (checkbox.value === 'biweekly') {
totalPrice *= 0.8; // Example: 20% off for Biweekly Cleanings
} else if (checkbox.value === 'monthly') {
totalPrice *= 0.88; // Example: 12% off for Monthly Cleanings
}
}
});
// Update the price display
priceDisplay.textContent = `$${totalPrice.toFixed(2)}`;
}
// Event listeners for input changes
serviceTypeSelect.addEventListener('change', updatePrice);
bedroomsSelect.addEventListener('change', updatePrice);
bathroomsSelect.addEventListener('change', updatePrice);
addonsCheckboxes.forEach(function(checkbox) {
checkbox.addEventListener('change', updatePrice);
});
scheduleCheckboxes.forEach(function(checkbox) {
checkbox.addEventListener('change', updatePrice);
});
// Apply discount button functionality (assuming you have a discount code validation function)
const applyDiscountButton = document.getElementById('apply-discount');
applyDiscountButton.addEventListener('click', function() {
// Example: Implement your discount code validation logic here
// You can adjust the totalPrice based on the discount code entered
// Example: totalPrice *= 0.9; // Apply a 10% discount
updatePrice(); // Update the displayed price after applying the discount
});
// Initial update of price on page load
updatePrice();
});