From c9fd4915b812015836eec60e5b75d03d1f272e9f Mon Sep 17 00:00:00 2001 From: Adam Wisher <37659188+mrwish7@users.noreply.github.com> Date: Sat, 31 May 2025 09:12:26 +0100 Subject: [PATCH] Multi TX search tweaks Order the match list by score, clean up of matches panel HTML and show score in DOM as data element --- server/datahandler.js | 3 ++- server/tx_search.js | 7 +++++-- web/index.ejs | 2 +- web/js/main.js | 15 ++++++++------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/server/datahandler.js b/server/datahandler.js index d0e2291..1f4ef74 100644 --- a/server/datahandler.js +++ b/server/datahandler.js @@ -421,7 +421,8 @@ function handleData(wss, receivedData, rdsWss) { id: currentTx.id, pi: currentTx.pi, reg: currentTx.reg, - otherMatches: currentTx.others + otherMatches: currentTx.others, + score: currentTx.score, }; } }) diff --git a/server/tx_search.js b/server/tx_search.js index 2380cce..33c8eef 100644 --- a/server/tx_search.js +++ b/server/tx_search.js @@ -191,10 +191,12 @@ async function fetchTx(freq, piCode, rdsPs) { for (loc of filteredLocations) { loc.score = evaluateStation(loc); } - match = filteredLocations.reduce((max, obj) => obj.score > max.score ? obj : max, filteredLocations[0]); - multiMatches = filteredLocations.filter(obj => obj !== match); + filteredLocations.sort((a, b) => b.score - a.score); + match = filteredLocations[0]; + multiMatches = filteredLocations.slice(1); } else if (filteredLocations.length === 1) { match = filteredLocations[0]; + match.score = 1; } if (match) { @@ -218,6 +220,7 @@ async function fetchTx(freq, piCode, rdsPs) { pi: match.pi, foundStation: true, reg: match.detectedByPireg, + score: match.score, others: multiMatches, }; } else { diff --git a/web/index.ejs b/web/index.ejs index 044d2ed..286c8b0 100644 --- a/web/index.ejs +++ b/web/index.ejs @@ -290,7 +290,7 @@