Methods

  • BrainJS: u.method()
  • BrainXML: <u>method()</u>
function User( ) {
this.loadWebPage = function(url) {
     
     return '<page>web</page> <load>' + url + '</load>';
  
};
this.locationReady = function( ) {
  
     var country = this.getCountry();    
     if (!country) {
       return false; 
     }
     if (!this.location.city) {
       return false;
     }
     country = country.toLowerCase(); 
     var countries = ['united states', 'usa', 'canada', 'can', 'australia', 'aus'];
     if (countries.indexOf(country) !== -1) {
       if (!this.location.state){
         return false;
       }
     }
     return true;
  
};
this.lookUp = function(str, version) {
  
     if (str === undefined || str === '' ){
       return 'acox lookUpResponse inputMissed';
     }
     if (version === undefined){
       version = 0;
     }
     var to = this.getPageLang();
     if (!to){
       to = 'en';
     }
     str = encodeURIComponent (str);    
     var url = 'http://acobot.com/api/dict/' + this.uid_key + '/' + str + '/' + to;
       return '<page>dictionary</page><load>' + url + '</load>';
     
     if (version == 2) {
       url = url + '/' + version;
       return sraix(url);
     }
     else {
       return '<page>dictionary</page><load>' + url + '</load>';
     }
     
  
};
this.lowerCase = function(str) {
  
     return str.toLowerCase();
  
};
this.lyrics = function(artist, song) {
  
     artist = encodeURIComponent(artist);
     song = encodeURIComponent(song);
     var url = 'http://acobot.com/api/lyrics/' + artist + '/' + song;
     return sraix(url);
  
};
this.machineReply = function(query) {
     // query = encodeURIComponent (query);
     // query = query.split(")").join("");
     // var url = 'http://acobot.com/api/reply/'+query;
     // return sraix(url);
  return "mechineReply";
  
};
this.month2n = function(arg) {
  
     var m = arg.toLowerCase();
     switch (m){
       case "january":
       case "jan":
         return 0;
       case "feburay":
       case "feb":
         return 1;
       case "march":
       case "mar":
         return 2;
       case "april":
       case "apr":
         return 3;
       case "may":
         return 4;
       case "june":
       case "jun":
         return 5;
       case "july":
       case "jul":
         return 6;
       case "august":
       case "aug":
         return 7;
       case "september":
       case "sept":
         return 8;
       case "octber":
       case "oct":
         return 9;
       case "november":
       case "nov":
         return 10;
       case "december":
       case "dec":
         return 11;
       default:
         return arg;
     }
  
};
this.monthOffset = function(nStr) {
     var n = parseFloat(nStr);
     if (isNaN(n)){
       return false;
     }
     var today = new Date();
     var thisMonth = today.getMonth();
     var m = thisMonth + n + 1;
     if (m > 12) {
       m = m -12;
     }
     else if (m < 1) {
       m = m + 12;
     }  
     return n2Month(m);
  
};
this.monthToSc = function(mon) {
  var monVal = {
  January:'一月',
  February:'二月',
  March:'三月',
  april:'四月',
  May:'五月',
  June:'六月',
  July:'七月',
  august:'八月',
  September:'九月',
  October:'十月',
  November:'十一月',
  December:'十二月'
  }
  
  return monVal[mon];
};
this.movieSynopsisById = function(id) {
  
     if (id === undefined) {
       return 'acox movieSynopsis idMissed';
     }
     var url = 'http://acobot.com/api/movie/synopsis/id'+id;
     return sraix(url);
  
};

Pages