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": {
|
"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."
|
"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": {
|
"auxiliaryMin": {
|
||||||
"message": "Min"
|
"message": "Min"
|
||||||
},
|
},
|
||||||
|
|
|
@ -244,8 +244,9 @@ TABS.auxiliary.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_ui() {
|
function update_ui() {
|
||||||
for (var i = 0; i < AUX_CONFIG.length; i++) {
|
let hasUsedMode = false;
|
||||||
var modeElement = $('#mode-' + i);
|
for (let i = 0; i < AUX_CONFIG.length; i++) {
|
||||||
|
let modeElement = $('#mode-' + i);
|
||||||
if (modeElement.find(' .range').length == 0) {
|
if (modeElement.find(' .range').length == 0) {
|
||||||
// if the mode is unused, skip it
|
// if the mode is unused, skip it
|
||||||
modeElement.removeClass('off').removeClass('on');
|
modeElement.removeClass('off').removeClass('on');
|
||||||
|
@ -257,6 +258,15 @@ TABS.auxiliary.initialize = function (callback) {
|
||||||
} else {
|
} else {
|
||||||
$('.mode .name').eq(i).data('modeElement').removeClass('on').addClass('off');
|
$('.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);
|
auto_select_channel(RC.channels);
|
||||||
|
@ -306,6 +316,18 @@ TABS.auxiliary.initialize = function (callback) {
|
||||||
return fillPrevChannelsValues();
|
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 instantly on first load
|
||||||
update_ui();
|
update_ui();
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,12 @@
|
||||||
<div class="note spacebottom">
|
<div class="note spacebottom">
|
||||||
<div class="note_spacer">
|
<div class="note_spacer">
|
||||||
<p i18n="auxiliaryHelp"></p>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
<table class="modes">
|
<table class="modes">
|
||||||
|
|
Loading…
Reference in New Issue