Rev 1647 | Rev 1652 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1647 | Rev 1649 | ||
|---|---|---|---|
| Line 8... | Line 8... | ||
| 8 | 8 | ||
| 9 | function IROut_StopSend(alias_name) |
9 | function IROut_StopSend(alias_name) |
| 10 | { |
10 | { |
| 11 | if (arguments.length < 1) |
11 | if (arguments.length < 1) |
| 12 | { |
12 | { |
| 13 | Log("\033[ |
13 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 14 | return false; |
14 | return false; |
| 15 | } |
15 | } |
| 16 | 16 | ||
| 17 | var aliases_data = Module_ResolveAlias(alias_name, IROut_ModuleNames); |
17 | var aliases_data = Module_ResolveAlias(alias_name, IROut_ModuleNames); |
| 18 | var found = false; |
18 | var found = false; |
| Line 23... | Line 23... | ||
| 23 | "Channel" : aliases_data[name]["specific"]["Channel"], |
23 | "Channel" : aliases_data[name]["specific"]["Channel"], |
| 24 | "Status" : "Released" }; |
24 | "Status" : "Released" }; |
| 25 | 25 | ||
| 26 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "IR", variables)) |
26 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "IR", variables)) |
| 27 | { |
27 | { |
| 28 | Log("\033[ |
28 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 29 | } |
29 | } |
| 30 | else |
30 | else |
| 31 | { |
31 | { |
| 32 | Log("\033[ |
32 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
| 33 | } |
33 | } |
| 34 | 34 | ||
| 35 | found = true; |
35 | found = true; |
| 36 | } |
36 | } |
| 37 | 37 | ||
| 38 | if (!found) |
38 | if (!found) |
| 39 | { |
39 | { |
| 40 | Log("\033[ |
40 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| 41 | return false; |
41 | return false; |
| 42 | } |
42 | } |
| 43 | 43 | ||
| 44 | return true; |
44 | return true; |
| 45 | } |
45 | } |
| Line 67... | Line 67... | ||
| 67 | 67 | ||
| 68 | function IROut_Send(alias_name, remote_name, button_name, status) |
68 | function IROut_Send(alias_name, remote_name, button_name, status) |
| 69 | { |
69 | { |
| 70 | if (arguments.length < 4) |
70 | if (arguments.length < 4) |
| 71 | { |
71 | { |
| 72 | Log("\033[ |
72 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 73 | return false; |
73 | return false; |
| 74 | } |
74 | } |
| 75 | 75 | ||
| 76 | var result_text = ""; |
76 | var result_text = ""; |
| 77 | var aliases_data = Module_ResolveAlias(alias_name, IROut_ModuleNames); |
77 | var aliases_data = Module_ResolveAlias(alias_name, IROut_ModuleNames); |
| 78 | 78 | ||
| 79 | var remote_storage_name = Storage_GetParameter("RemoteList", remote_name); |
79 | var remote_storage_name = Storage_GetParameter("RemoteList", remote_name); |
| 80 | 80 | ||
| 81 | if (!remote_storage_name) |
81 | if (!remote_storage_name) |
| 82 | { |
82 | { |
| 83 | Log("\033[ |
83 | Log("\033[31mNo such remote name in list, " + remote_name + ".\033[0m\n"); |
| 84 | return false; |
84 | return false; |
| 85 | } |
85 | } |
| 86 | 86 | ||
| 87 | var button_string = Storage_GetParameter(remote_storage_name, button_name); |
87 | var button_string = Storage_GetParameter(remote_storage_name, button_name); |
| 88 | 88 | ||
| 89 | if (!button_string) |
89 | if (!button_string) |
| 90 | { |
90 | { |
| 91 | Log("\033[ |
91 | Log("\033[31mNo such button " + button_name + " found on remote " + remote + ".\033[0m\n"); |
| 92 | return false; |
92 | return false; |
| 93 | } |
93 | } |
| 94 | 94 | ||
| 95 | var button_data = eval("(" + button_string + ")"); |
95 | var button_data = eval("(" + button_string + ")"); |
| 96 | 96 | ||
| 97 | if (typeof button_data["protocol"] == 'undefined' || typeof button_data["data"] == 'undefined') |
97 | if (typeof button_data["protocol"] == 'undefined' || typeof button_data["data"] == 'undefined') |
| 98 | { |
98 | { |
| 99 | Log("\033[ |
99 | Log("\033[31mButton data is corrupt.\033[0m\n"); |
| 100 | return false; |
100 | return false; |
| 101 | } |
101 | } |
| 102 | 102 | ||
| 103 | for (var name in aliases_data) |
103 | for (var name in aliases_data) |
| 104 | { |
104 | { |
| Line 108... | Line 108... | ||
| 108 | "IRdata" : button_data["data"], |
108 | "IRdata" : button_data["data"], |
| 109 | "Status" : status }; |
109 | "Status" : status }; |
| 110 | 110 | ||
| 111 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "IR", variables)) |
111 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "IR", variables)) |
| 112 | { |
112 | { |
| 113 | Log("\033[ |
113 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 114 | } |
114 | } |
| 115 | else |
115 | else |
| 116 | { |
116 | { |
| 117 | Log("\033[ |
117 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
| 118 | } |
118 | } |
| 119 | 119 | ||
| 120 | found = true; |
120 | found = true; |
| 121 | } |
121 | } |
| 122 | 122 | ||
| 123 | if (!found) |
123 | if (!found) |
| 124 | { |
124 | { |
| 125 | Log("\033[ |
125 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| 126 | return false; |
126 | return false; |
| 127 | } |
127 | } |
| 128 | 128 | ||
| 129 | return true; |
129 | return true; |
| 130 | } |
130 | } |