Adding underlying modulation to bookmarks (no editor yet!)
This commit is contained in:
parent
309274a6af
commit
df1a865323
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 '<option value="' + m.modulation + '">' + m.name + '</option>';
|
||||
}).join(''));
|
||||
return this;
|
||||
},
|
||||
setUnderlying: function(modes) {
|
||||
$el.find('#underlying').html('<option value="">None</option>' +
|
||||
modes.filter(function(m) {
|
||||
return m.isAvailable() && !m.underlying && m.type === 'analog';
|
||||
}).map(function(m) {
|
||||
return '<option value="' + m.modulation + '">' + m.name + '</option>';
|
||||
}).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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
|
|
|
|||
Loading…
Reference in New Issue