Methods

  • BrainJS: u.method()
  • BrainXML: <u>method()</u>
function User( ) {
this.getPlaceRef = function(place) {
    
     if (place === undefined) {
       return '';
     }
     var geo;
     for ( geo in this.location){
       if (this.location[geo] == place) {
         return "your " + geo;
       }
     }
     for ( geo in this.birthplace) {
       if (this.location[geo] == place) {
         return "your birth " + geo;
       }
     }
     return place;
  
};
this.getPossessivePronoun = function(title) {
     if (!title) {
       return '';
     }
     var pronoun = this.getPronoun(title);
     return this.p2pp(pronoun);
  
};
this.getPP = function(title) {
  
     return this.getPossessivePronoun(title);
  
};
this.getProfile = function( ) {
     var profile = '';
     if (this.name) {
       profile += 'Name: ' + this.name+'. ';
     }
     if (this.getAge()) {
       profile += 'age: '+ this.getAge()+'. ';
     }
     if (this.gender) {
       profile += 'Gender: '+ this.gender+'. ';
     }
     if (this.getLocation()) {
       profile += 'Location: '+ this.getLocation()+'. ';
     }
     return profile;
  
};
this.getPronoun = function(title) {
     if (!title) {
       return '';
     }
     var pronoun = this.r2p(title);
     if (pronoun !== '') {
       return pronoun;
     }
     return this.getPronounByName(title);
  
};
this.getPronounByName = function(name, relation) {
  
     var i = this.getIndex(name, relation);
     if (i === ''){
       return '';
     }
     switch (this.people[i].gender) {
       case 'male':
         return 'he';
       case 'female':
         return 'she';
       default:
         return '';
     }
  
};
this.getRelation = function(name) {
  
     if(name){
       var i = this.getIndex(name);
       if (i !== '') {
         return this.people[i].relation;
       }
     }
     return '';
  
};
this.getRemainDays = function( ) {
    var d=new Date(); 
    var rd=d.getDate();
    var m=d.getMonth()+1;
    var y=d.getFullYear();
    
    if (m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12)
    {rd=31-rd;}
    else if (m==4 || m==6 || m==9 || m==11)
    {rd=30-rd;}
    else if ((m==2) && (y%4===0) && (y%100!==0))
    {rd=29-rd;}
    else {rd=28-rd;}
    return rd;
};
this.getSpouseName = function( ) {
  
     switch (this.gender) {
       case "male":
         switch (this.marital) {
           case "single":
             return this.getName('girlfriend');
           case "engaged":
             return this.getName('fiancee');
           case "married":  
             return this.getName('wife');
           default:
             return '';
         }
         break;
       case "female":
         switch (this.marital) {
           case "single":
             return this.getName('boyfriend');
           case "engaged":
             return this.getName('finace');
           case "married":  
             return this.getName('husband');
           default:
             return '';
         }        
         break;
       default:
         return '';
     }
  
};
this.getTargetLangCode = function( ) {
  
   
     var lang = false;
     if (this.targetLang && this.targetLang != 'en') {
       lang = this.targetLang;
     }
     else if (this.device.language){
       lang = this.device.language;
     }
     else {
       lang = 'en';
     }
     
     if (lang == 'zh') {
       if (this.device.country == 'CHN') {
         lang = 'zh-chs';
       }
       else {
         lang = 'zh-cht';
       }
     }    
     return lang;
  
};

页面