Skip to content

Commit

Permalink
Settings: Hide UDP port if UDP is disabled
Browse files Browse the repository at this point in the history
Closes #88
  • Loading branch information
christianTF committed Jul 12, 2021
1 parent d5a7000 commit 1082605
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions templates/mqtt.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<TMPL_VAR mslist_select_html>
</div>

<div data-role="fieldcontain">
<div data-role="fieldcontain" class="main_udpport_block">
<label for="Main.udpport">Miniserver UDP port</label>
<input name="Main.udpport" id="Main.udpport" type="text" />
<p class="hint">Default UDP port is <span class="mono">11883</span>. If UDP is enabled, data <i>from the broker</i> are sent to this udp port on the Miniserver.</p>
Expand Down Expand Up @@ -1332,6 +1332,10 @@ <h2 class='ui-bar ui-bar-a ui-corner-all' id='package_mqttgateway_mosquitto'>Mos
$('select').selectmenu('refresh', true);
$('input:checkbox').checkboxradio('refresh');

// Hide UDP block if UDP is disabled
if( ! $("#Main\\.use_udp").is(":checked") )
$(".main_udpport_block").hide();

// Set SecurePIN from session storage
$('#securepin').val(sessionStorage.getItem("securePIN"));
if( $('#securepin').val() ) {
Expand Down Expand Up @@ -1422,6 +1426,9 @@ <h2 class='ui-bar ui-bar-a ui-corner-all' id='package_mqttgateway_mosquitto'>Mos
var idarray = id.split(".");
if(inputType === "checkbox") {
cfg.Main[idarray[1]] = $(this).is(":checked");

// console.log("idarray", idarray[1]);

if(id == "Main.enable_mosquitto")
creds_changed = true;
if($(this).is(":checked")) {
Expand All @@ -1432,12 +1439,21 @@ <h2 class='ui-bar ui-bar-a ui-corner-all' id='package_mqttgateway_mosquitto'>Mos
$("#brokerpsk_block").fadeOut();
$("#brokerwebsocket_block").fadeOut();
}

if(id == "Main.use_udp") {
if( $(this).is(":checked") )
$(".main_udpport_block").fadeIn();
else
$(".main_udpport_block").fadeOut();
}


}
else if( inputType === "radio" ) {
// cfg.Main[idarray[1]] = $(this).is(":checked");
var namearray = $(this)[0].name.split(".");
cfg.Main[namearray[1]] = $(this).val();
cfg.Main[namearray[1]] = $(this).val();

}
else if ( idarray[1] == "websocketport" ) {
creds_changed = true;
Expand Down

0 comments on commit 1082605

Please sign in to comment.