You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
1.9 KiB
HTML

5 years ago
<!DOCTYPE html>
<html>
<head>
<title>CLICKBAIT GENERATOR</title>
<meta charset="utf-8">
<style type="text/css">
* {
font-family: sans-serif;
font-size: calc(1vw + 3vh);
}
#wrapper {
display: flex;
flex-direction: column;
position: absolute;
left: 5%; top: 5%; right: 5%; bottom: 5%;
}
#textinput {
width: 100%;
border: none;
background: none;
}
#input {
padding: 2%;
flex: 0 1 auto;
background: red;
}
#display {
flex: 1 1 auto;
background: lightgrey;
padding: 2%;
overflow: auto;
}
#display div.msg {
padding-bottom: 0.5em;
color: grey;
}
#display div.human {
color: black;
}
#display div.bot {
color: black;
text-transform: uppercase;
}
#display div.debug {
color: red;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="display">
</div>
<div id="input">
<input type="text" id="textinput" autofocus />
</div>
</div>
<script src="eliza.js"></script>
<script>
function eliza (rules) {
var input = document.getElementById("textinput"),
output = document.getElementById("display"),
bot = chatbot(rules, true);
function log (msg, kls) {
var d = document.createElement("div");
d.setAttribute("class", "msg " + kls);
d.innerHTML = msg;
display.appendChild(d);
}
function say (msg) {
log(msg, "bot");
display.scrollTop = display.scrollTopMax;
}
input.addEventListener("keypress", function (event) {
if (event.keyCode == 13) {
var text = input.value;
log(text, "user");
say(bot(text), "bot");
input.value = "";
input.focus();
}
});
say(rules.initial);
}
</script>
<script src="doctor.js"></script>
</body>
</html>