mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-19 19:59:13 +03:00
Use const instead of var for js variables
This commit is contained in:
parent
9617425033
commit
680e73c990
4 changed files with 38 additions and 38 deletions
|
@ -121,7 +121,7 @@ Wireguard Clients
|
|||
{{define "bottom_js"}}
|
||||
<script>
|
||||
function setClientStatus(clientID, status) {
|
||||
var data = {"id": clientID, "status": status}
|
||||
const data = {"id": clientID, "status": status};
|
||||
$.ajax({
|
||||
cache: false,
|
||||
method: 'POST',
|
||||
|
@ -133,7 +133,7 @@ Wireguard Clients
|
|||
console.log("Set client " + clientID + " status to " + status)
|
||||
},
|
||||
error: function (jqXHR, exception) {
|
||||
var responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||
const responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||
toastr.error(responseJson['message']);
|
||||
}
|
||||
});
|
||||
|
@ -141,23 +141,23 @@ Wireguard Clients
|
|||
|
||||
function resumeClient(clientID) {
|
||||
setClientStatus(clientID, true);
|
||||
var divElement = document.getElementById("paused_" + clientID);
|
||||
const divElement = document.getElementById("paused_" + clientID);
|
||||
divElement.style.visibility = "hidden";
|
||||
}
|
||||
|
||||
function pauseClient(clientID) {
|
||||
setClientStatus(clientID, false);
|
||||
var divElement = document.getElementById("paused_" + clientID);
|
||||
const divElement = document.getElementById("paused_" + clientID);
|
||||
divElement.style.visibility = "visible";
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
// modal_pause_client modal event
|
||||
$('#modal_pause_client').on('show.bs.modal', function (event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var client_id = button.data('clientid');
|
||||
var client_name = button.data('clientname');
|
||||
var modal = $(this);
|
||||
const button = $(event.relatedTarget);
|
||||
const client_id = button.data('clientid');
|
||||
const client_name = button.data('clientname');
|
||||
const modal = $(this);
|
||||
modal.find('.modal-body').text("You are about to disable client " + client_name);
|
||||
modal.find('#pause_client_confirm').val(client_id);
|
||||
})
|
||||
|
@ -165,7 +165,7 @@ Wireguard Clients
|
|||
// pause_client_confirm button event
|
||||
$(document).ready(function () {
|
||||
$('#pause_client_confirm').click(function () {
|
||||
var client_id = $(this).val();
|
||||
const client_id = $(this).val();
|
||||
pauseClient(client_id);
|
||||
$('#modal_pause_client').modal('hide');
|
||||
});
|
||||
|
@ -173,10 +173,10 @@ Wireguard Clients
|
|||
|
||||
// modal_remove_client modal event
|
||||
$('#modal_remove_client').on('show.bs.modal', function (event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var client_id = button.data('clientid');
|
||||
var client_name = button.data('clientname');
|
||||
var modal = $(this);
|
||||
const button = $(event.relatedTarget);
|
||||
const client_id = button.data('clientid');
|
||||
const client_name = button.data('clientname');
|
||||
const modal = $(this);
|
||||
modal.find('.modal-body').text("You are about to remove client " + client_name);
|
||||
modal.find('#remove_client_confirm').val(client_id);
|
||||
})
|
||||
|
@ -184,8 +184,8 @@ Wireguard Clients
|
|||
// remove_client_confirm button event
|
||||
$(document).ready(function () {
|
||||
$('#remove_client_confirm').click(function () {
|
||||
var client_id = $(this).val();
|
||||
var data = {"id": client_id};
|
||||
const client_id = $(this).val();
|
||||
const data = {"id": client_id};
|
||||
$.ajax({
|
||||
cache: false,
|
||||
method: 'POST',
|
||||
|
@ -196,11 +196,11 @@ Wireguard Clients
|
|||
success: function(data) {
|
||||
$('#modal_remove_client').modal('hide');
|
||||
toastr.success('Removed client successfully');
|
||||
var divElement = document.getElementById('client_' + client_id);
|
||||
const divElement = document.getElementById('client_' + client_id);
|
||||
divElement.style.display = "none";
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
var responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||
const responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||
toastr.error(responseJson['message']);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -106,12 +106,12 @@ Global Settings
|
|||
{{define "bottom_js"}}
|
||||
<script>
|
||||
function submitGlobalSettings() {
|
||||
var endpoint_address = $("#endpoint_address").val();
|
||||
var dns_servers = $("#dns_servers").val().split(",");
|
||||
var mtu = $("#mtu").val();
|
||||
var persistent_keepalive = $("#persistent_keepalive").val();
|
||||
var config_file_path = $("#config_file_path").val();
|
||||
var data = {"endpoint_address": endpoint_address, "dns_servers": dns_servers, "mtu": mtu, "persistent_keepalive": persistent_keepalive, "config_file_path": config_file_path};
|
||||
const endpoint_address = $("#endpoint_address").val();
|
||||
const dns_servers = $("#dns_servers").val().split(",");
|
||||
const mtu = $("#mtu").val();
|
||||
const persistent_keepalive = $("#persistent_keepalive").val();
|
||||
const config_file_path = $("#config_file_path").val();
|
||||
const data = {"endpoint_address": endpoint_address, "dns_servers": dns_servers, "mtu": mtu, "persistent_keepalive": persistent_keepalive, "config_file_path": config_file_path};
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
|
@ -125,7 +125,7 @@ Global Settings
|
|||
toastr.success('Update global settings successfully');
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
var responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||
const responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||
toastr.error(responseJson['message']);
|
||||
}
|
||||
});
|
||||
|
@ -223,7 +223,7 @@ Global Settings
|
|||
// Use selected IP address from suggestion form
|
||||
$(document).ready(function () {
|
||||
$('#btn_use_ip').click(function () {
|
||||
var ip = $('#ip_suggestion').select2('val');
|
||||
const ip = $('#ip_suggestion').select2('val');
|
||||
$('#endpoint_address').val(ip);
|
||||
$('#modal_endpoint_address_suggestion').modal('hide');
|
||||
});
|
||||
|
|
|
@ -80,8 +80,8 @@
|
|||
</body>
|
||||
<script>
|
||||
function redirectNext() {
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
var nextURL = urlParams.get('next');
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const nextURL = urlParams.get('next');
|
||||
if (nextURL) {
|
||||
window.location.href = nextURL;
|
||||
} else {
|
||||
|
@ -92,9 +92,9 @@
|
|||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#btn_login').click(function () {
|
||||
var username = $("#username").val();
|
||||
var password = $("#password").val();
|
||||
var data = {"username": username, "password": password}
|
||||
const username = $("#username").val();
|
||||
const password = $("#password").val();
|
||||
const data = {"username": username, "password": password}
|
||||
console.log(data);
|
||||
|
||||
$.ajax({
|
||||
|
@ -110,7 +110,7 @@
|
|||
redirectNext();
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
var responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||
const responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||
document.getElementById("message").innerHTML = '<p style="color:red">' + responseJson['message'] + '</p>';
|
||||
}
|
||||
});
|
||||
|
|
|
@ -117,9 +117,9 @@ Wireguard Server Settings
|
|||
{{define "bottom_js"}}
|
||||
<script>
|
||||
function submitServerInterfaceSetting() {
|
||||
var addresses = $("#addresses").val().split(",");
|
||||
var listen_port = $("#listen_port").val();
|
||||
var data = {"addresses": addresses, "listen_port": listen_port};
|
||||
const addresses = $("#addresses").val().split(",");
|
||||
const listen_port = $("#listen_port").val();
|
||||
const data = {"addresses": addresses, "listen_port": listen_port};
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
|
@ -133,7 +133,7 @@ Wireguard Server Settings
|
|||
toastr.success('Updated Wireguard server interface addresses successfully');
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
var responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||
const responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||
toastr.error(responseJson['message']);
|
||||
}
|
||||
});
|
||||
|
@ -210,7 +210,7 @@ Wireguard Server Settings
|
|||
$('#public_key').val(data['public_key']);
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
var responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||
const responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||
toastr.error(responseJson['message']);
|
||||
}
|
||||
});
|
||||
|
@ -220,8 +220,8 @@ Wireguard Server Settings
|
|||
// Show private key button event
|
||||
$(document).ready(function () {
|
||||
$('#btn_show_private_key').click(function () {
|
||||
var privateElement = document.getElementById("private_key");
|
||||
var btnElement = document.getElementById("btn_show_private_key");
|
||||
const privateElement = document.getElementById("private_key");
|
||||
const btnElement = document.getElementById("btn_show_private_key");
|
||||
if (privateElement.type === 'password') {
|
||||
privateElement.type = 'text';
|
||||
btnElement.innerText = 'Hide';
|
||||
|
|
Loading…
Add table
Reference in a new issue