Methods

  • BrainJS: u.method()
  • BrainXML: <u>method()</u>
function User( ) {
this.decrAdCredits = function( ) {
  
     if (this.adCredits < 1) {
       this.adCredits = 0;
     }
     else {
       this.adCredits --;
     }
     return this.adCredits;  
  
};
this.delBuddy = function(uid) {
  
     delete this.buddies[uid];
  
};
this.dialogBullet = function( ) {
  
     return 'Dialog ' + this.dialog + '.';
  
};
this.dict2MyWords = function(word, version) {
  
     var lang = this.getPageLang();
     var url = 'http://acobot.com/api/dict2mywords/' + this.uid_key + '/' + word + '/' + lang + '/' + version;
     return sraix(url);
  
};
this.firstDialog = function( ) {
  
     if (this.reviews.length > 0) {
       this.reviewing = 1;
       return this.reviews.shift();
     }
     else {
       this.reviewing = 0;
       return this.dialog;
     }
     
  
};
this.getAccusativePronoun = function(title) {
     if (!title) {
       return '';
     }
     var pronoun = this.getPronoun(title);
     return this.p2ap(pronoun);
  
};
this.getAge = function( ) {
     var elapsed;
     var d = new Date();
     if(!isNaN(this.birth.year)) {
       return d.getFullYear() - this.birth.year;
     }
     else if (this.age && this.age > 0) {
       var d2 = new Date(this.ageDate);
       elapsed = d.getFullYear() - d2.getFullYear(); 
       return this.age + elapsed;
     }
     else {
       return '';
     }
  
};
this.getAP = function(title) {
  
     return this.getaccusativePronoun(title);
  
};
this.getBirthdayOffset = function( ) {
    
     if (!this.birth.date) {
       return false;
     }    
     if (this.birth.month === '' ||
         this.birth.date === '') {
       return false;
     }    
     var now = new Date();
     thisYear = now.getFullYear();
     var birthDate = new Date(thisYear, parseInt(this.birth.month,10)-1, parseInt(this.birth.date,10));
     var days = (birthDate.getTime() - now.getTime())/86400000;
     if (days > 0) {
       return Math.round(days);
     }
     else {
       return Math.ceil(days);
     }
  
};
this.getBuddies = function( ) {
  
   
     return '<page>buddies</page>' + JSON.stringfy(this.buddies);    
  
};

Pages