Subversion Repositories HomeAutomation

Rev

Rev 1608 | Rev 1619 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1.  
  2. var global_legacy = false;
  3.  
  4. function Start(legacy)
  5. {
  6.     global_legacy = legacy;
  7.    
  8.     if (global_legacy)
  9.     {
  10.         LoadScript("legacy/System/Base.js");
  11.         LoadScript("legacy/System/Startup.js");
  12.         LoadScript("legacy/Autostart.js");
  13.        
  14.         autostart();
  15.     }
  16.     else
  17.     {
  18.         LoadScript("user/autostart.js");
  19.     }
  20. }
  21.  
  22. function Extend(descendant, parent)
  23. {
  24.     var s_constructor = parent.toString();
  25.     var a_match = s_constructor.match(/\s*function (.*)\(/);
  26.    
  27.     if (a_match != null)
  28.     {
  29.         descendant.prototype[a_match[1]] = parent;
  30.     }
  31.    
  32.     for (var m in parent.prototype)
  33.     {
  34.         descendant.prototype[m] = parent.prototype[m];
  35.     }
  36. }
  37.  
  38. String.prototype.ltrim = function(charlist)
  39. {
  40.     charlist = !charlist ? ' \s\xA0' : charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1');
  41.     var re = new RegExp('^[' + charlist + ']+', 'g');
  42.     return this.replace(re, '');
  43. }
  44.  
  45. String.prototype.rtrim = function(charlist)
  46. {
  47.     charlist = !charlist ? ' \s\xA0' : charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1');
  48.     var re = new RegExp('[' + charlist + ']+$', 'g');
  49.     return this.replace(re, '');
  50. }
  51.  
  52. String.prototype.trim = function(charlist)
  53. {
  54.     var str = this.ltrim(charlist);
  55.     return str.rtrim(charlist);
  56. }
  57.  
  58. function EventBase()
  59. {
  60.     this.callbacks_ = new Array();
  61. }
  62.  
  63. EventBase.prototype.callbacks_ = null;
  64.  
  65. EventBase.prototype.Bind = function(event_name, callback)
  66. {
  67.     if (typeof this.callbacks_[event_name] == 'undefined')
  68.     {
  69.         this.callbacks_[event_name] = new Array();
  70.     }
  71.    
  72.     this.callbacks_[event_name].push(callback);
  73. }
  74.  
  75. EventBase.prototype.Trigger = function(event_name)
  76. {
  77.     if (typeof this.callbacks_[event_name] != 'undefined')
  78.     {
  79.         for (var n = 0; n < this.callbacks_[event_name].length; n++)
  80.         {
  81.             this.callbacks_[event_name][n].apply(null, Array.prototype.slice.call(arguments, 0));
  82.         }
  83.     }
  84. }
  85.