diff --git a/.gitignore b/.gitignore index 03f42a7..aa29cb0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ node_modules/ /*.json -/ffmpeg.exe /serverlog.txt -/web/js/plugins/ \ No newline at end of file +/web/js/plugins/ +/plugins/* +!/plugins/example/frontend.js +!/plugins/example.js \ No newline at end of file diff --git a/index.js b/index.js index adba7f8..d0ed3bb 100644 --- a/index.js +++ b/index.js @@ -6,4 +6,5 @@ require('./server/index.js'); * Github repo: https://github.com/NoobishSVK/fm-dx-webserver * Server files: /server * Client files (web): /web + * Plugin files: /plugins */ \ No newline at end of file diff --git a/package.json b/package.json index 69b381b..03732ae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fm-dx-webserver", - "version": "1.2.5", + "version": "1.2.6", "description": "FM DX Webserver", "main": "index.js", "scripts": { diff --git a/server/datahandler.js b/server/datahandler.js index 60bce67..337bc9f 100644 --- a/server/datahandler.js +++ b/server/datahandler.js @@ -205,12 +205,13 @@ const updateInterval = 75; var dataToSend = { pi: '?', freq: 87.500.toFixed(3), - previousFreq: 87.500.toFixed(3), - signal: 0, - highestSignal: -Infinity, + prevFreq: 87.500.toFixed(3), + sig: 0, + sigRaw: '', + sigTop: -Infinity, bw: 0, st: false, - st_forced: false, + stForced: false, rds: false, ps: '', tp: 0, @@ -224,13 +225,14 @@ var dataToSend = { eq: 0, ant: 0, txInfo: { - station: '', + tx: '', pol: '', erp: '', city: '', itu: '', - distance: '', - azimuth: '' + dist: '', + azi: '', + id: '' }, country_name: '', country_iso: 'UN', @@ -251,7 +253,7 @@ const initialData = { ...dataToSend }; const resetToDefault = dataToSend => Object.assign(dataToSend, initialData); -function handleData(wss, receivedData) { +function handleData(wss, receivedData, rdsWss) { // Retrieve the last update time for this client const currentTime = Date.now(); @@ -350,6 +352,10 @@ function handleData(wss, receivedData) { modifiedData += errorsNew.toString(16).padStart(2, '0'); } + rdsWss.clients.forEach((client) => { // Send to /rds endpoint via WebSocket + client.send(modifiedData); + }); + rdsparser.parse_string(rds, modifiedData); legacyRdsPiBuffer = null; break; @@ -360,13 +366,14 @@ function handleData(wss, receivedData) { const currentTx = fetchTx(parseFloat(dataToSend.freq).toFixed(1), dataToSend.pi, dataToSend.ps); if(currentTx && currentTx.station !== undefined) { dataToSend.txInfo = { - station: currentTx.station, + tx: currentTx.station, pol: currentTx.pol, erp: currentTx.erp, city: currentTx.city, itu: currentTx.itu, - distance: currentTx.distance, - azimuth: currentTx.azimuth + dist: currentTx.distance, + azi: currentTx.azimuth, + id: currentTx.id } } @@ -389,20 +396,22 @@ function processSignal(receivedData, st, stForced) { const modifiedData = receivedData.substring(2); const parsedValue = parseFloat(modifiedData); dataToSend.st = st; - dataToSend.st_forced = stForced; + dataToSend.stForced = stForced; initialData.st = st; - initialData.st_forced = stForced; + initialData.stForced = stForced; if (!isNaN(parsedValue)) { // Convert parsedValue to a number var signal = parseFloat(parsedValue.toFixed(2)); - dataToSend.signal = signal; - initialData.signal = signal; + dataToSend.sig = signal; + initialData.sig = signal; + dataToSend.sigRaw = receivedData; + initialData.sigRaw = receivedData; // Convert highestSignal to a number for comparison - var highestSignal = parseFloat(dataToSend.highestSignal); + var highestSignal = parseFloat(dataToSend.sigTop); if (signal > highestSignal) { - dataToSend.highestSignal = signal.toString(); // Convert back to string for consistency + dataToSend.sigTop = signal.toString(); // Convert back to string for consistency } } diff --git a/server/endpoints.js b/server/endpoints.js index 225c005..3d54050 100644 --- a/server/endpoints.js +++ b/server/endpoints.js @@ -22,6 +22,8 @@ router.get('/', (req, res) => { return; } + const noPlugins = req.query.noPlugins === 'true'; + if (configExists() === false) { let serialPorts; @@ -57,6 +59,7 @@ router.get('/', (req, res) => { tuningUpperLimit: serverConfig.webserver.tuningUpperLimit, chatEnabled: serverConfig.webserver.chatEnabled, device: serverConfig.device, + noPlugins, plugins: serverConfig.plugins, bwSwitch: serverConfig.bwSwitch ? serverConfig.bwSwitch : false }); diff --git a/server/helpers.js b/server/helpers.js index e31b5fc..3e2ec48 100644 --- a/server/helpers.js +++ b/server/helpers.js @@ -1,4 +1,3 @@ -const WebSocket = require('ws'); const dataHandler = require('./datahandler'); const storage = require('./storage'); const consoleCmd = require('./console'); @@ -55,7 +54,7 @@ function formatUptime(uptimeInSeconds) { let incompleteDataBuffer = ''; -function resolveDataBuffer(data, wss) { +function resolveDataBuffer(data, wss, rdsWss) { var receivedData = incompleteDataBuffer + data.toString(); const isIncomplete = (receivedData.slice(-1) != '\n'); @@ -73,7 +72,7 @@ function resolveDataBuffer(data, wss) { } if (receivedData.length) { - dataHandler.handleData(wss, receivedData); + dataHandler.handleData(wss, receivedData, rdsWss); }; } diff --git a/server/index.js b/server/index.js index 739b6be..023ac9a 100644 --- a/server/index.js +++ b/server/index.js @@ -11,6 +11,7 @@ const httpServer = http.createServer(app); const WebSocket = require('ws'); const wss = new WebSocket.Server({ noServer: true }); const chatWss = new WebSocket.Server({ noServer: true }); +const rdsWss = new WebSocket.Server({ noServer: true }); const path = require('path'); const net = require('net'); const client = new net.Socket(); @@ -109,7 +110,7 @@ if (serverConfig.xdrd.wirelessConnection === false) { }, 3000); serialport.on('data', (data) => { - helpers.resolveDataBuffer(data, wss); + helpers.resolveDataBuffer(data, wss, rdsWss); }); serialport.on('error', (error) => { @@ -185,7 +186,7 @@ function connectToXdrd() { }; client.on('data', (data) => { - helpers.resolveDataBuffer(data, wss); + helpers.resolveDataBuffer(data, wss, rdsWss); if (authFlags.authMsg == true && authFlags.messageCount > 1) { // If the limit is reached, remove the 'data' event listener client.off('data', authDataHandler); @@ -437,6 +438,15 @@ chatWss.on('connection', (ws, request) => { }); }); +rdsWss.on('connection', (ws, request) => { + ws.on('message', function incoming(message) { + + }); + + ws.on('close', function close() { + }); +}); + // Websocket register for /text, /audio and /chat paths httpServer.on('upgrade', (request, socket, head) => { if (request.url === '/text') { @@ -453,6 +463,12 @@ httpServer.on('upgrade', (request, socket, head) => { chatWss.emit('connection', ws, request); }); }); + } else if (request.url === '/rds') { + sessionMiddleware(request, {}, () => { + rdsWss.handleUpgrade(request, socket, head, (ws) => { + rdsWss.emit('connection', ws, request); + }); + }); } else { socket.destroy(); } diff --git a/server/tx_search.js b/server/tx_search.js index 998db7d..c2acdc9 100644 --- a/server/tx_search.js +++ b/server/tx_search.js @@ -83,6 +83,7 @@ function processData(data, piCode, rdsPs) { itu: matchingCity.itu, distance: maxDistance.toFixed(0), azimuth: txAzimuth.toFixed(0), + id: matchingStation.id, foundStation: true }; } else { diff --git a/web/css/buttons.css b/web/css/buttons.css index 61e0a5d..f471812 100644 --- a/web/css/buttons.css +++ b/web/css/buttons.css @@ -83,14 +83,14 @@ input[type="text"], textarea, input[type="password"] { #tune-buttons input[type="text"] { width: 50%; - height: 100%; + height: 48px; min-height: 46px; padding-left: 20px; box-sizing: border-box; border: 2px solid transparent; outline: 0; color: var(--color-text); - background-color: var(--color-1-transparent); + background-color: transparent; font-family: 'Titillium Web', sans-serif; } @@ -120,7 +120,7 @@ input[type="text"], textarea, input[type="password"] { border: 0; color: var(--color-1); width: 25%; - height: 100%; + height: 48px; display: block; padding: 14px; cursor: pointer; @@ -158,7 +158,7 @@ input[type="range"] { /* Track: Mozilla Firefox */ input[type="range"]::-moz-range-track { height: 48px; - background: var(--color-1-transparent); + background-color: transpraent; border-radius: 15px; border: 0; } @@ -340,4 +340,10 @@ select option { select:hover { background: var(--color-5); +} + +@media only screen and (max-width: 768px) { + #tune-buttons input[type="text"] { + background-color: var(--color-1-transparent); + } } \ No newline at end of file diff --git a/web/css/dropdown.css b/web/css/dropdown.css index 287b7a8..6c2f89a 100644 --- a/web/css/dropdown.css +++ b/web/css/dropdown.css @@ -40,6 +40,11 @@ background-color: var(--color-4); color: var(--color-main); border-radius: 15px; + transition: 0.35s ease-in-out background-color; + } + + .dropdown input:hover { + background-color: var(--color-main-bright); } .dropdown.opened > input { diff --git a/web/css/helpers.css b/web/css/helpers.css index 3215c7e..8be4055 100644 --- a/web/css/helpers.css +++ b/web/css/helpers.css @@ -112,7 +112,7 @@ .hover-brighten:hover { cursor: pointer; - background-color: var(--color-2); + background-color: var(--color-2-transparent); } .text-left { diff --git a/web/css/main.css b/web/css/main.css index f514e33..4ecc064 100644 --- a/web/css/main.css +++ b/web/css/main.css @@ -77,8 +77,8 @@ body { } #wrapper { - width: 1180px; - max-width: 1180px; + width: 100%; + max-width: calc(0% + 1180px); } #wrapper.setup-wrapper { margin: auto; diff --git a/web/css/panels.css b/web/css/panels.css index 78eb4c7..8fea02b 100644 --- a/web/css/panels.css +++ b/web/css/panels.css @@ -8,8 +8,25 @@ transition: 0.3s ease-in-out background-color; } -*[class^="panel-"]:not(.no-bg):not(.no-filter) { - backdrop-filter:blur(5px); +*[class^="panel-"]:not(.no-bg):not(.no-filter):not(.w-100) { + -webkit-backdrop-filter: blur(5px); + backdrop-filter: blur(5px); +} + +.panel-100.w-100 { + position: relative; +} + +.panel-100.w-100::before { + content: ''; + backdrop-filter: blur(10px); + width: 100%; + height: 100%; + position: absolute; + top: 0; + left: 0; + z-index: -1; + border-radius: 15px; } .panel-10 { @@ -54,6 +71,9 @@ margin-bottom: 20px; background-color: transparent; } + *[class^="panel-"]:not(.no-bg):not(.no-filter) { + backdrop-filter:blur(0px); + } .flex-phone { display: flex; } diff --git a/web/index.ejs b/web/index.ejs index dfcd505..e4faff7 100644 --- a/web/index.ejs +++ b/web/index.ejs @@ -125,12 +125,12 @@ <% if (antennas.enabled == true) { %>