1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-26 22:13:53 +01:00
Files
fm-dx-webserver/web/js/init.js
2024-09-12 21:30:12 +02:00

39 lines
1.5 KiB
JavaScript

var currentDate = new Date('Sep 12, 2024 21:30:00');
var day = currentDate.getDate();
var month = currentDate.getMonth() + 1; // Months are zero-indexed, so add 1
var year = currentDate.getFullYear();
var formattedDate = day + '/' + month + '/' + year;
var currentVersion = 'v1.2.8.1 [' + formattedDate + ']';
getInitialSettings();
removeUrlParameters(); // Call this function to remove URL parameters
function getInitialSettings() {
$.ajax({
url: './static_data',
dataType: 'json',
success: function (data) {
localStorage.setItem('qthLatitude', data.qthLatitude);
localStorage.setItem('qthLongitude', data.qthLongitude);
localStorage.setItem('defaultTheme', data.defaultTheme);
localStorage.setItem('preset1', data.presets[0]);
localStorage.setItem('preset2', data.presets[1]);
localStorage.setItem('preset3', data.presets[2]);
localStorage.setItem('preset4', data.presets[3]);
localStorage.setItem('bgImage', data.bgImage);
localStorage.setItem('rdsMode', data.rdsMode);
},
error: function (error) {
console.error('Error:', error);
}
});
}
function removeUrlParameters() {
// Get the current URL without the query parameters
var urlWithoutParams = window.location.protocol + "//" + window.location.host + window.location.pathname;
// Replace the current URL with the new one, without reloading the page
window.history.replaceState({ path: urlWithoutParams }, '', urlWithoutParams);
}