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;
|
var me = this;
|
||||||
me.modesToScan = ['lsb', 'usb', 'cw', 'am', 'sam', 'nfm'];
|
me.modesToScan = ['lsb', 'usb', 'cw', 'am', 'sam', 'nfm'];
|
||||||
me.localBookmarks = new BookmarkLocalStorage();
|
me.localBookmarks = new BookmarkLocalStorage();
|
||||||
me.$container = $("#openwebrx-bookmarks-container");
|
me.$container = $('#openwebrx-bookmarks-container');
|
||||||
me.bookmarks = {};
|
me.bookmarks = {};
|
||||||
|
|
||||||
me.$container.on('click', '.bookmark', function(e){
|
me.$container.on('click', '.bookmark', function(e){
|
||||||
|
|
@ -11,9 +11,7 @@ function BookmarkBar() {
|
||||||
var b = $bookmark.data();
|
var b = $bookmark.data();
|
||||||
if (!b || !b.frequency || !b.modulation) return;
|
if (!b || !b.frequency || !b.modulation) return;
|
||||||
me.getDemodulator().set_offset_frequency(b.frequency - center_freq);
|
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');
|
$bookmark.addClass('selected');
|
||||||
stopScanner();
|
stopScanner();
|
||||||
});
|
});
|
||||||
|
|
@ -41,7 +39,7 @@ function BookmarkBar() {
|
||||||
me.showEditDialog();
|
me.showEditDialog();
|
||||||
});
|
});
|
||||||
|
|
||||||
me.$dialog = $("#openwebrx-dialog-bookmark");
|
me.$dialog = $('#openwebrx-dialog-bookmark');
|
||||||
me.$dialog.find('.openwebrx-button[data-action=cancel]').click(function(){
|
me.$dialog.find('.openwebrx-button[data-action=cancel]').click(function(){
|
||||||
me.$dialog.hide();
|
me.$dialog.hide();
|
||||||
});
|
});
|
||||||
|
|
@ -108,13 +106,16 @@ BookmarkBar.prototype.render = function(){
|
||||||
|
|
||||||
BookmarkBar.prototype.showEditDialog = function(bookmark) {
|
BookmarkBar.prototype.showEditDialog = function(bookmark) {
|
||||||
if (!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 = {
|
bookmark = {
|
||||||
name: "",
|
name: '',
|
||||||
frequency: center_freq + this.getDemodulator().get_offset_frequency(),
|
frequency: center_freq + this.getDemodulator().get_offset_frequency(),
|
||||||
modulation: mode,
|
modulation: mode1,
|
||||||
description: "",
|
underlying: mode2,
|
||||||
scannable : this.modesToScan.indexOf(mode) >= 0
|
description: '',
|
||||||
|
scannable : this.modesToScan.indexOf(mode1) >= 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.$dialog.bookmarkDialog().setValues(bookmark);
|
this.$dialog.bookmarkDialog().setValues(bookmark);
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,25 @@ $.fn.bookmarkDialog = function() {
|
||||||
var $el = this;
|
var $el = this;
|
||||||
return {
|
return {
|
||||||
setModes: function(modes) {
|
setModes: function(modes) {
|
||||||
$el.find('#modulation').html(modes.filter(function(m){
|
$el.find('#modulation').html(modes.filter(function(m) {
|
||||||
return m.isAvailable();
|
return m.isAvailable();
|
||||||
}).map(function(m) {
|
}).map(function(m) {
|
||||||
return '<option value="' + m.modulation + '">' + m.name + '</option>';
|
return '<option value="' + m.modulation + '">' + m.name + '</option>';
|
||||||
}).join(''));
|
}).join(''));
|
||||||
return this;
|
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) {
|
setValues: function(bookmark) {
|
||||||
var $form = $el.find('form');
|
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);
|
var $input = $form.find('#' + key);
|
||||||
if ($input.is(':checkbox')) {
|
if ($input.is(':checkbox')) {
|
||||||
$input.prop('checked', bookmark[key]);
|
$input.prop('checked', bookmark[key]);
|
||||||
|
|
@ -25,7 +34,7 @@ $.fn.bookmarkDialog = function() {
|
||||||
getValues: function() {
|
getValues: function() {
|
||||||
var bookmark = {};
|
var bookmark = {};
|
||||||
var valid = true;
|
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);
|
var $input = $el.find('#' + key);
|
||||||
valid = valid && $input[0].checkValidity();
|
valid = valid && $input[0].checkValidity();
|
||||||
bookmark[key] = $input.is(':checkbox')? $input.is(':checked') : $input.val();
|
bookmark[key] = $input.is(':checkbox')? $input.is(':checked') : $input.val();
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@ var Modes = {
|
||||||
setModes:function(json){
|
setModes:function(json){
|
||||||
this.modes = json.map(function(m){ return new Mode(m); });
|
this.modes = json.map(function(m){ return new Mode(m); });
|
||||||
this.updatePanels();
|
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(){
|
getModes:function(){
|
||||||
return this.modes;
|
return this.modes;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ class Bookmark(object):
|
||||||
self.name = j["name"]
|
self.name = j["name"]
|
||||||
self.frequency = j["frequency"]
|
self.frequency = j["frequency"]
|
||||||
self.modulation = j["modulation"]
|
self.modulation = j["modulation"]
|
||||||
|
self.underlying = j["underlying"] if "underlying" in j else ""
|
||||||
self.description = j["description"] if "description" in j else ""
|
self.description = j["description"] if "description" in j else ""
|
||||||
self.srcFile = srcFile
|
self.srcFile = srcFile
|
||||||
# By default, only scan modulations that make sense to scan
|
# By default, only scan modulations that make sense to scan
|
||||||
|
|
@ -33,6 +34,9 @@ class Bookmark(object):
|
||||||
def getModulation(self):
|
def getModulation(self):
|
||||||
return self.modulation
|
return self.modulation
|
||||||
|
|
||||||
|
def getUnderlying(self):
|
||||||
|
return self.underlying
|
||||||
|
|
||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return self.description
|
return self.description
|
||||||
|
|
||||||
|
|
@ -47,6 +51,7 @@ class Bookmark(object):
|
||||||
"name": self.getName(),
|
"name": self.getName(),
|
||||||
"frequency": self.getFrequency(),
|
"frequency": self.getFrequency(),
|
||||||
"modulation": self.getModulation(),
|
"modulation": self.getModulation(),
|
||||||
|
"underlying": self.getUnderlying(),
|
||||||
"description": self.getDescription(),
|
"description": self.getDescription(),
|
||||||
"scannable": self.isScannable(),
|
"scannable": self.isScannable(),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ class BookmarksController(AuthorizationMixin, BreadcrumbMixin, WebpageController
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
data = json.loads(self.get_body().decode("utf-8"))
|
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:
|
if key in data:
|
||||||
value = data[key]
|
value = data[key]
|
||||||
if key == "frequency":
|
if key == "frequency":
|
||||||
|
|
@ -125,7 +125,7 @@ class BookmarksController(AuthorizationMixin, BreadcrumbMixin, WebpageController
|
||||||
def create(bookmark_data):
|
def create(bookmark_data):
|
||||||
# sanitize
|
# sanitize
|
||||||
data = {}
|
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 in bookmark_data:
|
||||||
if key == "frequency":
|
if key == "frequency":
|
||||||
data[key] = int(bookmark_data[key])
|
data[key] = int(bookmark_data[key])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue