Updated remote access and flag JS

This commit is contained in:
John Crisp 2025-06-11 11:58:16 +02:00
parent 22fbb582d2
commit eb05438d80
2 changed files with 52 additions and 39 deletions

View File

@ -208,7 +208,7 @@ document.addEventListener('DOMContentLoaded', () => {
//if (!response.ok) throw new Error('Country not found');
//const data = await response.json();
//// Return the name in the native language
//return data[0].name.common;
//return data[0].name.common;
//} catch (error) {
//console.error(error);
//return 'Unknown Country';
@ -222,7 +222,7 @@ document.addEventListener('DOMContentLoaded', () => {
function getCountryCodeFromLanguage(language) {
return languageToCountryMap[language] ? languageToCountryMap[language].code : null;
}
function getCountryNameFromCountryCode(countryCode) {
//alert(`Country code: ${countryCode}`);
for (const language in languageToCountryMap) {
@ -263,11 +263,15 @@ document.addEventListener('DOMContentLoaded', () => {
function displayLocaleAndFlag() {
// Get the browser locale
const userLocale = navigator.language || navigator.userLanguage;
const userLocale = navigator.languages && navigator.languages.length
? navigator.languages[0]
: navigator.language;
//alert(`User Locale: ${userLocale}`); // Alert the detected locale
//console.log(navigator.languages); // Log language to console
const { flag, isUnknown, countryCode } = getFlagEmoji(userLocale);
//alert(`Country Code: ${countryCode}, Is Unknown: ${isUnknown}`); // Debug country code and unknown flag status
// Display the locale and the corresponding flag (or fallback)
@ -278,7 +282,7 @@ function displayLocaleAndFlag() {
fallbackDiv.className = 'fallback-box';
fallbackDiv.textContent = `? ${userLocale.toUpperCase()}`; // Show ? and locale code inside the box
document.getElementById('flag-container').appendChild(fallbackDiv);
// Tooltip for fallback
fallbackDiv.title = "Unknown Country"; // Tooltip for fallback
//alert('Fallback triggered: Unknown Country'); // Debug fallback
@ -290,7 +294,7 @@ function displayLocaleAndFlag() {
flagSpan.textContent = flag; // Use flag emoji
flagSpan.title = countryName; // Tooltip for the flag in country language
document.getElementById('flag-container').appendChild(flagSpan);
//alert(`Flag Emoji: ${flag}`); // Debug flag emoji display
}
}

View File

@ -24,12 +24,13 @@
<% my $btn = l('SAVE'); %>
<form action="/smanager/remoteaccess" method="POST">
% my $ipsec = $c->get_ipsecrw_status();
% if ( $ipsec ) {
<!-- reetp not tested -->
% if ( $ipsec) {
<h2><%= l 'rma_TITLE_IPSECRW' %></h2>
<div>
<%= l 'rma_DESC_IPSECRW' %>
@ -42,7 +43,7 @@
<%= text_field 'IpsecrwSess', class => "" %>
</div>
<br>
<div>
<%= $c->render_to_string(inline => $c->l('rma_DESC_IPSECRW_RESET')); %>
</div>
@ -56,14 +57,14 @@
<br><br>
<!--<hr class="" />-->
%}
% }
<!-- percequ include 'partials/_rma_pptp' -->
<h2><%= $c->l('rma_VALIDFROM_TITLE', $c->l('rma_REMOTE_MANAGEMENT')); %></h2>
<br>
<div>
<%= l 'rma_VALIDFROM_DESC' %>
</div>
@ -82,7 +83,7 @@
</tr>
</thead>
<tbody>
% foreach my $val ( @vals ) {
% my ($net, $mask) = split '/', $val;
% $mask = '255.255.255.255' unless ($mask);
@ -96,9 +97,9 @@
</td>
</tr>
% }
</tbody>
</table>
</table>
<!-- my @cbGroup = $q->checkbox_group(-name => 'validFromRemove',
-values => [@vals], -labels => { map {$_ => ''} @vals });
@ -109,16 +110,20 @@
<b><%= l('rma_NO_ENTRIES_YET'); %></b>
% }
<%= l 'rma_DESC_VALID_FROM_ENTRIES' %>
<br>
<div>
<%= l 'rma_DESC_VALID_FROM_ENTRIES' %>
</div>
<br><br>
<div class="row g-3 align-items-center">
<div class="col-md-2">
<%= l 'NETWORK' %>
<label for="inputNetwork" class="col-form-label"><%= l 'NETWORK' %></label>
</div>
<div class="col-auto">
<%= text_field 'ValidFromNetwork', class => "" %>
<input type="text" name="ValidFromNetwork" id="inputNetwork" class="form-control" aria-describedby="Network">
</div>
</div>
@ -126,19 +131,21 @@
<div class="row g-3 align-items-center">
<div class="col-md-2">
<%= l 'rma_SUBNET_MASK' %>
<label for="inputSubnetMask" class="col-form-label"><%= l 'rma_SUBNET_MASK' %></label>
</div>
<div class="col-auto">
<%= text_field 'ValidFromMask', class => "" %>
<input type="text" name="ValidFromMask" id="inputSubnetMask" class="form-control" aria-describedby="Subnet">
</div>
</div>
<!--<hr class="" />-->
<br><br>
<h2><%= l 'rma_TITLE_SSH' %></h2>
<br>
<div>
<%= l 'rma_DESC_SSH' %>
</div>
@ -156,7 +163,7 @@
</div>
<br>
<div class="row g-3 align-items-center">
<div class="col-md-2">
<%= l 'rma_LABEL_SSH_ADMIN' %>
@ -178,16 +185,16 @@
<%= select_field 'SshPasswordAuthentication' => [[(l 'NO'), 'no'], [(l 'YES'), 'yes']], class => "form-select" %>
</div>
</div>
<br>
<div class="row g-3 align-items-center">
<div class="col-md-2">
<%= l 'rma_LABEL_SSH_PORT' %>
<label for="inputSSHPort" class="col-form-label"><%= l 'rma_LABEL_SSH_PORT' %></label>
</div>
<div class="col-auto">
<div class="col-sm-1">
% param 'SshTCPPort' => $c->get_ssh_port() unless param 'SshTCPPort';
<%= text_field 'SshTCPPort' %>
<input type="text" name="SshTCPPort" id="inputSSHPort" class="form-control" aria-describedby="SSH Port" value="<%= $c->get_ssh_port() %>">
</div>
</div>
@ -195,12 +202,14 @@
<!--<hr class="" />-->
<br><br>
<h2><%= l 'rma_TITLE_FTP_ACCESS' %></h2>
<br>
<div>
<%= $c->render_to_string(inline => $c->l('rma_DESC_FTP_ACCESS')); %>
</div>
<br>
<div class="row g-3 align-items-center">
@ -212,16 +221,16 @@
<%= select_field 'FtpAccess' => $c->networkAccess_list(), class => "form-select" %>
</div>
</div>
<br>
<br>
<div>
<%= $c->render_to_string(inline => $c->l('rma_DESC_FTP_LOGIN')); %>
</div>
<br>
<div class="row g-3 align-items-center">
<div class="col-md-2">
<%= l 'rma_LABEL_FTP_LOGIN' %>
@ -237,19 +246,19 @@
% my $mode = $c->get_telnet_mode();
% if ( $mode ne 'off') {
<!--<hr class="" />-->
<h2><%= l 'rma_TITLE_TELNET_ACCESS' %></h2>
<br>
<div class="row g-3 align-items-center">
<div class="col-md-2">
<%= l 'rma_DESC_TELNET_ACCESS' %>
</div>
<div>
<br><br>
<div class="row g-3 align-items-center">
<div class="col-md-2">
<%= l 'rma_LABEL_TELNET_ACCESS' %>