Methods

  • BrainJS: u.method()
  • BrainXML: <u>method()</u>
function User( ) {
this.ucwords = function(str) {
  
     //   example 1: ucwords('kevin van  zonneveld');
     //   returns 1: 'Kevin Van  Zonneveld'
     //   example 2: ucwords('HELLO WORLD');
     //   returns 2: 'HELLO WORLD'
   
     return (str + '')
       .replace(/^([a-z\u00E0-\u00FC])|\s+([a-z\u00E0-\u00FC])/g, function($1) {
         return $1.toUpperCase();
       });
  
};
this.uniquePS = function(ps) {
  
     var a = ps.concat();
     for(var i=0; i          
this.userTime2serverTime = function(time) {
  
     if (this.device.timezoneoffset === false) {      
       return time;
     }
     var now = new Date();
     var serverOffset = now.getTimezoneOffset();
     return time - this.device.timezoneoffset + serverOffset;
  
};
this.VBQuiz = function(cont) {
  
     var to = this.getPageLang();
     if (!to){
       to = 'en';
     }
     var url = 'http://acobot.com/api/vb/quiz/' + this.uid_key + '/' + to;
     if (cont === 'cont') {
       url += '/cont';
     }
     url += '?appversion=' + this.appVersion;
     return sraix(url);
  
};
this.vbRankScore = function(qid, input) {
  
     var to = this.getPageLang();
     if (!to){
       to = 'en';
     }
     if (qid === undefined || input === undefined) {
       qid = 0;
       input = 'null';
     }
     var url = 'http://acobot.com/api/vb/score/rank/' + this.uid_key + '/' + to + '/' + qid + '/' + input + '/' + this.adCredits;
     url += '?appversion=' + this.appVersion;
     return sraix(url);
  
};
this.VBReport = function( ) {
     var to = this.getPageLang();
     if (!to){
       to = 'en';
     }
     var url = 'http://acobot.com/api/vb/report/' + this.uid_key + '/' + to;
     return this.loadWebPage(url);
  
};
this.vbWordScore = function(qid, input) {
  
     var to = this.getPageLang();
     if (!to){
       to = 'en';
     }    
     if (qid === undefined || input === undefined) {
       qid = 0;
       input = 'null';
     }
     var url = 'http://acobot.com/api/vb/score/word/' + this.uid_key + '/' + to + '/' + qid + '/' + input + '/' + this.adCredits;
     url += '?appversion=' + this.appVersion;
     return sraix(url);
  
};
this.viewPS = function( ) {
  
     var cnt = 'user.ps: ';
     for (var i in this.ps){
       cnt = cnt + i + encodeURIComponent(' ' + this.ps[i].condition + ' = ' + this.ps[i].output) + ' ';
     }
     return cnt;
  
};
this.weakEngine = function(engine, text) {
     //text = encodeURIComponent (text);
     //engine = encodeURIComponent (engine);
     
     //var url = 'http://acobot.com/api/weak-engines/add/'+ engine + '/' + text;
     //return sraix(url);
     return "weakEngine";
  
};
this.word2num = function(s) {
  var Small = {
      'zero': 0,
      'one': 1,
      'two': 2,
      'three': 3,
      'four': 4,
      'five': 5,
      'six': 6,
      'seven': 7,
      'eight': 8,
      'nine': 9,
      'ten': 10,
      'eleven': 11,
      'twelve': 12,
      'thirteen': 13,
      'fourteen': 14,
      'fifteen': 15,
      'sixteen': 16,
      'seventeen': 17,
      'eighteen': 18,
      'nineteen': 19,
      'twenty': 20,
      'thirty': 30,
      'forty': 40,
      'fifty': 50,
      'sixty': 60,
      'seventy': 70,
      'eighty': 80,
      'ninety': 90
    };
  
    var Magnitude = {
      'thousand':     1000,
      'million':      1000000,
      'billion':      1000000000,
      'trillion':     1000000000000,
      'quadrillion':  1000000000000000,
      'quintillion':  1000000000000000000,
      'sextillion':   1000000000000000000000,
      'septillion':   1000000000000000000000000,
      'octillion':    1000000000000000000000000000,
      'nonillion':    1000000000000000000000000000000,
      'decillion':    1000000000000000000000000000000000
    };
  
    var a, n, g;
  
    function feach(w) {
      var x = Small[w];
      if (x != null) {
          g = g + x;
      }
      else if (w == "hundred") {
          g = g * 100;
      }
      else {
          x = Magnitude[w];
          if (x != null) {
              n = n + g * x;
              g = 0;
          }
          else { 
              return false;
          }
      }
    }
      
    a = s.toString().split(/[\s-]+/);
    n = 0;
    g = 0;
    a.forEach(feach);
    return n + g;
};

页面