Skip to content

Commit aed739f

Browse files
committed
Rebase & added check for api version (hide copy profile buttons for pre-BF-3.2 versions)
1 parent d918362 commit aed739f

File tree

1 file changed

+54
-48
lines changed

1 file changed

+54
-48
lines changed

tabs/pid_tuning.js

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -833,66 +833,72 @@ TABS.pid_tuning.initialize = function (callback) {
833833

834834
var selectProfileValues = { "0": "Profile 1", "1": "Profile 2", "2": "Profile 3" };
835835
var selectRateProfileValues = { "0": "Rateprofile 1", "1": "Rateprofile 2", "2": "Rateprofile 3" };
836+
837+
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
836838

837-
var selectProfile = $('.selectProfile');
838-
var selectRateProfile = $('.selectRateProfile');
839+
var selectProfile = $('.selectProfile');
840+
var selectRateProfile = $('.selectRateProfile');
839841

840-
$.each(selectProfileValues, function(key, value) {
841-
if (key != CONFIG.profile)
842-
selectProfile.append(new Option(value, key));
843-
});
844-
$.each(selectRateProfileValues, function(key, value) {
845-
if (key != CONFIG.rateProfile)
846-
selectRateProfile.append(new Option(value, key));
847-
});
842+
$.each(selectProfileValues, function(key, value) {
843+
if (key != CONFIG.profile)
844+
selectProfile.append(new Option(value, key));
845+
});
846+
$.each(selectRateProfileValues, function(key, value) {
847+
if (key != CONFIG.rateProfile)
848+
selectRateProfile.append(new Option(value, key));
849+
});
848850

849-
$('.copyprofilebtn').click(function() {
850-
$('.dialogCopyProfile').find('.contentProfile').show();
851-
$('.dialogCopyProfile').find('.contentRateProfile').hide();
852-
dialogCopyProfileMode = DIALOG_MODE_PROFILE;
853-
dialogCopyProfile.showModal();
854-
});
851+
$('.copyprofilebtn').click(function() {
852+
$('.dialogCopyProfile').find('.contentProfile').show();
853+
$('.dialogCopyProfile').find('.contentRateProfile').hide();
854+
dialogCopyProfileMode = DIALOG_MODE_PROFILE;
855+
dialogCopyProfile.showModal();
856+
});
855857

856-
$('.copyrateprofilebtn').click(function() {
857-
$('.dialogCopyProfile').find('.contentProfile').hide();
858-
$('.dialogCopyProfile').find('.contentRateProfile').show();
859-
dialogCopyProfileMode = DIALOG_MODE_RATEPROFILE;
860-
dialogCopyProfile.showModal();
861-
});
858+
$('.copyrateprofilebtn').click(function() {
859+
$('.dialogCopyProfile').find('.contentProfile').hide();
860+
$('.dialogCopyProfile').find('.contentRateProfile').show();
861+
dialogCopyProfileMode = DIALOG_MODE_RATEPROFILE;
862+
dialogCopyProfile.showModal();
863+
});
862864

863-
$('.dialogCopyProfile-cancelbtn').click(function() {
864-
dialogCopyProfile.close();
865-
});
865+
$('.dialogCopyProfile-cancelbtn').click(function() {
866+
dialogCopyProfile.close();
867+
});
866868

867-
$('.dialogCopyProfile-confirmbtn').click(function() {
868-
switch(dialogCopyProfileMode) {
869-
case DIALOG_MODE_PROFILE:
870-
COPY_PROFILE.type = DIALOG_MODE_PROFILE; // 0 = pid profile
871-
COPY_PROFILE.dstProfile = parseInt(selectProfile.val());
872-
COPY_PROFILE.srcProfile = CONFIG.profile;
869+
$('.dialogCopyProfile-confirmbtn').click(function() {
870+
switch(dialogCopyProfileMode) {
871+
case DIALOG_MODE_PROFILE:
872+
COPY_PROFILE.type = DIALOG_MODE_PROFILE; // 0 = pid profile
873+
COPY_PROFILE.dstProfile = parseInt(selectProfile.val());
874+
COPY_PROFILE.srcProfile = CONFIG.profile;
873875

874-
MSP.send_message(MSPCodes.MSP_COPY_PROFILE, mspHelper.crunch(MSPCodes.MSP_COPY_PROFILE), false, close_dialog);
876+
MSP.send_message(MSPCodes.MSP_COPY_PROFILE, mspHelper.crunch(MSPCodes.MSP_COPY_PROFILE), false, close_dialog);
875877

876-
break;
877-
878-
case DIALOG_MODE_RATEPROFILE:
879-
COPY_PROFILE.type = DIALOG_MODE_RATEPROFILE; // 1 = rate profile
880-
COPY_PROFILE.dstProfile = parseInt(selectRateProfile.val());
881-
COPY_PROFILE.srcProfile = CONFIG.profile;
878+
break;
879+
880+
case DIALOG_MODE_RATEPROFILE:
881+
COPY_PROFILE.type = DIALOG_MODE_RATEPROFILE; // 1 = rate profile
882+
COPY_PROFILE.dstProfile = parseInt(selectRateProfile.val());
883+
COPY_PROFILE.srcProfile = CONFIG.profile;
882884

883-
MSP.send_message(MSPCodes.MSP_COPY_PROFILE, mspHelper.crunch(MSPCodes.MSP_COPY_PROFILE), false, close_dialog);
885+
MSP.send_message(MSPCodes.MSP_COPY_PROFILE, mspHelper.crunch(MSPCodes.MSP_COPY_PROFILE), false, close_dialog);
884886

885-
break;
887+
break;
886888

887-
default:
888-
close_dialog();
889-
break;
890-
}
889+
default:
890+
close_dialog();
891+
break;
892+
}
891893

892-
function close_dialog() {
893-
dialogCopyProfile.close();
894-
}
895-
});
894+
function close_dialog() {
895+
dialogCopyProfile.close();
896+
}
897+
});
898+
} else {
899+
$('.copyprofilebtn').hide();
900+
$('.copyrateprofilebtn').hide();
901+
}
896902

897903
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
898904
$('#pid-tuning .delta select').change(function() {

0 commit comments

Comments
 (0)