//
// Handle keyboard shortcuts
//
function Shortcuts() {}
Shortcuts.init = function(target) {
var that = this;
target.addEventListener('keydown', function(e) { that.handleKey(e); });
this.overlay = jQuery('
Hide this help with '?'.
tune frequency
${this.keycap('ArrowLeft')}|${this.keycap('ArrowRight')}
zoom waterfall
${this.keycap('ArrowUp')}|${this.keycap('ArrowDown')}
select modulation
(${this.keycap('Control')}+) ${this.keycap('0')}..${this.keycap('9')}
change tuning step
${this.keycap('[')}|${this.keycap(']')}
change volume
${this.keycap('Control')}+${this.keycap('ArrowUp')}|${this.keycap('ArrowDown')}
mute/unumte sound
${this.keycap('Space')}
auto-set squelch
${this.keycap('A')}
change squelch level
${this.keycap('Control')}+${this.keycap('ArrowLeft')}|${this.keycap('ArrowRight')}
disable squelch
${this.keycap('D')}
toggle noise reduction
${this.keycap('N')}
adjust bandpass offset
${this.keycap('Shift')}+${this.keycap('ArrowLeft')}|${this.keycap('ArrowRight')}
adjust bandpass width
${this.keycap('Shift')}+${this.keycap('ArrowUp')}|${this.keycap('ArrowDown')}
toggle scanner
${this.keycap('S')}
adjust waterfall min level
${this.keycap(',')}|${this.keycap('.')}
adjust waterfall max level
${this.keycap('<')}|${this.keycap('>')}
auto-set colors once
${this.keycap('Z')}
auto-set colors
${this.keycap('X')}
set default colors
${this.keycap('C')}
toggle recorder
${this.keycap('R')}
toggle spectrum
${this.keycap('V')}
toggle bandplan
${this.keycap('B')}
open map
${this.keycap('M')}
open files browser
${this.keycap('F')}
open documentation
${this.keycap('H')}
`);
};
Shortcuts.moveSlider = function(slider, delta) {
var $control = $(slider);
if (!$control.prop('disabled')) {
$control.val(parseInt($control.val()) + delta).change();
}
};
Shortcuts.moveSelector = function(selector, steps) {
var $control = $(selector);
if (!$control.prop('disabled')) {
var max = $(selector + ' option').length;
var n = $control.prop('selectedIndex') + steps;
n = n < 0? n + max : n >= max? n - max : n;
$control.prop('selectedIndex', n).change();
}
};
Shortcuts.handleKey = function(event) {
// Do not handle shortcuts when focused on a text or numeric input
var on_input = !!($('input:focus').length && ($('input:focus')[0].type === 'text' || $('input:focus')[0].type === 'number'));
if (on_input) return;
// Leave CTRL+