Skip to content

Commit

Permalink
Preservative refresh of Connect URI on input
Browse files Browse the repository at this point in the history
To preserve unfamiliar parameters from aliases etc when a form field is
used to tweak the connection parameters.
  • Loading branch information
martinhpedersen committed May 1, 2024
1 parent 3521664 commit 7d43a6d
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions web/src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,26 +591,31 @@ function getConnectURL() { return $('#connectURLInput').val(); }
function setConnectURL(url) { $('#connectURLInput').val(url); }

function buildConnectURL() {
let url =
$('#transportSelect').val() + '://' + $('#addrInput').val() + '/' + $('#targetInput').val();

let params = '';

// Instead of building from scratch, we use the current URL as a starting
// point to retain URI parts not supported by the modal. The unsupported
// parts may originate from a connect alias or by manual edit of the URL
// field.
var current = getConnectURL()
let url = URI(current)
.protocol($('#transportSelect').val())
.hostname($('#addrInput').val())
.path($('#targetInput').val());
if ($('#freqInput').val() && $('#freqInput').parent().hasClass('has-success')) {
params += '&freq=' + $('#freqInput').val();
url = url.setQuery("freq", $('#freqInput').val());
} else {
url = url.removeQuery("freq");
}
if ($('#bandwidthInput').val()) {
params += '&bw=' + $('#bandwidthInput').val();
url = url.setQuery("bw", $('#bandwidthInput').val());
} else {
url = url.removeQuery("bw");
}
if ($('#radioOnlyInput').is(':checked')) {
params += '&radio_only=true';
}

if (params) {
url += params.replace('&', '?');
url = url.setQuery("radio_only", "true");
} else {
url = url.removeQuery("radio_only");
}

return url;
return url.build();
}

function onConnectFreqChange() {
Expand Down

0 comments on commit 7d43a6d

Please sign in to comment.