1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-27 06:23:53 +01:00
This commit is contained in:
NoobishSVK
2024-02-19 21:49:20 +01:00
parent bc7a3ddf48
commit 2d59684c3f
5 changed files with 73 additions and 48 deletions

View File

@@ -150,7 +150,7 @@ var AudioFormatReader = /** @class */ (function () {
// Theoretical minimum is 2.
// Recommended value is 3 or higher.
if (isAndroid)
settings["mpeg"]["MinDecodeFrames"] = 17;
settings["mpeg"]["MinDecodeFrames"] = 3;
else
settings["mpeg"]["MinDecodeFrames"] = 3;
return settings;

18
web/js/init.js Normal file
View File

@@ -0,0 +1,18 @@
getInitialSettings();
function getInitialSettings() {
$.ajax({
url: './static_data',
dataType: 'json',
success: function (data) {
// Use the received data (data.qthLatitude, data.qthLongitude) as needed
localStorage.setItem('qthLatitude', data.qthLatitude);
localStorage.setItem('qthLongitude', data.qthLongitude);
localStorage.setItem('audioPort', data.audioPort);
localStorage.setItem('streamEnabled', data.streamEnabled);
},
error: function (error) {
console.error('Error:', error);
}
});
}

View File

@@ -24,7 +24,6 @@ $(document).ready(function () {
canvas.width = canvas.parentElement.clientWidth;
canvas.height = canvas.parentElement.clientHeight;
getInitialSettings();
// Start updating the canvas
initCanvas();
@@ -156,47 +155,45 @@ $(document).ready(function () {
});
});
function getInitialSettings() {
$.ajax({
url: './static_data',
dataType: 'json',
success: function (data) {
// Use the received data (data.qthLatitude, data.qthLongitude) as needed
localStorage.setItem('qthLatitude', data.qthLatitude);
localStorage.setItem('qthLongitude', data.qthLongitude);
localStorage.setItem('audioPort', data.audioPort);
localStorage.setItem('streamEnabled', data.streamEnabled);
},
error: function (error) {
console.error('Error:', error);
}
});
}
function getLocalizedTime(serverTime) {
const serverDate = new Date(serverTime);
// Format server time using options for local time formatting
const options = { year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', hour12: false };
const formattedServerTime = serverDate.toLocaleString(navigator.language ? navigator.language : 'en-US', options);
return formattedServerTime;
}
function getServerTime() {
$.ajax({
url: './server_time',
dataType: 'json',
success: function (data) {
$('#server-time').text(getLocalizedTime(data.serverTime));
$('#client-time').text(getLocalizedTime(new Date()));
},
error: function (error) {
console.error('Error:', error);
}
url: "/server_time",
dataType: "json",
success: function(data) {
const serverTimeUtc = data.serverTime;
const options = {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
hour12: false
};
const serverOptions = {
...options,
timeZone: 'Etc/UTC' // Add timeZone only for server time
};
const formattedServerTime = new Date(serverTimeUtc).toLocaleString(navigator.language ? navigator.language : 'en-US', serverOptions);
$("#server-time").text(formattedServerTime);
// Get and format user's local time directly without specifying timeZone:
const localTime = new Date();
const formattedLocalTime = new Date(localTime).toLocaleString(navigator.language ? navigator.language : 'en-US', options);
// Display client time:
$("#client-time").text(formattedLocalTime);
},
error: function(jqXHR, textStatus, errorThrown) {
console.error("Error fetching server time:", errorThrown);
// Handle error gracefully (e.g., display a fallback message)
}
});
}
}
function sendPingRequest() {
const startTime = new Date().getTime();
@@ -596,7 +593,6 @@ function updateDataElements(parsedData) {
$('.data-st').html("<span class='opacity-half'>ST</span>");
}
}
console.log(parsedData.st, parsedData.st_forced);
$('#data-rt0').html(processString(parsedData.rt0, parsedData.rt0_errors));
$('#data-rt1').html(processString(parsedData.rt1, parsedData.rt1_errors));