init
This commit is contained in:
31
js/chatbot.js
Normal file
31
js/chatbot.js
Normal file
@@ -0,0 +1,31 @@
|
||||
function sendMessage() {
|
||||
const userInput = document.getElementById('user-input').value;
|
||||
const chatOutput = document.getElementById('chat-output');
|
||||
|
||||
if (userInput.trim() === "") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Display user message
|
||||
chatOutput.innerHTML += `<div><strong>You:</strong> ${userInput}</div>`;
|
||||
|
||||
// Simulate chatbot response (use REST API call here for real chatbot)
|
||||
fetch('https://your-chatbot-api.com/message', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ message: userInput })
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
chatOutput.innerHTML += `<div><strong>Chatbot:</strong> ${data.reply}</div>`;
|
||||
chatOutput.scrollTop = chatOutput.scrollHeight; // Auto-scroll
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
chatOutput.innerHTML += `<div><strong>Chatbot:</strong> Sorry, something went wrong.</div>`;
|
||||
});
|
||||
|
||||
document.getElementById('user-input').value = ''; // Clear input field
|
||||
}
|
||||
|
||||
|
46
js/main.js
Normal file
46
js/main.js
Normal file
@@ -0,0 +1,46 @@
|
||||
(function ($) {
|
||||
"use strict";
|
||||
|
||||
// Dropdown on mouse hover
|
||||
$(document).ready(function () {
|
||||
function toggleNavbarMethod() {
|
||||
if ($(window).width() > 992) {
|
||||
$('.navbar .dropdown').on('mouseover', function () {
|
||||
$('.dropdown-toggle', this).trigger('click');
|
||||
}).on('mouseout', function () {
|
||||
$('.dropdown-toggle', this).trigger('click').blur();
|
||||
});
|
||||
} else {
|
||||
$('.navbar .dropdown').off('mouseover').off('mouseout');
|
||||
}
|
||||
}
|
||||
toggleNavbarMethod();
|
||||
$(window).resize(toggleNavbarMethod);
|
||||
});
|
||||
|
||||
|
||||
// Back to top button
|
||||
$(window).scroll(function () {
|
||||
if ($(this).scrollTop() > 100) {
|
||||
$('.back-to-top').fadeIn('slow');
|
||||
} else {
|
||||
$('.back-to-top').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
$('.back-to-top').click(function () {
|
||||
$('html, body').animate({scrollTop: 0}, 1500, 'easeInOutExpo');
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
// Testimonials carousel
|
||||
$(".testimonial-carousel").owlCarousel({
|
||||
autoplay: true,
|
||||
smartSpeed: 1500,
|
||||
dots: true,
|
||||
loop: true,
|
||||
items: 1
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
Reference in New Issue
Block a user