|
4 | 4 | function sepiaFW_build_client_controls(){ |
5 | 5 | var Controls = {}; |
6 | 6 |
|
| 7 | + function parseAction(action){ |
| 8 | + var req; |
| 9 | + if (typeof action === "string"){ |
| 10 | + req = JSON.parse(action); |
| 11 | + }else{ |
| 12 | + req = action; |
| 13 | + } |
| 14 | + return req; |
| 15 | + } |
| 16 | + |
7 | 17 | //Open/close settings menu |
8 | 18 | Controls.settings = function(controlData){ |
9 | 19 | if (controlData && controlData.action){ |
@@ -50,10 +60,15 @@ function sepiaFW_build_client_controls(){ |
50 | 60 | //volumeDown |
51 | 61 | volumeDown(); |
52 | 62 | return true; |
53 | | - }else if (controlData.action == "set"){ |
| 63 | + }else if (controlData.action.match(/volume;;\d/gi).length == 1){ |
54 | 64 | //volumeSet |
55 | | - volumeSet(controlData.volume); //TODO: untested and not fully implemented yet |
56 | | - return true; |
| 65 | + var vol = parseInt(controlData.action.split(";;")[1]); //no data, we have the shortcut here ;-) |
| 66 | + if (vol){ |
| 67 | + volumeSet(vol); //TODO: untested and not fully implemented yet |
| 68 | + return true; |
| 69 | + }else{ |
| 70 | + return false; |
| 71 | + } |
57 | 72 | }else{ |
58 | 73 | SepiaFW.debug.error("Client controls - Unsupported action in 'settings': " + controlData.action); |
59 | 74 | } |
@@ -89,16 +104,21 @@ function sepiaFW_build_client_controls(){ |
89 | 104 | } |
90 | 105 | } |
91 | 106 |
|
| 107 | + //CLEXI send |
| 108 | + Controls.clexi = function(controlData){ |
| 109 | + if (SepiaFW.clexi && controlData.action){ |
| 110 | + var req = parseAction(controlData.action); |
| 111 | + //console.log(req); |
| 112 | + SepiaFW.clexi.send(req.xtension, req.data); |
| 113 | + return true; |
| 114 | + } |
| 115 | + return false; |
| 116 | + } |
| 117 | + |
92 | 118 | //Mesh-Node call |
93 | 119 | Controls.meshNode = function(controlData){ |
94 | | - //TODO |
95 | 120 | if (controlData.action){ |
96 | | - var req; |
97 | | - if (typeof controlData.action === "string"){ |
98 | | - req = JSON.parse(controlData.action); |
99 | | - }else{ |
100 | | - req = controlData.action; |
101 | | - } |
| 121 | + var req = parseAction(controlData.action); |
102 | 122 | //console.log(req); |
103 | 123 | return callMeshNode(req.url, req.pin, req.plugin, req.data); |
104 | 124 | } |
|
0 commit comments