topical media & game development

talk show tell print

sample-js-eliza-bot-term.htm / htm



  <HTML>
  <HEAD>
          <TITLE>Eliza</TITLE>
          <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="lib-present-script-elizabot-termlib.js"></SCRIPT>
          <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="lib-present-script-elizabot-elizabot.js"></SCRIPT>
          <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="lib-present-script-elizabot-elizadata.js"></SCRIPT>
  
  <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
  <!--
  
  var conf= {
          x:0,
          y:0,
          id: 1,
          termDiv:'elizaDiv',
          frameColor: '#77777a',
          ps: 'YOU:  ',
          historyUnique: true,
          initHandler: initHandler,
          exitHandler: termExit,
          handler: termHandler
  }
  
  var term = new Terminal(conf);
  var eliza = new ElizaBot();
  
  function termOpen() {
          TermGlobals.keylock=false;
          if (term.closed) eliza.reset();
          term.open();
          setTermLink(false);
  }
  
  function setTermLink(v) {
          var linkobj;
          if (document.getElementById) {
                  linkobj=document.getElementById('termOpenLink');
          }
          else if (document.all) {
                  linkobj=document.all.termOpenLink;
          }
          else {
                  linkobj=document.links.termOpenLink;
          }
          if (linkobj) linkobj.className = (v)? 'termopen': 'termopenhidden';
  }
  
  function initHandler() {
          this.write( [
                  '  Welcome to',
                  '                    EEEEEE  LL      IIII  ZZZZZZZ   AAAAA ',
                  '                    EE      LL       II       ZZ   AA   AA',
                  '                    EEEEE   LL       II     ZZZ    AAAAAAA',
                  '                    EE      LL       II    ZZ      AA   AA',
                  '                    EEEEEE  LLLLLL  IIII  ZZZZZZZ  AA   AA',
                  ' ',
                  '  Eliza is a mock Rogerian psychotherapist.',
                  '  The original program was described by Joseph Weizenbaum in 1966.',
                  '  This implementation by Norbert Landsteiner 2005.',
                  '\%n\%n'
                  ]);
          this.type('ELIZA: '+elizaInitials[Math.floor(Math.random()*elizaInitials.length)]);
          this.prompt();
  }
  
  function termHandler() {
          var line=this.lineBuffer;
          // no action on empty line
          if (line.search(/^\s*/)==0) {
                  this.prompt();
                  return;
          }
          // transform
          this.write('\%nELIZA: '+eliza.transform(line));
          if (eliza.quit) {
                  setTimeout('term.close()',2500);
                  return;
          }
          this.prompt();
  }
  
  function termExit() {
          TermGlobals.keylock=true;
          setTermLink(true);
  }
  
  //-->
  </SCRIPT>
  
  <STYLE TYPE="text/css">
  body,p,a,td {
          font-family: courier,fixed;
          font-size: 12px;
          color: #ffffff;
  }
  a,a:link,a:visited {
          text-decoration: none;
          color: #77dd11;
  }
  a:hover {
          text-decoration: underline;
          color: #77dd11;
  }
  a:active {
          text-decoration: underline;
          color: #dddddd;
  }
  
  .term {
          font-family: courier,fixed;
          font-size: 12px;
          color: #aaccaa;
          background: none;
  }
  
  .termReverse {
          font-family: courier,fixed;
          font-size: 12px;
          color: #111111;
          background: #aaccaa;
  }
  
  grey,.grey {
          font-family: courier,fixed;
          font-size: 12px;
          color: #999999;
  }
  
  a.termopen,a.termopen:link,a.termopen:visited {
          text-decoration: none;
          color: #77dd11;
          background: none;
  }
  a.termopen:hover {
          text-decoration: none;
          color: #222222;
          background: #77dd11;
  }
  a.termopen:active {
          text-decoration: none;
          color: #222222;
          background: #dddddd;
  }
  
  a.termopenhidden,a.termopenhidden:link,a.termopenhidden:visited {
          text-decoration: none;
          color: #253850;
          background: none;
  }
  a.termopenhidden:hover {
          text-decoration: none;
          color: #222222;
          background: #77dd11;
  }
  a.termopenhidden:active {
          text-decoration: none;
          color: #222222;
          background: #dddddd;
  }
  h1 {
          font-family: courier,fixed,swiss,sans-serif;
          font-size: 18px;
          color: #ffffff;
  }
  .lh13 {
          line-height: 13px;
  }
  .lh15 {
          line-height: 15px;
  }
  
  </STYLE>
  </HEAD>
  
  <BODY BGCOLOR="#253850" LINK="#77dd11" TEXT="#33d011" ALINK="#dddddd" VLINK="#77dd11"
  TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">
  
  <TABLE BORDER="0" CELLSPACING="10" CELLPADDING="0" WIDTH="100%">
  <TR><TD ALIGN="center"> <H2>eliza terminal</H2> </TD>
  </TD></TR>
  <TR><TD ALIGN="center">
          <A HREF="javascript:termOpen()" onfocus="if(this.blur)this.blur();" onmouseover="window.status='open terminal'; return true" onmouseout="window.status=''; return true" CLASS="termopen" ID="termOpenLink">&gt; open ELIZA terminal&nbsp;</A>
  
  </TD></TR>
  <TR><TD ALIGN="center" VALIGN="top" HEIGHT="370">
          <DIV ID="elizaDiv" STYLE="position:relative;"></DIV>
  </TD></TR>
  <TR><TD ALIGN="center">
          <TABLE BORDER="0" CELLSPACING="10" CELLPADDING="0" WIDTH="600">
          <TR><TD CLASS="lh13" COLSPAN="2">
                  This page is a sample for <A HREF="http://www.masswerk.at/termlib/">mass:werk termlib.js</A> and the ELIZA library <A HREF="http://www.masswerk.at/elizabot/">elizabot.js</A>.<BR><BR>
  
                  For a chat with two Eliza therapists see the <A HREF="eliza_chat.html">ELIZA-Chat</A>.<BR><BR>
  
                  ELIZA is a natural language conversation program described by Joseph Weizenbaum in January 1966 <A HREF="#ELIZA">[1]</A>.
                  It features the dialog between a human user and a computer program representing a mock Rogerian psychotherapist.
  
          </TD></TR>
          <TR><TD COLSPAN="2">&nbsp;</TD></TR>
          <TR><TD COLSPAN="2">Compatibility:</TD></TR>
  
          <TR><TD COLSPAN="2">
                  This page uses JavaScript and DHTML and should be compatible with most standard web browsers.<BR>
                  Please note that khtml (Konqueror) currently does not handle any keyboard events.
          </TD></TR>
          <TR><TD COLSPAN="2">&nbsp;</TD></TR>
          <TR><TD COLSPAN="2">References:</TD></TR>
          <TR VALIGN="top">
          <TD><A NAME="ELIZA"></A>[1]</TD>
  
          <TD>
                  Weizenbaum, Joseph &quot;ELIZA &#150; A Computer Program For the Study of Natural Language
                  Communication Between Man and Machine&quot;<BR>
                  in: Communications of the ACM; Volume 9 , Issue 1 (January 1966): p 36-45.
          </TD>
          </TR>
          <TR><TD COLSPAN="2">&nbsp;</TD></TR>
          <TR><TD COLSPAN="2">&copy; Norbert Landsteiner 2005; &lt;<A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at>&gt;</TD></TR>
  
          <TR><TD COLSPAN="2">&nbsp;</TD></TR>
          </TABLE>
  </TABLE>
  
  </BODY>
  </HTML>
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.