Created
November 29, 2020 23:45
-
-
Save HeenaR17/84cf6d26fd0d06809ac72ba581622e53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Pizza Predicter</title> | |
<link | |
rel="shortcut icon" | |
type="image/x-icon" | |
href="../static/pizza.png" | |
/> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
<style> | |
body { | |
font-family: monospace; | |
} | |
h1 { | |
background-color: blue; | |
display: inline-block; | |
color: white; | |
font-style: italic; | |
font-size: 3em; | |
margin: 0; | |
padding: 14px; | |
position: sticky ; | |
} | |
h3 { | |
color: black; | |
font-size: 20px; | |
margin-top: 3px; | |
text-align: center; | |
} | |
#chatbox { | |
margin-left: auto; | |
margin-right: auto; | |
width: 80%; | |
margin-top: 60px; | |
} | |
#userInput { | |
margin-left: auto; | |
margin-right: auto; | |
width: 40%; | |
margin-top: 60px; | |
} | |
#textInput { | |
width: 90%; | |
border: none; | |
border-bottom: 3px solid black; | |
font-family: monospace; | |
font-size: 17px; | |
} | |
.userText { | |
color: white; | |
font-family: monospace; | |
font-size: 17px; | |
text-align: right; | |
line-height: 30px; | |
} | |
.userText span { | |
background-color: #808080; | |
padding: 10px; | |
border-radius: 2px; | |
} | |
.botText { | |
color: white; | |
font-family: monospace; | |
font-size: 17px; | |
text-align: left; | |
line-height: 30px; | |
} | |
.botText span { | |
background-color: #4169e1; | |
padding: 10px; | |
border-radius: 2px; | |
} | |
#tidbit { | |
position: absolute; | |
bottom: 0; | |
right: 0; | |
width: 300px; | |
} | |
.boxed { | |
margin-left: auto; | |
margin-right: auto; | |
width: 60%; | |
margin-top: 40px; | |
border: 1px solid green; | |
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2); | |
padding-bottom: 20px; | |
} | |
.box { | |
border: 2px solid black; | |
width: 80%; | |
} | |
</style> | |
</head> | |
<body> | |
<center> | |
<h1> | |
<img | |
src= "../static/pizza.png" | |
style="width:40px;height:40px; margin:10px" | |
/>Your Pizza Predictor | |
</h1> | |
<div class="box"></div> | |
</center> | |
<div class="boxed"> | |
<div> | |
<div id="chatbox"> | |
<p class="botText"> | |
<span>Hi! I'm Pizza Predicter Bot, please enter ingredients to predict pizza name</span> | |
</p> | |
</div> | |
<div id="userInput"> | |
<input id="textInput" type="text" name="msg" placeholder="Message" /> | |
</div> | |
</div> | |
</div> | |
<script> | |
function getBotResponse() { | |
var rawText = $("#textInput").val(); | |
var userHtml = '<p class="userText"><span>' + rawText + "</span></p>"; | |
$("#textInput").val(""); | |
$("#chatbox").append(userHtml); | |
document | |
.getElementById("userInput") | |
.scrollIntoView({ block: "start", behavior: "smooth" }); | |
$.get("/get", { msg: rawText }).done(function(data) { | |
var botHtml = '<p class="botText"><span>' + data + "</span></p>"; | |
$("#chatbox").append(botHtml); | |
document | |
.getElementById("userInput") | |
.scrollIntoView({ block: "start", behavior: "smooth" }); | |
}); | |
} | |
$("#textInput").keypress(function(e) { | |
if (e.which == 13) { | |
getBotResponse(); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment