Subversion Repositories HomeAutomation

Rev

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

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