From 8d408046ded31ba16d4569b4fc7d7d597aa3e504 Mon Sep 17 00:00:00 2001 From: Roman Hergenreder Date: Tue, 6 Apr 2021 17:39:21 +0200 Subject: [PATCH] install.js port fix --- js/install.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/js/install.js b/js/install.js index 174ffd3..64789c2 100644 --- a/js/install.js +++ b/js/install.js @@ -138,22 +138,26 @@ $(document).ready(function() { }); // DATABASE PORT - let prevPort = $("#port").val(); - let prevDbms = $("#type option:selected").val(); + let portField = $("#port"); + let typeField = $("#type"); + + let prevPort = parseInt(portField.val()); + let prevDbms = typeField.find("option:selected").val(); function updateDefaultPort() { let defaultPorts = { "mysql": 3306, "postgres": 5432 }; - let curDbms = $("#type option:selected").val(); + let curDbms = typeField.find("option:selected").val(); if(defaultPorts[prevDbms] === prevPort) { - $("#port").val(defaultPorts[curDbms]); + prevDbms = curDbms; + portField.val(prevPort = defaultPorts[curDbms]); } } updateDefaultPort(); - $("#type").change(function() { + typeField.change(function() { updateDefaultPort(); }); });