Subversion Repositories HomeAutomation

Rev

Rev 1604 | Rev 1608 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

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