Merge pull request #1128 from atomgomba/feature-toggle-unconfigured-modes
Add switch to show/hide unused modes10.4.x-maintenance
commit
e4aa88906b
|
@ -1504,6 +1504,9 @@
|
|||
"auxiliaryHelp": {
|
||||
"message": "Use ranges to define the switches on your transmitter and corresponding mode assignments. A receiver channel that gives a reading between a range min/max will activate the mode. Remember to save your settings using the Save button."
|
||||
},
|
||||
"auxiliaryToggleUnused": {
|
||||
"message": "Show/hide unused modes"
|
||||
},
|
||||
"auxiliaryMin": {
|
||||
"message": "Min"
|
||||
},
|
||||
|
|
|
@ -244,8 +244,9 @@ TABS.auxiliary.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function update_ui() {
|
||||
for (var i = 0; i < AUX_CONFIG.length; i++) {
|
||||
var modeElement = $('#mode-' + i);
|
||||
let hasUsedMode = false;
|
||||
for (let i = 0; i < AUX_CONFIG.length; i++) {
|
||||
let modeElement = $('#mode-' + i);
|
||||
if (modeElement.find(' .range').length == 0) {
|
||||
// if the mode is unused, skip it
|
||||
modeElement.removeClass('off').removeClass('on');
|
||||
|
@ -257,6 +258,15 @@ TABS.auxiliary.initialize = function (callback) {
|
|||
} else {
|
||||
$('.mode .name').eq(i).data('modeElement').removeClass('on').addClass('off');
|
||||
}
|
||||
hasUsedMode = true;
|
||||
}
|
||||
|
||||
let hideUnused = hideUnusedModes && hasUsedMode;
|
||||
for (let i = 0; i < AUX_CONFIG.length; i++) {
|
||||
let modeElement = $('#mode-' + i);
|
||||
if (modeElement.find(' .range').length == 0) {
|
||||
modeElement.toggle(!hideUnused);
|
||||
}
|
||||
}
|
||||
|
||||
auto_select_channel(RC.channels);
|
||||
|
@ -306,6 +316,18 @@ TABS.auxiliary.initialize = function (callback) {
|
|||
return fillPrevChannelsValues();
|
||||
}
|
||||
|
||||
let hideUnusedModes = false;
|
||||
chrome.storage.local.get('hideUnusedModes', function (result) {
|
||||
$("input#switch-toggle-unused")
|
||||
.change(function() {
|
||||
hideUnusedModes = $(this).prop("checked");
|
||||
chrome.storage.local.set({ hideUnusedModes: hideUnusedModes });
|
||||
update_ui();
|
||||
})
|
||||
.prop("checked", !!result.hideUnusedModes)
|
||||
.change();
|
||||
});
|
||||
|
||||
// update ui instantly on first load
|
||||
update_ui();
|
||||
|
||||
|
|
|
@ -7,6 +7,12 @@
|
|||
<div class="note spacebottom">
|
||||
<div class="note_spacer">
|
||||
<p i18n="auxiliaryHelp"></p>
|
||||
<p>
|
||||
<form>
|
||||
<input type="checkbox" id="switch-toggle-unused" name="switch-toggle-unused" class="togglesmall"></input>
|
||||
<label for="switch-toggle-unused"><span i18n="auxiliaryToggleUnused" /></label>
|
||||
</form>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<table class="modes">
|
||||
|
|
Loading…
Reference in New Issue