diff --git a/htdocs/lib/BookmarkBar.js b/htdocs/lib/BookmarkBar.js index 4edac8e..d039494 100644 --- a/htdocs/lib/BookmarkBar.js +++ b/htdocs/lib/BookmarkBar.js @@ -9,7 +9,7 @@ function BookmarkBar() { me.$container.find('.bookmark').removeClass('selected'); var b = $bookmark.data(); if (!b || !b.frequency || (!b.modulation && !b.digital_modulation)) return; - demodulator_set_offset_frequency(0, b.frequency - center_freq); + demodulators[0].set_offset_frequency(b.frequency - center_freq); if (b.modulation) { demodulator_analog_replace(b.modulation); } else if (b.digital_modulation) { diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index 45112f8..50cfdec 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -334,7 +334,6 @@ function demod_envelope_where_clicked(x, drag_ranges, key_modifiers) { // Check //******* class Demodulator ******* // this can be used as a base class for ANY demodulator Demodulator = function (offset_frequency) { - //console.log("this too"); this.offset_frequency = offset_frequency; this.envelope = {}; this.color = demodulators_get_next_color(); @@ -357,11 +356,7 @@ Demodulator.draggable_ranges = { demodulator_response_time = 50; -//in ms; if we don't limit the number of SETs sent to the server, audio will underrun (possibly output buffer is cleared on SETs in GNU Radio - function Demodulator_default_analog(offset_frequency, subtype) { - //console.log("hopefully this happens"); - //http://stackoverflow.com/questions/4152931/javascript-inheritance-call-super-constructor-or-use-prototype-chain Demodulator.call(this, offset_frequency); this.subtype = subtype; this.filter = { @@ -565,10 +560,10 @@ function demodulator_analog_replace(subtype, for_digital) { //this function shou update_digitalvoice_panels("openwebrx-panel-metadata-" + subtype); } -function demodulator_set_offset_frequency(to_what) { +Demodulator.prototype.set_offset_frequency = function(to_what) { if (to_what > bandwidth / 2 || to_what < -bandwidth / 2) return; - demodulators[0].offset_frequency = Math.round(to_what); - demodulators[0].set(); + this.offset_frequency = Math.round(to_what); + this.set(); mkenvelopes(get_visible_freq_range()); tunedFrequencyDisplay.setFrequency(center_freq + to_what); } @@ -635,7 +630,7 @@ function scale_canvas_mousemove(evt) { else if (scale_canvas_drag_params.drag) { //call the drag_move for all demodulators (and they will decide if they're dragged) for (i = 0; i < demodulators.length; i++) event_handled |= demodulators[i].envelope.drag_move(evt.pageX); - if (!event_handled) demodulator_set_offset_frequency(scale_offset_freq_from_px(evt.pageX)); + if (!event_handled) demodulators[0].set_offset_frequency(scale_offset_freq_from_px(evt.pageX)); } } @@ -651,7 +646,7 @@ function scale_canvas_end_drag(x) { scale_canvas_drag_params.mouse_down = false; var event_handled = false; for (var i = 0; i < demodulators.length; i++) event_handled |= demodulators[i].envelope.drag_end(); - if (!event_handled) demodulator_set_offset_frequency(scale_offset_freq_from_px(x)); + if (!event_handled) demodulators[0].set_offset_frequency(scale_offset_freq_from_px(x)); } function scale_canvas_mouseup(evt) { @@ -932,7 +927,7 @@ function canvas_mouseup(evt) { var relativeX = get_relative_x(evt); if (!canvas_drag) { - demodulator_set_offset_frequency(canvas_get_freq_offset(relativeX)); + demodulators[0].set_offset_frequency(canvas_get_freq_offset(relativeX)); } else { canvas_end_drag(); @@ -1792,7 +1787,7 @@ function openwebrx_init() { initPanels(); tunedFrequencyDisplay = new TuneableFrequencyDisplay($('#webrx-actual-freq')); tunedFrequencyDisplay.onFrequencyChange(function(f) { - demodulator_set_offset_frequency(f - center_freq); + demodulators[0].set_offset_frequency(f - center_freq); }); mouseFrequencyDisplay = new FrequencyDisplay($('#webrx-mouse-freq')); window.addEventListener("resize", openwebrx_resize);