<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<!DOCTYPE html>
<html>
	<head>
		<title>Botiverse</title>
		<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
		<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
		<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css')}}"/>
		<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.png') }}">
	</head>
	
	
	<body>
		<div style="text-align:center">
		<img src="{{url_for('static', filename='logo.png')}}" alt="ChatBot" style="width:600px; margin-top: 50px; margin-bottom: 0px;">
		</div>
		<div class="container-fluid h-100">
			<div class="row justify-content-center h-100">		
				<div class="col-md-8 col-xl-6 chat">
					<div class="card">
						<div class="card-header msg_head">
							<div class="d-flex bd-highlight">
								<div class="img_cont">
									<img src="{{url_for('static', filename='icons/'+bot+'.png')}}" alt="ChatBot" class="rounded-circle user_img">
									<span class="online_icon"></span>
								</div>
								<div class="user_info">
									<span>{{bot}}</span>
									<p>Ask me anything!</p>
								</div>
							</div>
						</div>
						<div id="messageFormeight" class="card-body msg_card_body">
							
							
						</div>
						<div class="card-footer">
							<form id="messageArea" class="input-group">
                                <input type="text" id="text" name="msg" placeholder="Type your question..." autocomplete="off" class="form-control type_msg" required/>
								<div class="input-group-append">
									<button type="submit" id="send" class="input-group-text send_btn"><i class="fas fa-location-arrow"></i></button>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
		
		<script>
			$(document).ready(function() {
				$("#messageArea").on("submit", function(event) {
					const date = new Date();
					const hour = date.getHours();
					const minute = date.getMinutes();
					const str_time = hour+":"+minute;
					var rawText = $("#text").val();

					var userHtml = '<div class="d-flex justify-content-end mb-4"><div class="msg_cotainer_send">' + rawText + '<span class="msg_time_send">'+ str_time + '</span></div><div class="img_cont_msg"><img src="https://i.ibb.co/d5b84Xw/Untitled-design.png" class="rounded-circle user_img_msg"></div></div>';
					
					$("#text").val("");
					$("#messageFormeight").append(userHtml);

					$.ajax({
						data: {
							msg: rawText,	
						},
						type: "POST",
						url: "/get",
					}).done(function(data) {
						var botHtml = '<div class="d-flex justify-content-start mb-4"><div class="img_cont_msg"><img src="{{url_for('static', filename='icons/'+bot+'.png')}}" class="rounded-circle user_img_msg"></div><div class="msg_cotainer">' + data + '<span class="msg_time">' + str_time + '</span></div></div>';
						$("#messageFormeight").append($.parseHTML(botHtml));
						$("#messageFormeight").animate({ scrollTop: $("#messageFormeight")[0].scrollHeight }, "slow");
					});
					

					event.preventDefault();
				});
			});
		</script>
    </body>
</html>