Subversion Repositories HomeAutomation

Rev

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

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