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.

107 lines
2.8 KiB
HTML

5 years ago
<HTML>
<HEAD>
<meta charset="utf-8">
<TITLE>Eliza (elizabot.js)</TITLE>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="elizabot.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="elizadata.js"></SCRIPT>
<link rel="stylesheet" type="text/css" href="./clippy.js/build/clippy.css" media="all">
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
var eliza = new ElizaBot();
var elizaLines = new Array();
var displayCols = 60;
var displayRows = 20;
function elizaReset() {
eliza.reset();
elizaLines.length = 0;
elizaStep();
}
function elizaStep() {
var f = document.forms.e_form;
var userinput = f.e_input.value;
if (eliza.quit) {
f.e_input.value = '';
if (confirm("This session is over.\nStart over?")) elizaReset();
f.e_input.focus();
return;
}
else if (userinput != '') {
var usr = 'YOU: ' + userinput;
var rpl ='ELIZA: ' + eliza.transform(userinput);
elizaLines.push(usr);
elizaLines.push(rpl);
// display nicely
// (fit to textarea with last line free - reserved for extra line caused by word wrap)
var temp = new Array();
var l = 0;
for (var i=elizaLines.length-1; i>=0; i--) {
l += 1 + Math.floor(elizaLines[i].length/displayCols);
if (l >= displayRows) break
else temp.push(elizaLines[i]);
}
elizaLines = temp.reverse();
f.e_display.value = elizaLines.join('\n');
}
else if (elizaLines.length == 0) {
// no input and no saved lines -> output initial
var initial = 'ELIZA: ' + eliza.getInitial();
elizaLines.push(initial);
f.e_display.value = initial + '\n';
}
f.e_input.value = '';
f.e_input.focus();
}
//-->
</SCRIPT>
</HEAD>
<BODY TOPMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" BOTTOMMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0" STYLE="border:0" onload="window.setTimeout('elizaReset()',100)"><A NAME="top"></A>
<CENTER>
<P>&nbsp;</P>
<H3>Eliza</H3>
<TABLE BORDER="0" CELLSPACING="10" CELLPADDING="0">
<FORM NAME="e_form" onsubmit="elizaStep();return false">
<TR><TD COLSPAN="2"><TEXTAREA NAME="e_display" COLS="60" ROWS="20"></TEXTAREA></TD></TR>
<TR VALIGN="middle">
<TD><INPUT TYPE="text" NAME="e_input" SIZE="50"></TD>
<TD ALIGN="right"><INPUT TYPE="submit" VALUE="&nbsp;Talk&nbsp;"> <INPUT TYPE="reset" VALUE="Reset" onClick="window.setTimeout('elizaReset()',100)"></TD>
</TR>
</FORM>
<script src="./jquery.1.7.min.js"></script>
<script src="./clippy.js/build/clippy.js"></script>
<script type="text/javascript">
clippy.load('Clippy', function(agent){
agent.show();
//agent.play('Searching');
//agent.animate();
//agent.animations();
//agent.moveTo();
//agent.play();
agent.speak('Heeeeeeeeey!');
agent.animate();
agent.speak('Im Clippy!');
//agent.gestureAt(200,200);
//agent.stopCurrent();
//agent.stop();
});
</script>
</BODY>
</HTML>