complete storage and display

This commit is contained in:
Jakob Ketterl 2019-09-28 20:28:25 +02:00
parent bd9cdc1cba
commit af9fcbc38d
2 changed files with 23 additions and 4 deletions

View File

@ -205,6 +205,14 @@ input[type=range]:focus::-ms-fill-upper
margin-bottom: -5px; margin-bottom: -5px;
} }
#openwebrx-bookmarks-container .bookmark[data-source=local] {
background-color: #0FF;
}
#openwebrx-bookmarks-container .bookmark[data-source=local]:after {
border-top-color: #0FF;
}
#webrx-canvas-container #webrx-canvas-container
{ {
/*background-image:url('../gfx/openwebrx-blank-background-1.jpg');*/ /*background-image:url('../gfx/openwebrx-blank-background-1.jpg');*/

View File

@ -1215,6 +1215,7 @@ function on_ws_recv(evt)
waterfall_init(); waterfall_init();
audio_preinit(); audio_preinit();
loadLocalBookmarks();
if (audio_allowed && !audio_initialized) audio_init(); if (audio_allowed && !audio_initialized) audio_init();
waterfall_clear(); waterfall_clear();
@ -1269,7 +1270,7 @@ function on_ws_recv(evt)
update_packet_panel(json.value); update_packet_panel(json.value);
break; break;
case "bookmarks": case "bookmarks":
update_bookmarks(json.value); update_bookmarks(json.value, "server");
break; break;
default: default:
console.warn('received message of unknown type: ' + json.type); console.warn('received message of unknown type: ' + json.type);
@ -1336,17 +1337,25 @@ function on_ws_recv(evt)
} }
} }
function update_bookmarks(bookmarks) { function update_bookmarks(bookmarks, source) {
var $container = $('#openwebrx-bookmarks-container'); var $container = $('#openwebrx-bookmarks-container');
$container.empty(); $container.find('.bookmark[data-source=' + source + ']').remove();
bookmarks.forEach(function(b){ bookmarks.forEach(function(b){
$bookmark = $('<div class="bookmark">' + b.name + '</div>'); $bookmark = $('<div class="bookmark" data-source="' + source + '">' + b.name + '</div>');
$bookmark.data(b); $bookmark.data(b);
$container.append($bookmark); $container.append($bookmark);
}); });
position_bookmarks(); position_bookmarks();
} }
function loadLocalBookmarks() {
var range = get_visible_freq_range();
var bookmarks = getLocalBookmarks().filter(function(b){
return b.frequency >= range.start && b.frequency <= range.end;
});
update_bookmarks(bookmarks, 'local');
}
function position_bookmarks() { function position_bookmarks() {
var range = get_visible_freq_range(); var range = get_visible_freq_range();
$('#openwebrx-bookmarks-container .bookmark').each(function(){ $('#openwebrx-bookmarks-container .bookmark').each(function(){
@ -1407,9 +1416,11 @@ function storeNewBookmark() {
$dialog.find("form :submit").click(); $dialog.find("form :submit").click();
return; return;
} }
bookmark.frequency = Number(bookmark.frequency);
var bookmarks = getLocalBookmarks(); var bookmarks = getLocalBookmarks();
bookmarks.push(bookmark); bookmarks.push(bookmark);
setLocalBookmarks(bookmarks); setLocalBookmarks(bookmarks);
loadLocalBookmarks();
$dialog.hide(); $dialog.hide();
} }