Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removed references to global from eliza

  • Loading branch information...
commit 3ad20adf4e1cd5529bcd466dbd89ad5a08002afb 1 parent 182a87e
robarnold robarnold authored
Showing with 8 additions and 11 deletions.
  1. +8 −11 eliza.js
19 eliza.js
View
@@ -70,16 +70,14 @@ ElizaBot.prototype.reset = function() {
ElizaBot.prototype._dataParsed = false;
ElizaBot.prototype._init = function() {
- // install ref to global object
- var global=ElizaBot.prototype.global=self;
// parse data and convert it from canonical form to internal use
// prodoce synonym list
var synPatterns={};
- if ((global.elizaSynons) && (typeof elizaSynons == 'object')) {
+ if (typeof elizaSynons == 'object') {
for (var i in elizaSynons) synPatterns[i]='('+i+'|'+elizaSynons[i].join('|')+')';
}
// check for keywords or install empty structure to prevent any errors
- if ((!global.elizaKeywords) || (typeof elizaKeywords.length == 'undefined')) {
+ if (typeof elizaKeywords.length == 'undefined') {
elizaKeywords=[['###',0,[['###',[]]]]];
}
// 1st convert rules to regexps
@@ -155,7 +153,7 @@ ElizaBot.prototype._init = function() {
// and compose regexps and refs for pres and posts
ElizaBot.prototype.pres={};
ElizaBot.prototype.posts={};
- if ((global.elizaPres) && (elizaPres.length)) {
+ if (elizaPres.length) {
var a=new Array();
for (var i=0; i<elizaPres.length; i+=2) {
a.push(elizaPres[i]);
@@ -168,7 +166,7 @@ ElizaBot.prototype._init = function() {
ElizaBot.prototype.preExp = /####/;
ElizaBot.prototype.pres['####']='####';
}
- if ((global.elizaPosts) && (elizaPosts.length)) {
+ if (elizaPosts.length) {
var a=new Array();
for (var i=0; i<elizaPosts.length; i+=2) {
a.push(elizaPosts[i]);
@@ -182,7 +180,7 @@ ElizaBot.prototype._init = function() {
ElizaBot.prototype.posts['####']='####';
}
// check for elizaQuits and install default if missing
- if ((!global.elizaQuits) || (typeof elizaQuits.length == 'undefined')) {
+ if (typeof elizaQuits.length == 'undefined') {
elizaQuits=[];
}
// done
@@ -322,7 +320,7 @@ ElizaBot.prototype._postTransform = function(s) {
// final cleanings
s=s.replace(/\s{2,}/g, ' ');
s=s.replace(/\s+\./g, '.');
- if ((this.global.elizaPostTransforms) && (elizaPostTransforms.length)) {
+ if (elizaPostTransforms.length) {
for (var i=0; i<elizaPostTransforms.length; i+=2) {
s=s.replace(elizaPostTransforms[i], elizaPostTransforms[i+1]);
elizaPostTransforms[i].lastIndex=0;
@@ -364,12 +362,12 @@ ElizaBot.prototype._memGet = function() {
}
ElizaBot.prototype.getFinal = function() {
- if (!ElizaBot.prototype.global.elizaFinals) return '';
+ if (!elizaFinals) return '';
return elizaFinals[Math.floor(Math.random()*elizaFinals.length)];
}
ElizaBot.prototype.getInitial = function() {
- if (!ElizaBot.prototype.global.elizaInitials) return '';
+ if (!elizaInitials) return '';
return elizaInitials[Math.floor(Math.random()*elizaInitials.length)];
}
@@ -1001,5 +999,4 @@ var elizaPostTransforms = [
];
// eof
-
exports.ElizaBot = ElizaBot;
Please sign in to comment.
Something went wrong with that request. Please try again.