Сохранение текущего выбранного профиля

This commit is contained in:
Gravit 2018-11-20 01:12:58 +07:00
parent 7c58959e24
commit 3b29043dca
No known key found for this signature in database
GPG key ID: 061981E1E85D3216

View file

@ -276,19 +276,24 @@ function updateProfilesList(profiles) {
profilesList = []; profilesList = [];
// Set profiles items // Set profiles items
serverList.getChildren().clear(); serverList.getChildren().clear();
var index = 0;
profiles.forEach(function (profile, i, arr) { profiles.forEach(function (profile, i, arr) {
pingers[profile.object] = new ServerPinger(profile.object.getServerSocketAddress(), profile.object.getVersion()); pingers[profile.object] = new ServerPinger(profile.object.getServerSocketAddress(), profile.object.getVersion());
var serverBtn = new javafx.scene.control.ToggleButton(profile); var serverBtn = new javafx.scene.control.ToggleButton(profile);
(function () { (function () {
profilesList[serverBtn] = profile; profilesList[serverBtn] = profile;
var hold = serverBtn; var hold = serverBtn;
var hIndex = index;
serverBtn.setOnAction(function (event) { serverBtn.setOnAction(function (event) {
serverHolder.set(hold); serverHolder.set(hold);
settings.profile = hIndex;
}); });
})(); })();
serverList.getChildren().add(serverBtn); serverList.getChildren().add(serverBtn);
index++;
}); });
serverHolder.set(serverList.getChildren().get(0)); LogHelper.debug("Load selected %d profile",settings.profile);
serverHolder.set(serverList.getChildren().get(settings.profile));
} }
function pingServer(btn) { function pingServer(btn) {