1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-26 22:13:53 +01:00

some changes

This commit is contained in:
2026-02-24 15:03:56 +01:00
parent 648ef00bed
commit 5d524eba56
15 changed files with 316 additions and 378 deletions

View File

@@ -193,8 +193,7 @@ function handleData(wss, receivedData, rdsWss) {
data += (((errors & 0x03) == 0) ? modifiedData.slice(12, 16) : '----'); data += (((errors & 0x03) == 0) ? modifiedData.slice(12, 16) : '----');
const newDataString = "G:\r\n" + data + "\r\n\r\n"; const newDataString = "G:\r\n" + data + "\r\n\r\n";
const finalBuffer = Buffer.from(newDataString, 'utf-8'); client.send(newDataString);
client.send(finalBuffer);
}); });
rdsdec.decodeGroup(parseInt(modifiedData.slice(0, 4), 16), parseInt(modifiedData.slice(4, 8), 16), parseInt(modifiedData.slice(8, 12), 16), parseInt(modifiedData.slice(12, 16), 16)); rdsdec.decodeGroup(parseInt(modifiedData.slice(0, 4), 16), parseInt(modifiedData.slice(4, 8), 16), parseInt(modifiedData.slice(8, 12), 16), parseInt(modifiedData.slice(12, 16), 16));

View File

@@ -27,11 +27,8 @@ function destroyStream() {
function OnConnectivityCallback(isConnected) { function OnConnectivityCallback(isConnected) {
console.log("Connectivity changed:", isConnected); console.log("Connectivity changed:", isConnected);
if (Stream) { if (Stream) Stream.Volume = $('#volumeSlider').val();
Stream.Volume = $('#volumeSlider').val(); else console.warn("Stream is not initialized.");
} else {
console.warn("Stream is not initialized.");
}
} }
@@ -44,18 +41,14 @@ function OnPlayButtonClick(_ev) {
shouldReconnect = false; shouldReconnect = false;
destroyStream(); destroyStream();
$playbutton.find('.fa-solid').toggleClass('fa-stop fa-play'); $playbutton.find('.fa-solid').toggleClass('fa-stop fa-play');
if (isAppleiOS && 'audioSession' in navigator) { if (isAppleiOS && 'audioSession' in navigator) navigator.audioSession.type = "none";
navigator.audioSession.type = "none";
}
} else { } else {
console.log("Starting stream..."); console.log("Starting stream...");
shouldReconnect = true; shouldReconnect = true;
createStream(); createStream();
Stream.Start(); Stream.Start();
$playbutton.find('.fa-solid').toggleClass('fa-play fa-stop'); $playbutton.find('.fa-solid').toggleClass('fa-play fa-stop');
if (isAppleiOS && 'audioSession' in navigator) { if (isAppleiOS && 'audioSession' in navigator) navigator.audioSession.type = "playback";
navigator.audioSession.type = "playback";
}
} }
$playbutton.addClass('bg-gray').prop('disabled', true); $playbutton.addClass('bg-gray').prop('disabled', true);
@@ -70,9 +63,7 @@ function updateVolume() {
newVolumeGlobal = newVolume; newVolumeGlobal = newVolume;
console.log("Volume updated to:", newVolume); console.log("Volume updated to:", newVolume);
Stream.Volume = newVolume; Stream.Volume = newVolume;
} else { } else console.warn("Stream is not initialized.");
console.warn("Stream is not initialized.");
}
} }
$(document).ready(Init); $(document).ready(Init);

View File

@@ -3,18 +3,13 @@ function tuneUp() {
if (socket.readyState === WebSocket.OPEN) { if (socket.readyState === WebSocket.OPEN) {
getCurrentFreq(); getCurrentFreq();
let addVal = 0; let addVal = 0;
if (currentFreq < 0.52) { if (currentFreq < 0.52) addVal = 9 - (Math.round(currentFreq*1000) % 9);
addVal = 9 - (Math.round(currentFreq*1000) % 9); else if (currentFreq < 1.71) {
} else if (currentFreq < 1.71) {
// TODO: Rework to replace 9 with 9 or 10 based on regionalisation setting // TODO: Rework to replace 9 with 9 or 10 based on regionalisation setting
addVal = 9 - (Math.round(currentFreq*1000) % 9); addVal = 9 - (Math.round(currentFreq*1000) % 9);
} else if (currentFreq < 29.6) { } else if (currentFreq < 29.6) addVal = 5 - (Math.round(currentFreq*1000) % 5);
addVal = 5 - (Math.round(currentFreq*1000) % 5); else if (currentFreq >= 65.9 && currentFreq < 74) addVal = 30 - ((Math.round(currentFreq*1000) - 65900) % 30);
} else if (currentFreq >= 65.9 && currentFreq < 74) { else addVal = 100 - (Math.round(currentFreq*1000) % 100);
addVal = 30 - ((Math.round(currentFreq*1000) - 65900) % 30);
} else {
addVal = 100 - (Math.round(currentFreq*1000) % 100);
}
socket.send("T" + (Math.round(currentFreq*1000) + addVal)); socket.send("T" + (Math.round(currentFreq*1000) + addVal));
} }
} }
@@ -23,18 +18,13 @@ function tuneDown() {
if (socket.readyState === WebSocket.OPEN) { if (socket.readyState === WebSocket.OPEN) {
getCurrentFreq(); getCurrentFreq();
let subVal = 0; let subVal = 0;
if (currentFreq < 0.52) { if (currentFreq < 0.52) subVal = (Math.round(currentFreq*1000) % 9 == 0) ? 9 : (Math.round(currentFreq*1000) % 9);
else if (currentFreq < 1.71) {
// TODO: Rework to replace 9 with 9 or 10 based on regionalisation setting (Americans use 10, because of dumbfuckinstan)
subVal = (Math.round(currentFreq*1000) % 9 == 0) ? 9 : (Math.round(currentFreq*1000) % 9); subVal = (Math.round(currentFreq*1000) % 9 == 0) ? 9 : (Math.round(currentFreq*1000) % 9);
} else if (currentFreq < 1.71) { } else if (currentFreq < 29.6) subVal = (Math.round(currentFreq*1000) % 5 == 0) ? 5 : (Math.round(currentFreq*1000) % 5);
// TODO: Rework to replace 9 with 9 or 10 based on regionalisation setting else if (currentFreq > 65.9 && currentFreq <= 74) subVal = ((Math.round(currentFreq*1000) - 65900) % 30 == 0) ? 30 : ((Math.round(currentFreq*1000) - 65900) % 30);
subVal = (Math.round(currentFreq*1000) % 9 == 0) ? 9 : (Math.round(currentFreq*1000) % 9); else subVal = (Math.round(currentFreq*1000) % 100 == 0) ? 100 : (Math.round(currentFreq*1000) % 100);
} else if (currentFreq < 29.6) {
subVal = (Math.round(currentFreq*1000) % 5 == 0) ? 5 : (Math.round(currentFreq*1000) % 5);
} else if (currentFreq > 65.9 && currentFreq <= 74) {
subVal = ((Math.round(currentFreq*1000) - 65900) % 30 == 0) ? 30 : ((Math.round(currentFreq*1000) - 65900) % 30);
} else {
subVal = (Math.round(currentFreq*1000) % 100 == 0) ? 100 : (Math.round(currentFreq*1000) % 100);
}
socket.send("T" + (Math.round(currentFreq*1000) - subVal)); socket.send("T" + (Math.round(currentFreq*1000) - subVal));
} }
} }

View File

@@ -19,9 +19,7 @@ $(document).ready(function() {
function generateRandomString(length) { function generateRandomString(length) {
const characters = 'ABCDEFGHJKMNOPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz0123456789'; const characters = 'ABCDEFGHJKMNOPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz0123456789';
let result = ''; let result = '';
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) result += characters.charAt(Math.floor(Math.random() * characters.length));
result += characters.charAt(Math.floor(Math.random() * characters.length));
}
return result; return result;
} }
@@ -87,9 +85,7 @@ $(document).ready(function() {
}); });
chatSendInput.keypress(function(event) { chatSendInput.keypress(function(event) {
if (event.which === 13) { if (event.which === 13) sendMessage();
sendMessage();
}
}); });
function sendMessage() { function sendMessage() {

View File

@@ -38,9 +38,7 @@ function fetchConfig() {
function populateFields(data, prefix = "") { function populateFields(data, prefix = "") {
$.each(data, (key, value) => { $.each(data, (key, value) => {
if (value === null) { if (value === null) value = ""; // Convert null to an empty string
value = ""; // Convert null to an empty string
}
let id = `${prefix}${prefix ? "-" : ""}${key}`; let id = `${prefix}${prefix ? "-" : ""}${key}`;
const $element = $(`#${id}`); const $element = $(`#${id}`);
@@ -50,11 +48,8 @@ function populateFields(data, prefix = "") {
$element.find('option').each(function() { $element.find('option').each(function() {
const $option = $(this); const $option = $(this);
const dataName = $option.data('name'); const dataName = $option.data('name');
if (value.includes(dataName)) { if (value.includes(dataName)) $option.prop('selected', true);
$option.prop('selected', true); else $option.prop('selected', false);
} else {
$option.prop('selected', false);
}
}); });
$element.trigger('change'); $element.trigger('change');
@@ -68,11 +63,8 @@ function populateFields(data, prefix = "") {
const arrayId = `${id}-${index + 1}`; const arrayId = `${id}-${index + 1}`;
const $arrayElement = $(`#${arrayId}`); const $arrayElement = $(`#${arrayId}`);
if ($arrayElement.length) { if ($arrayElement.length) $arrayElement.val(item);
$arrayElement.val(item); else console.log(`Element with id ${arrayId} not found`);
} else {
console.log(`Element with id ${arrayId} not found`);
}
}); });
return; return;
} else { } else {
@@ -92,9 +84,7 @@ function populateFields(data, prefix = "") {
const $dropdownOption = $element.siblings('ul.options').find(`li[data-value="${value}"]`); const $dropdownOption = $element.siblings('ul.options').find(`li[data-value="${value}"]`);
$element.val($dropdownOption.length ? $dropdownOption.text() : value); $element.val($dropdownOption.length ? $dropdownOption.text() : value);
$element.attr('data-value', value); $element.attr('data-value', value);
} else { } else $element.val(value);
$element.val(value);
}
}); });
} }
@@ -111,9 +101,7 @@ function updateConfigData(data, prefix = "") {
if ($presetElement.length) { if ($presetElement.length) {
data[key].push($presetElement.val() || null); // Allow null if necessary data[key].push($presetElement.val() || null); // Allow null if necessary
index++; index++;
} else { } else break;
break;
}
} }
return; return;
} }
@@ -123,16 +111,12 @@ function updateConfigData(data, prefix = "") {
const $selectedOptions = $element.find('option:selected'); const $selectedOptions = $element.find('option:selected');
$selectedOptions.each(function() { $selectedOptions.each(function() {
const dataName = $(this).attr('data-name'); const dataName = $(this).attr('data-name');
if (dataName) { if (dataName) data[key].push(dataName);
data[key].push(dataName);
}
}); });
return; return;
} }
if (typeof value === "object" && value !== null && !Array.isArray(value)) { if (typeof value === "object" && value !== null && !Array.isArray(value)) return updateConfigData(value, id);
return updateConfigData(value, id);
}
if ($element.length) { if ($element.length) {
const newValue = $element.attr("data-value") ?? $element.val() ?? null; const newValue = $element.attr("data-value") ?? $element.val() ?? null;

View File

@@ -106,9 +106,7 @@ $(document).ready(function() {
$listOfOptions.on('click', selectOption); $listOfOptions.on('click', selectOption);
$dropdowns.on('click', 'input', toggleDropdown); $dropdowns.on('click', 'input', toggleDropdown);
$dropdowns.on('keydown', 'input', function(event) { $dropdowns.on('keydown', 'input', function(event) {
if (event.key === 'Enter') { if (event.key === 'Enter') toggleDropdown(event);
toggleDropdown(event);
}
}); });
$dropdowns.on('keydown', '.option', navigateOptions); $dropdowns.on('keydown', '.option', navigateOptions);

View File

@@ -1028,15 +1028,10 @@ const updateDataElements = throttle(function(parsedData) {
updateHtmlIfChanged($('#alternative-txes'), altTxInfo); updateHtmlIfChanged($('#alternative-txes'), altTxInfo);
updateTextIfChanged($('#data-station-distance'), txDistance); updateTextIfChanged($('#data-station-distance'), txDistance);
$dataStationContainer.css('display', 'block'); $dataStationContainer.css('display', 'block');
} else { } else $dataStationContainer.removeAttr('style');
$dataStationContainer.removeAttr('style');
}
if(parsedData.txInfo.tx.length > 1 && parsedData.txInfo.dist > 150 && parsedData.txInfo.dist < 4000) { if(parsedData.txInfo.tx.length > 1 && parsedData.txInfo.dist > 150 && parsedData.txInfo.dist < 4000) $('.log-fmlist').removeAttr('disabled').removeClass('btn-disabled cursor-disabled');
$('.log-fmlist').removeAttr('disabled').removeClass('btn-disabled cursor-disabled'); else $('.log-fmlist').attr('disabled', 'true').addClass('btn-disabled cursor-disabled');
} else {
$('.log-fmlist').attr('disabled', 'true').addClass('btn-disabled cursor-disabled');
}
updateHtmlIfChanged($('#data-regular-pi'), parsedData.txInfo.reg === true ? parsedData.txInfo.pi : '&nbsp;'); updateHtmlIfChanged($('#data-regular-pi'), parsedData.txInfo.reg === true ? parsedData.txInfo.pi : '&nbsp;');
if (updateCounter % 8 === 0) { if (updateCounter % 8 === 0) {
@@ -1084,7 +1079,6 @@ function updatePanels(parsedData) {
} }
if (updateCounter % 3 === 0) { if (updateCounter % 3 === 0) {
updateButtonState("data-eq", parsedData.eq); updateButtonState("data-eq", parsedData.eq);
updateButtonState("data-ims", parsedData.ims); updateButtonState("data-ims", parsedData.ims);
@@ -1288,4 +1282,3 @@ function initTooltips(target = null) {
$('#preset1').parent().hide(); $('#preset1').parent().hide();
} }
} }

View File

@@ -31,15 +31,11 @@ $(document).ready(function() {
$(document).on("click", function(event) { // Close the modal when clicking outside of it $(document).on("click", function(event) { // Close the modal when clicking outside of it
if ($(event.target).is(modal)) { if ($(event.target).is(modal)) closeModal();
closeModal();
}
}); });
$(document).on("keydown", function(event) { // Close the modal when pressing ESC key $(document).on("keydown", function(event) { // Close the modal when pressing ESC key
if (event.key === "Escape") { if (event.key === "Escape") closeModal();
closeModal();
}
}); });
$(".tuner-mobile-settings").on("click", function () { $(".tuner-mobile-settings").on("click", function () {
@@ -69,9 +65,8 @@ function initPopups() {
function togglePopup(targetSelector) { function togglePopup(targetSelector) {
const $target = $(targetSelector); const $target = $(targetSelector);
if ($target.is(":visible")) { if ($target.is(":visible")) $target.fadeOut(200);
$target.fadeOut(200); else {
} else {
$(".popup-window").fadeOut(200); $(".popup-window").fadeOut(200);
$target.fadeIn(200); $target.fadeIn(200);
} }

View File

@@ -189,9 +189,7 @@ function loadInitialSettings() {
if(signalParameter && !localStorage.getItem('signalUnit')) { if(signalParameter && !localStorage.getItem('signalUnit')) {
signalSelector.find('input').val(signalSelector.find('.option[data-value="' + signalParameter + '"]').text()); signalSelector.find('input').val(signalSelector.find('.option[data-value="' + signalParameter + '"]').text());
localStorage.setItem('signalUnit', signalParameter); localStorage.setItem('signalUnit', signalParameter);
} else { } else signalSelector.find('input').val(signalSelector.find('.option[data-value="' + savedUnit + '"]').text());
signalSelector.find('input').val(signalSelector.find('.option[data-value="' + savedUnit + '"]').text());
}
signalSelector.on('click', '.option', (event) => { signalSelector.on('click', '.option', (event) => {
const selectedSignalUnit = $(event.target).data('value'); const selectedSignalUnit = $(event.target).data('value');

View File

@@ -27,9 +27,7 @@ function mapCreate() {
zoom: 3, zoom: 3,
worldCopyJump: true worldCopyJump: true
}); });
} else { } else map.setZoom(3).panTo([40, 0]);
map.setZoom(3).panTo([40, 0]);
}
L.tileLayer(tilesURL, { L.tileLayer(tilesURL, {
attribution: mapAttrib, attribution: mapAttrib,
@@ -272,9 +270,7 @@ function checkTunnelServers() {
// If this li is the currently selected one, update input text too // If this li is the currently selected one, update input text too
// Note: input.val() holds the label, so match by label is safer // Note: input.val() holds the label, so match by label is safer
if ($li.text() === selectedValue || server.value === selectedValue) { if ($li.text() === selectedValue || server.value === selectedValue) $input.val(server.label);
$input.val(server.label);
}
} }
}); });
}, },

View File

@@ -27,8 +27,6 @@ function navigateStep(isNext) {
currentStep.hide(); currentStep.hide();
targetStep.show(); targetStep.show();
updateProgressBar(targetStep); updateProgressBar(targetStep);
} else if (isNext) { } else if (isNext) submitConfig();
submitConfig();
}
updateWizardContent(); updateWizardContent();
} }