98 lines
3.2 KiB
PHP
98 lines
3.2 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Chat with Gemini</title>
|
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
|
<style>
|
|
.chat-container {
|
|
max-width: 800px;
|
|
margin: 50px auto;
|
|
border: 1px solid #ddd;
|
|
border-radius: 10px;
|
|
overflow: hidden;
|
|
}
|
|
.chat-header {
|
|
background-color: #f8f9fa;
|
|
padding: 15px;
|
|
border-bottom: 1px solid #ddd;
|
|
font-size: 1.2rem;
|
|
font-weight: bold;
|
|
}
|
|
.chat-box {
|
|
height: 400px;
|
|
overflow-y: auto;
|
|
padding: 15px;
|
|
}
|
|
.chat-input {
|
|
padding: 15px;
|
|
border-top: 1px solid #ddd;
|
|
}
|
|
.message {
|
|
margin-bottom: 15px;
|
|
}
|
|
.user-message {
|
|
text-align: right;
|
|
}
|
|
.bot-message .card-body {
|
|
background-color: #f1f1f1;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<?php include 'navbar.php'; ?>
|
|
<div class="container">
|
|
<div class="chat-container">
|
|
<div class="chat-header">
|
|
Chat with Gemini
|
|
</div>
|
|
<div class="chat-box" id="chat-box">
|
|
<!-- Messages will be appended here -->
|
|
</div>
|
|
<div class="chat-input">
|
|
<form id="chat-form">
|
|
<div class="input-group">
|
|
<input type="text" id="user-input" class="form-control" placeholder="Ask me about the app...">
|
|
<div class="input-group-append">
|
|
<button class="btn btn-primary" type="submit">Send</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
$("#chat-form").submit(function(e) {
|
|
e.preventDefault();
|
|
var userInput = $("#user-input").val();
|
|
if (userInput.trim() === "") {
|
|
return;
|
|
}
|
|
|
|
// Display user message
|
|
$("#chat-box").append('<div class="message user-message"><div class="card d-inline-block"><div class="card-body">' + userInput + '</div></div></div>');
|
|
$("#user-input").val("");
|
|
$("#chat-box").scrollTop($("#chat-box")[0].scrollHeight);
|
|
|
|
|
|
// Send user input to the bot
|
|
$.ajax({
|
|
url: "chat_logic.php",
|
|
type: "POST",
|
|
data: { message: userInput },
|
|
success: function(response) {
|
|
// Display bot response
|
|
$("#chat-box").append('<div class="message bot-message"><div class="card d-inline-block"><div class="card-body">' + response + '</div></div></div>');
|
|
$("#chat-box").scrollTop($("#chat-box")[0].scrollHeight);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|