Oppa: eliza

Beitrag lesen

so hier gehts weiter:

if (words.length > 2) {
    if (words[2].toUpperCase() == 'ES')
      if (words[1].toUpperCase() == 'GEHT') {
        s = words[2]
        words[2] = words[0]
        words[0] = s
      }
  }

if (words[0].toUpperCase().search(Possesiv) != -1) {
    words[1] = words[0] + ' ' + words[1]
    words.shift()
  }

MakeAnAnswer = 0
  if (Math.floor(Math.random() * 2) == 0)
    MakeAnAnswer = 1

if (MakeAnAnswer == 0)
    s = ComplexAnswerQ[Math.floor(Math.random() * ComplexAnswerQ.length)] + ' ' +
        words[0] + ' '
  else
    s = ComplexAnswerA[Math.floor(Math.random() * ComplexAnswerA.length)] + ' ' +
        words[0] + ' '

for(i = 2; i <= words.length-1; i++)
    {
      s = s + words[i] + ' '
    }

if (MakeAnAnswer == 0)
    s = s + words[1] + '?'
  else
    s = s + words[1] + '!'

Eliza(s)
}

// GetLines() liefert die angezeigte (!) Zeilenanzahl im Textfeld

function GetLines()
{
  temp = window.document.Eliza.elizachat.value + '\n'
  linescount = 0
  while (temp.search(/\n/) != -1)
  {
    linescount = linescount + Math.floor(temp.search(/\n/) / 70)
    temp = temp.slice(temp.search(/\n/)+1)
    linescount = linescount + 1
  }
  return (linescount)
}

// Gibt eine Eingabe des Patienten aus und lässt Eliza antworten

function Patient(SayWhat)
{

Say('Du',SayWhat)
  Answer(SayWhat)
}

// Löscht die oberste virtuelle (!) Zeile

function DeleteTopLine()
{
  FirstBreakPos = window.document.Eliza.elizachat.value.search(/\n/);
  window.document.Eliza.elizachat.value =
  window.document.Eliza.elizachat.value.slice(FirstBreakPos+1)
}

// Gibt Standartmeldung aus (da erste Zeile kann Say nicht verwendet werden)

function SayHello()
{
  window.document.Eliza.elizachat.value = 'Eliza: '+
  Greetings[Math.floor(Math.random() * Greetings.length)];
}

// Lässt Eliza etwas sagen

function Eliza(SayWhat)
{
  Say('Eliza',SayWhat)
}

//-->

</script>

</head>

<body text="#000000" bgcolor="#FFFFFF" link="#FF0000" alink="#FF0000" vlink="#FF0000"
background="back.jpg">

<center>

<form name="Eliza" action="" method=post>

<br>

<textarea name="elizachat" cols="70" rows="20" wrap=physical></textarea><br>

<br>

<input type="Text" name="talkedit" size=60 maxlength=-1
  onKeyPress="if (event.which == 13) Patient(window.document.Eliza.talkedit.value)">

<input type="Button" name="" value="Sagen" width="90"
  onClick="Patient(window.document.Eliza.talkedit.value)">
</form>

</center>

</body>
</html>

dann mal fröhliche unterhaltung :-)