-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
76 lines (68 loc) · 2.16 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<HTML>
<HEAD>
<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>
<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> </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=" Talk "> <INPUT TYPE="reset" VALUE="Reset" onClick="window.setTimeout('elizaReset()',100)"></TD>
</TR>
</FORM>
</BODY>
</HTML>