Rev 1647 | Rev 1649 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1647 | Rev 1648 | ||
|---|---|---|---|
| Line 24... | Line 24... | ||
| 24 | for (var button_name in buttons) |
24 | for (var button_name in buttons) |
| 25 | { |
25 | { |
| 26 | var button_data = eval("(" + buttons[button_name]+ ")"); |
26 | var button_data = eval("(" + buttons[button_name]+ ")"); |
| 27 | 27 | ||
| 28 | Log(buttons[button_name]); |
28 | Log(buttons[button_name]); |
| 29 | - | ||
| 30 | Log(button_data); |
- | |
| 31 | Log(button_data["protocol"] + "==" + protocol); |
- | |
| 32 | Log(button_data["data"] + "==" + data); |
- | |
| 33 | 29 | ||
| 34 | if (button_data["data"] == (data + '') && button_data["protocol"] == protocol) |
30 | if (button_data["data"] == (data + '') && button_data["protocol"] == protocol) |
| 35 | { |
31 | { |
| 36 | return button_name; |
32 | return button_name; |
| 37 | } |
33 | } |
| 38 | } |
34 | } |
| 39 | 35 | ||
| 40 | Log("Found |
36 | Log("Found no matching button on remote " + remote_name); |
| 41 | return ""; |
37 | return ""; |
| 42 | } |
38 | } |
| 43 | 39 | ||
| 44 | function IRIn_Record(alias_name, remote_name) |
40 | function IRIn_Record(alias_name, remote_name) |
| 45 | { |
41 | { |
| 46 | 42 | ||
| 47 | if (arguments.length < 2) |
43 | if (arguments.length < 2) |
| 48 | { |
44 | { |
| 49 | Log("\033[31;1mNot enough parameters given.\033[0m\n"); |
45 | Log("\033[31;1mNot enough parameters given.\033[0m\n"); |
| 50 | return false; |
46 | return false; |
| 51 | } |
47 | } |
| 52 | 48 | ||
| 53 | IRIn_RecordRemoteName = Storage_GetParameter("RemoteList", remote_name); |
49 | IRIn_RecordRemoteName = Storage_GetParameter("RemoteList", remote_name); |
| 54 | 50 | ||
| 55 | if (!IRIn_RecordRemoteName) |
51 | if (!IRIn_RecordRemoteName) |
| 56 | { |
52 | { |
| 57 | IRIn_RecordRemoteName = "Remote_" + remote_name; |
53 | IRIn_RecordRemoteName = "Remote_" + remote_name; |
| 58 | 54 | ||
| 59 | Log("\033[32;1mNo such remote name in list, " + remote_name + ", creating...\033[0m\n"); |
55 | Log("\033[32;1mNo such remote name in list, " + remote_name + ", creating...\033[0m\n"); |
| 60 | 56 | ||
| 61 | Storage_SetParameter("RemoteList", remote_name, IRIn_RecordRemoteName); |
57 | Storage_SetParameter("RemoteList", remote_name, IRIn_RecordRemoteName); |
| 62 | } |
58 | } |
| 63 | 59 | ||
| 64 | var aliases_data = Module_ResolveAlias(alias_name, IRIn_ModuleNames); |
60 | var aliases_data = Module_ResolveAlias(alias_name, IRIn_ModuleNames); |
| 65 | 61 | ||
| 66 | for (var name in aliases_data) |
62 | for (var name in aliases_data) |
| 67 | { |
63 | { |
| 68 | if (aliases_data[name]["group"]) |
64 | if (aliases_data[name]["group"]) |
| 69 | { |
65 | { |
| 70 | Log("\033[31;1mAlias must not be an alias group.\033[0m\n"); |
66 | Log("\033[31;1mAlias must not be an alias group.\033[0m\n"); |
| 71 | return false; |
67 | return false; |
| 72 | } |
68 | } |
| 73 | 69 | ||
| 74 | IRIn_RecordAliasData = aliases_data[name]; |
70 | IRIn_RecordAliasData = aliases_data[name]; |
| 75 | Log("Enter a single dot to finish.\n"); |
71 | Log("Enter a single dot to finish.\n"); |
| 76 | 72 | ||
| Line 84... | Line 80... | ||
| 84 | Log("\033[31;1mNo such alias name found, " + alias_name + ".\033[0m\n"); |
80 | Log("\033[31;1mNo such alias name found, " + alias_name + ".\033[0m\n"); |
| 85 | return false; |
81 | return false; |
| 86 | 82 | ||
| 87 | } |
83 | } |
| 88 | Console_RegisterCommand(IRIn_Record, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, IRIn_Aliases(), IRIn_Remotes()); }); |
84 | Console_RegisterCommand(IRIn_Record, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, IRIn_Aliases(), IRIn_Remotes()); }); |
| 89 | 85 | ||
| 90 | function IRIn_RecordOnResponse(response) |
86 | function IRIn_RecordOnResponse(response) |
| 91 | { |
87 | { |
| 92 | if (response == ".") |
88 | if (response == ".") |
| 93 | { |
89 | { |
| 94 | return true; |
90 | return true; |
| 95 | } |
91 | } |
| 96 | 92 | ||
| 97 | Storage_SetParameter(IRIn_RecordRemoteName, response, JSON.stringify(IRIn_RecordLast)); |
93 | Storage_SetParameter(IRIn_RecordRemoteName, response, JSON.stringify(IRIn_RecordLast)); |
| 98 | IRIn_RecordLast = null; |
94 | IRIn_RecordLast = null; |
| 99 | 95 | ||
| 100 | Log("\033[29;1mPress a button on you remote...\033[0m\n"); |
96 | Log("\033[29;1mPress a button on you remote...\033[0m\n"); |
| 101 | Console_PreventDefaultPrompt(); |
97 | Console_PreventDefaultPrompt(); |
| 102 | 98 | ||
| 103 | return true; |
99 | return true; |
| 104 | } |
100 | } |
| 105 | 101 | ||
| 106 | function IRIn_RecordOnIrMessage(alias_name, command, variables) |
102 | function IRIn_RecordOnIrMessage(alias_name, command, variables) |
| 107 | { |
103 | { |
| 108 | Log("callback\n"); |
- | |
| 109 | - | ||
| 110 | if (variables["Status"] != "Pressed" || IRIn_RecordLast != null) |
104 | if (variables["Status"] != "Pressed" || IRIn_RecordLast != null) |
| 111 | { |
105 | { |
| 112 | return; |
106 | return; |
| 113 | } |
107 | } |
| 114 | 108 | ||