diff options
author | Pawel Spychalski (DzikuVx) <pspychalski@gmail.com> | 2019-04-01 22:22:22 +0300 |
---|---|---|
committer | Pawel Spychalski (DzikuVx) <pspychalski@gmail.com> | 2019-04-01 22:22:22 +0300 |
commit | e23a8a518935179a465bf8d1c0fa4e7539d0f3ba (patch) | |
tree | 8d28f6c99dd680a6ddb629f2881f705de7ea6959 /js | |
parent | 2a4f9309b9853b03e7ba071115924229cfd55245 (diff) |
UI improvements and saving
Diffstat (limited to 'js')
-rw-r--r-- | js/logicCondition.js | 5 | ||||
-rw-r--r-- | js/logicConditionsCollection.js | 35 | ||||
-rw-r--r-- | js/msp/MSPHelper.js | 10 |
3 files changed, 36 insertions, 14 deletions
diff --git a/js/logicCondition.js b/js/logicCondition.js index 362f0410..8e5e508d 100644 --- a/js/logicCondition.js +++ b/js/logicCondition.js @@ -63,7 +63,7 @@ let LogicCondition = function (enabled, operation, operandAType, operandAValue, self.onEnabledChange = function (event) { let $cT = $(event.currentTarget); - console.log($cT); + self.setEnabled(!!$cT.prop('checked')); }; self.getOperatorMetadata = function () { @@ -231,9 +231,6 @@ let LogicCondition = function (enabled, operation, operandAType, operandAValue, self.renderOperand(0); self.renderOperand(1); - - console.log($row); - } return self; diff --git a/js/logicConditionsCollection.js b/js/logicConditionsCollection.js index 7390a615..f22db142 100644 --- a/js/logicConditionsCollection.js +++ b/js/logicConditionsCollection.js @@ -3,7 +3,8 @@ let LogicConditionsCollection = function () { let self = {}, - data = []; + data = [], + $container; self.put = function (element) { data.push(element); @@ -19,17 +20,41 @@ let LogicConditionsCollection = function () { self.getCount = function () { return data.length - } + }; - self.render = function ($container) { + self.render = function () { + let $table = $container.find(".logic__table") + $table.find("tbody tr").remove(); for (let k in self.get()) { if (self.get().hasOwnProperty(k)) { - self.get()[k].render(k, $container); + self.get()[k].render(k, $table); } } + }; + + self.onSave = function () { + let chain = new MSPChainerClass() + + chain.setChain([ + mspHelper.sendLogicConditions, + mspHelper.saveToEeprom + ]); + + chain.execute(); + }; + + self.onClose = function() { + $container.hide(); + }; - } + self.init = function ($element) { + $container = $element; + + $container.find('.logic__save').click(self.onSave); + $container.find('.logic__close').click(self.onClose); + + }; return self; };
\ No newline at end of file diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index d0b94daf..1d903830 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -2370,7 +2370,7 @@ var mspHelper = (function (gui) { let buffer = []; - // send one at a time, with index + // send one at a time, with index, 14 bytes per one condition let condition = LOGIC_CONDITIONS.get()[conditionIndex]; @@ -2383,10 +2383,10 @@ var mspHelper = (function (gui) { buffer.push(specificByte(condition.getOperandAValue(), 2)); buffer.push(specificByte(condition.getOperandAValue(), 3)); buffer.push(condition.getOperandBType()); - buffer.push(specificByte(condition.getOperandAValue(), 0)); - buffer.push(specificByte(condition.getOperandAValue(), 1)); - buffer.push(specificByte(condition.getOperandAValue(), 2)); - buffer.push(specificByte(condition.getOperandAValue(), 3)); + buffer.push(specificByte(condition.getOperandBValue(), 0)); + buffer.push(specificByte(condition.getOperandBValue(), 1)); + buffer.push(specificByte(condition.getOperandBValue(), 2)); + buffer.push(specificByte(condition.getOperandBValue(), 3)); buffer.push(condition.getFlags()); // prepare for next iteration |