Skip to content

Commit

Permalink
www/caddy: Reduce scope of variables in javascript - replace var with…
Browse files Browse the repository at this point in the history
… let (opnsense#3956)

* Update general.volt - Reduce scope of variables

The declared variables are only used in the block, so the scope can be reduced from "var" to "let".

* Update reverse_proxy.volt

Replace var with let
  • Loading branch information
Monviech authored May 6, 2024
1 parent 71e78ac commit 045976e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@

<script type="text/javascript">
$(document).ready(function() {
var data_get_map = {'frm_GeneralSettings':"/api/caddy/General/get"};
let data_get_map = {'frm_GeneralSettings':"/api/caddy/General/get"};
mapDataToFormUI(data_get_map).done(function(data){

// Refresh selectpicker for these dropdowns
$('.selectpicker').selectpicker('refresh');

// Function to show alerts in the HTML message area
function showAlert(message, type = "error") {
var alertClass = type === "error" ? "alert-danger" : "alert-success";
var messageArea = $("#messageArea");
let alertClass = type === "error" ? "alert-danger" : "alert-success";
let messageArea = $("#messageArea");

// Stop any current animation, clear the queue, and immediately hide the element
messageArea.stop(true, true).hide();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

// Function to handle the search filter request modification
function addDomainFilterToRequest(request) {
var selectedDomains = $('#reverseFilter').val();
let selectedDomains = $('#reverseFilter').val();
if (selectedDomains && selectedDomains.length > 0) {
request['reverseUuids'] = selectedDomains.join(',');
}
Expand Down Expand Up @@ -99,8 +99,8 @@

// Function to show alerts in the HTML message area
function showAlert(message, type = "error") {
var alertClass = type === "error" ? "alert-danger" : "alert-success";
var messageArea = $("#messageArea");
let alertClass = type === "error" ? "alert-danger" : "alert-success";
let messageArea = $("#messageArea");

// Stop any current animation, clear the queue, and immediately hide the element
messageArea.stop(true, true).hide();
Expand Down Expand Up @@ -171,7 +171,7 @@
type: 'GET',
dataType: 'json',
success: function(data) {
var select = $('#reverseFilter');
let select = $('#reverseFilter');
select.empty(); // Clear current options
if (data && data.rows) {
data.rows.forEach(function(item) {
Expand Down Expand Up @@ -204,12 +204,12 @@
}

// Initialize visibility based on the active tab on page load
var activeTab = $('#maintabs .active a').attr('href').replace('#', '');
let activeTab = $('#maintabs .active a').attr('href').replace('#', '');
toggleSelectPicker(activeTab);

// Change event when switching tabs
$('#maintabs a').on('click', function (e) {
var currentTab = $(this).attr('href').replace('#', '');
let currentTab = $(this).attr('href').replace('#', '');
toggleSelectPicker(currentTab);
});

Expand Down

0 comments on commit 045976e

Please sign in to comment.