include digital demods in hash

This commit is contained in:
Jakob Ketterl 2020-01-25 23:47:32 +01:00
parent 8fc981c8a0
commit 49c333b88a

View File

@ -549,13 +549,15 @@ function demodulator_analog_replace(subtype, for_digital) { //this function shou
secondary_demod_close_window(); secondary_demod_close_window();
secondary_demod_listbox_update(); secondary_demod_listbox_update();
} }
last_analog_demodulator_subtype = subtype; if (!demodulators || !demodulators[0] || demodulators[0].subtype !== subtype) {
var temp_offset = 0; last_analog_demodulator_subtype = subtype;
if (demodulators.length) { var temp_offset = 0;
temp_offset = demodulators[0].offset_frequency; if (demodulators.length) {
demodulator_remove(0); temp_offset = demodulators[0].offset_frequency;
demodulator_remove(0);
}
demodulator_add(new Demodulator_default_analog(temp_offset, subtype));
} }
demodulator_add(new Demodulator_default_analog(temp_offset, subtype));
demodulator_buttons_update(); demodulator_buttons_update();
update_digitalvoice_panels("openwebrx-panel-metadata-" + subtype); update_digitalvoice_panels("openwebrx-panel-metadata-" + subtype);
updateHash(); updateHash();
@ -1533,11 +1535,16 @@ function validateHash() {
function updateHash() { function updateHash() {
var demod = demodulators[0]; var demod = demodulators[0];
if (!demod) return;
window.location.hash = $.map({ window.location.hash = $.map({
freq: demod.get_offset_frequency() + center_freq, freq: demod.get_offset_frequency() + center_freq,
mod: demod.subtype mod: demod.subtype,
secondary_mod: secondary_demod
}, function(value, key){ }, function(value, key){
if (!value) return undefined;
return key + '=' + value; return key + '=' + value;
}).filter(function(v) {
return !!v;
}).join(','); }).join(',');
} }
@ -1559,7 +1566,9 @@ function onAudioStart(success, apiType){
function initialize_demodulator(initialParams) { function initialize_demodulator(initialParams) {
mkscale(); mkscale();
var params = $.extend(initialParams || {}, validateHash()); var params = $.extend(initialParams || {}, validateHash());
if (params.mod) { if (params.secondary_mod) {
demodulator_digital_replace(params.secondary_mod);
} else if (params.mod) {
demodulator_analog_replace(params.mod); demodulator_analog_replace(params.mod);
} }
if (params.offset_frequency) { if (params.offset_frequency) {
@ -1951,6 +1960,7 @@ function initPanels() {
function demodulator_buttons_update() { function demodulator_buttons_update() {
$(".openwebrx-demodulator-button").removeClass("highlighted"); $(".openwebrx-demodulator-button").removeClass("highlighted");
if (!demodulators.length) return;
if (secondary_demod) { if (secondary_demod) {
$("#openwebrx-button-dig").addClass("highlighted"); $("#openwebrx-button-dig").addClass("highlighted");
$('#openwebrx-secondary-demod-listbox').val(secondary_demod); $('#openwebrx-secondary-demod-listbox').val(secondary_demod);
@ -2013,6 +2023,7 @@ function demodulator_digital_replace_last() {
} }
function demodulator_digital_replace(subtype) { function demodulator_digital_replace(subtype) {
if (secondary_demod === subtype) return;
switch (subtype) { switch (subtype) {
case "bpsk31": case "bpsk31":
case "bpsk63": case "bpsk63":
@ -2050,6 +2061,7 @@ function demodulator_digital_replace(subtype) {
toggle_panel("openwebrx-panel-wsjt-message", ['ft8', 'wspr', 'jt65', 'jt9', 'ft4'].indexOf(subtype) >= 0); toggle_panel("openwebrx-panel-wsjt-message", ['ft8', 'wspr', 'jt65', 'jt9', 'ft4'].indexOf(subtype) >= 0);
toggle_panel("openwebrx-panel-packet-message", subtype === "packet"); toggle_panel("openwebrx-panel-packet-message", subtype === "packet");
toggle_panel("openwebrx-panel-pocsag-message", subtype === "pocsag"); toggle_panel("openwebrx-panel-pocsag-message", subtype === "pocsag");
updateHash();
} }
function secondary_demod_create_canvas() { function secondary_demod_create_canvas() {