Methods

  • BrainJS: u.method()
  • BrainXML: <u>method()</u>
function User( ) {
this.getLocation = function( ) {
  
     if (this.location.city) {
       return this.location.city;
     }
     else if (this.location.state) {
       return this.location.state;
     }
     else if (this.location.country) {
       return this.location.country;
     }
     else {
       return '';
     }
  
};
this.getLocationType = function( ) {
  
     if (this.location.city) {
       return "city";
     }
     else if (this.location.state) {
       return "state";
     }
     else if (this.location.country) {
       return "country";
     }
     else {
       return '';
     }
   
  
};
this.getMathExpr = function(str) {
  return extractMathExpr(str);
};
this.getName = function(relation) {
  
     if (!relation) {
       return this.getUserName();
     }
     var i = this.getIndex("",relation);
     if (i !== '') {
       if (this.people[i].name) {
         return this.people[i].name;
       }
       else {
         return "your " + relation;
       }
     }
     return "your " + relation;
  
};
this.getNames = function( ) {
  
     var names = [];
     var j = 0;
     for (var i in this.people) {
       if (this.people[i].name) {
         names[j] = this.people[i].name;
         j++;
       }
     }
     return names;
  
};
this.getNews = function(topic, offset) {
     var url = 'http://acobot.com/api/news/' + this.uid_key;
     if (topic === undefined){
       return sraix(url);
     }
     if(offset === undefined){
       offset = 0;
     }
     topic = encodeURIComponent(topic);
     topic = removeBOM(topic);
     url = url + '/' + topic + '/' + offset;
     return sraix(url);
  //return 'acox notFound news about ' + topic + '';
};
this.getNewsTopic = function( ) {
    
     var url = 'http://acobot.com/api/news_topic';
     return sraix(url);
  
};
this.getOpeningMovie = function( ) {
  
   
     var country = 'united states';
     if (this.location.country) {
       country = this.location.country;
     }
     return openingMovie(country);
  
};
this.getPageLang = function( ) {
    
     var lang = 'en';
     if (this.device.language && this.device.language != 'NaN'){
       lang = this.device.language;
     }
     if (lang == 'en') {
       if (this.firstLanguage !== undefined) {
         lang = this.firstLanguage;
       }
     }    
     else if (lang == 'zh') {
       if (this.device.country == 'CHN') {
         lang = 'zh-chs';
       }
       else {
         lang = 'zh-cht';
       }
     }
     else if (lang == 'zh-cn' || lang == 'zh-chs'){
       lang = 'zh-chs';
     }
     else if (lang == 'zh-tw' || lang == 'zh-cht' ){
       lang = 'zh-cht';
     } 
     else if (lang.indexOf('-') > -1) {
       var parts = lang.split('-');
       lang = parts[0];
     }  
     return lang;
  
};
this.getPerson = function(name, relation) {
  
     var i = this.getIndex(name, relation);
     if (i === '') {
       return '';
     }
     return this.people[i];
  
};

Pages