diff --git a/htdocs/lib/BookmarkBar.js b/htdocs/lib/BookmarkBar.js index 65ca2040..f368032d 100644 --- a/htdocs/lib/BookmarkBar.js +++ b/htdocs/lib/BookmarkBar.js @@ -2,7 +2,7 @@ function BookmarkBar() { var me = this; me.modesToScan = ['lsb', 'usb', 'cw', 'am', 'sam', 'nfm']; me.localBookmarks = new BookmarkLocalStorage(); - me.$container = $("#openwebrx-bookmarks-container"); + me.$container = $('#openwebrx-bookmarks-container'); me.bookmarks = {}; me.$container.on('click', '.bookmark', function(e){ @@ -11,9 +11,7 @@ function BookmarkBar() { var b = $bookmark.data(); if (!b || !b.frequency || !b.modulation) return; me.getDemodulator().set_offset_frequency(b.frequency - center_freq); - if (b.modulation) { - me.getDemodulatorPanel().setMode(b.modulation, b.underlying); - } + me.getDemodulatorPanel().setMode(b.modulation, b.underlying); $bookmark.addClass('selected'); stopScanner(); }); @@ -41,7 +39,7 @@ function BookmarkBar() { me.showEditDialog(); }); - me.$dialog = $("#openwebrx-dialog-bookmark"); + me.$dialog = $('#openwebrx-dialog-bookmark'); me.$dialog.find('.openwebrx-button[data-action=cancel]').click(function(){ me.$dialog.hide(); }); @@ -108,13 +106,16 @@ BookmarkBar.prototype.render = function(){ BookmarkBar.prototype.showEditDialog = function(bookmark) { if (!bookmark) { - var mode = this.getDemodulator().get_secondary_demod() || this.getDemodulator().get_modulation(); + var mode1 = this.getDemodulator().get_secondary_demod() + var mode2 = this.getDemodulator().get_modulation(); + if (!mode1) { mode1 = mode2; mode2 = ''; } bookmark = { - name: "", + name: '', frequency: center_freq + this.getDemodulator().get_offset_frequency(), - modulation: mode, - description: "", - scannable : this.modesToScan.indexOf(mode) >= 0 + modulation: mode1, + underlying: mode2, + description: '', + scannable : this.modesToScan.indexOf(mode1) >= 0 } } this.$dialog.bookmarkDialog().setValues(bookmark); diff --git a/htdocs/lib/BookmarkDialog.js b/htdocs/lib/BookmarkDialog.js index ee7c2fd4..ef039352 100644 --- a/htdocs/lib/BookmarkDialog.js +++ b/htdocs/lib/BookmarkDialog.js @@ -2,16 +2,25 @@ $.fn.bookmarkDialog = function() { var $el = this; return { setModes: function(modes) { - $el.find('#modulation').html(modes.filter(function(m){ + $el.find('#modulation').html(modes.filter(function(m) { return m.isAvailable(); }).map(function(m) { return ''; }).join('')); return this; }, + setUnderlying: function(modes) { + $el.find('#underlying').html('' + + modes.filter(function(m) { + return m.isAvailable() && !m.underlying && m.type === 'analog'; + }).map(function(m) { + return ''; + }).join('')); + return this; + }, setValues: function(bookmark) { var $form = $el.find('form'); - ['name', 'frequency', 'modulation', 'description', 'scannable'].forEach(function(key){ + ['name', 'frequency', 'modulation', 'underlying', 'description', 'scannable'].forEach(function(key) { var $input = $form.find('#' + key); if ($input.is(':checkbox')) { $input.prop('checked', bookmark[key]); @@ -25,7 +34,7 @@ $.fn.bookmarkDialog = function() { getValues: function() { var bookmark = {}; var valid = true; - ['name', 'frequency', 'modulation', 'description', 'scannable'].forEach(function(key){ + ['name', 'frequency', 'modulation', 'underlying', 'description', 'scannable'].forEach(function(key) { var $input = $el.find('#' + key); valid = valid && $input[0].checkValidity(); bookmark[key] = $input.is(':checkbox')? $input.is(':checked') : $input.val(); diff --git a/htdocs/lib/Modes.js b/htdocs/lib/Modes.js index 0bdac90b..1ec050d1 100644 --- a/htdocs/lib/Modes.js +++ b/htdocs/lib/Modes.js @@ -5,7 +5,9 @@ var Modes = { setModes:function(json){ this.modes = json.map(function(m){ return new Mode(m); }); this.updatePanels(); - $('#openwebrx-dialog-bookmark').bookmarkDialog().setModes(this.modes); + var bookmarkDialog = $('#openwebrx-dialog-bookmark').bookmarkDialog(); + bookmarkDialog.setUnderlying(this.modes); + bookmarkDialog.setModes(this.modes); }, getModes:function(){ return this.modes; diff --git a/owrx/bookmarks.py b/owrx/bookmarks.py index b7b3aeea..81f7b93a 100644 --- a/owrx/bookmarks.py +++ b/owrx/bookmarks.py @@ -16,6 +16,7 @@ class Bookmark(object): self.name = j["name"] self.frequency = j["frequency"] self.modulation = j["modulation"] + self.underlying = j["underlying"] if "underlying" in j else "" self.description = j["description"] if "description" in j else "" self.srcFile = srcFile # By default, only scan modulations that make sense to scan @@ -33,6 +34,9 @@ class Bookmark(object): def getModulation(self): return self.modulation + def getUnderlying(self): + return self.underlying + def getDescription(self): return self.description @@ -47,6 +51,7 @@ class Bookmark(object): "name": self.getName(), "frequency": self.getFrequency(), "modulation": self.getModulation(), + "underlying": self.getUnderlying(), "description": self.getDescription(), "scannable": self.isScannable(), } diff --git a/owrx/controllers/settings/bookmarks.py b/owrx/controllers/settings/bookmarks.py index 1c9c9a09..596a1a7c 100644 --- a/owrx/controllers/settings/bookmarks.py +++ b/owrx/controllers/settings/bookmarks.py @@ -106,7 +106,7 @@ class BookmarksController(AuthorizationMixin, BreadcrumbMixin, WebpageController return try: data = json.loads(self.get_body().decode("utf-8")) - for key in ["name", "frequency", "modulation", "description", "scannable"]: + for key in ["name", "frequency", "modulation", "underlying", "description", "scannable"]: if key in data: value = data[key] if key == "frequency": @@ -125,7 +125,7 @@ class BookmarksController(AuthorizationMixin, BreadcrumbMixin, WebpageController def create(bookmark_data): # sanitize data = {} - for key in ["name", "frequency", "modulation", "description", "scannable"]: + for key in ["name", "frequency", "modulation", "underlying", "description", "scannable"]: if key in bookmark_data: if key == "frequency": data[key] = int(bookmark_data[key])