Subversion Repositories HomeAutomation

Rev

Rev 1603 | Rev 1609 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1603 Rev 1604
Line 20... Line 20...
20
}
20
}
21
 
21
 
22
function Module_OnChange(full_id, available)
22
function Module_OnChange(full_id, available)
23
{
23
{
24
    var parts = full_id.split(":", 2);
24
    var parts = full_id.split(":", 2);
-
 
25
   
-
 
26
    if (legacy)
-
 
27
    {
-
 
28
        legacyOnState(full_id, parts[1], parts[0], available);
-
 
29
        return;
-
 
30
    }
25
   
31
   
26
    var module = GetModule(parts[0]);
32
    var module = GetModule(parts[0]);
27
   
33
   
28
    if (module)
34
    if (module)
29
    {
35
    {
Line 40... Line 46...
40
    var variables = new Array();
46
    var variables = new Array();
41
   
47
   
42
    for (var i = 3; i < number_of_variables * 2 + 3; i += 2)
48
    for (var i = 3; i < number_of_variables * 2 + 3; i += 2)
43
    {
49
    {
44
        variables[arguments[i]] = arguments[i + 1];
50
        variables[arguments[i]] = arguments[i + 1];
45
    }
51
    }
46
   
52
   
47
    variables.length = number_of_variables;
53
    variables.length = number_of_variables;
48
   
54
   
49
    var parts = full_id.split(":", 2);
55
    var parts = full_id.split(":", 2);
-
 
56
   
-
 
57
    if (legacy)
-
 
58
    {
-
 
59
        legacyOnMessage(full_id, parts[1], parts[0], command, variables);
-
 
60
        return;
-
 
61
    }
-
 
62
   
50
   
63
   
51
    var module = GetModule(parts[0]);
64
    var module = GetModule(parts[0]);
52
   
65
   
53
    if (module)
66
    if (module)
54
    {
67
    {
Line 65... Line 78...
65
    var args = new Array();
78
    var args = new Array();
66
   
79
   
67
    args[args.length] = full_id;
80
    args[args.length] = full_id;
68
    args[args.length] = command;
81
    args[args.length] = command;
69
    args[args.length] = variables.length;
82
    args[args.length] = variables.length;
70
   
83
   
71
    for (var i = 0; i < variables.length; i++)
84
    for (var i = 0; i < variables.length; i++)
72
    {
85
    {
73
        var obj = variables[i];
86
        var obj = variables[i];
74
       
87
       
75
        for (var key in obj)
88
        for (var key in obj)
76
        {
89
        {
77
            args[args.length] = key;
90
            args[args.length] = key;
78
            args[args.length] = obj[key];
91
            args[args.length] = obj[key];
79
        }
92
        }
80
    }
93
    }
81
   
94
   
82
    Module_SendMessage.apply(null, Array.prototype.slice.call(args, 0));
95
    Module_SendMessage.apply(null, Array.prototype.slice.call(args, 0));
83
}
96
}
84
 
97
 
85
 
98
 
86
function Module(name)
99
function Module(name)
87
{
100
{
88
    this.name_ = name;
101
    this.name_ = name;
89
    this.ids_ = new Array();
102
    this.ids_ = new Array();
90
   
103
   
91
    this.EventBase();
104
    this.EventBase();
92
}
105
}
93
 
106
 
94
Extend(Module, EventBase);
107
Extend(Module, EventBase);
95
 
108
 
96
Module.prototype.name_;
109
Module.prototype.name_;
97
Module.prototype.ids_;
110
Module.prototype.ids_;
Line 109... Line 122...
109
    }
122
    }
110
}
123
}
111
 
124
 
112
Module.prototype.ReceiveMessage = function(id, command, variables)
125
Module.prototype.ReceiveMessage = function(id, command, variables)
113
{
126
{
114
   
-
 
-
 
127
    Log("received " + command);
115
}
128
}
116
 
129
 
117
Module.prototype.GetAvailableIds = function()
130
Module.prototype.GetAvailableIds = function()
118
{
131
{
119
    var ids = new Array();
132
    var ids = new Array();