implement a frequency input with switchable exponent
This commit is contained in:
21
htdocs/lib/settings/FrequencyInput.js
Normal file
21
htdocs/lib/settings/FrequencyInput.js
Normal file
@ -0,0 +1,21 @@
|
||||
$.fn.frequencyInput = function() {
|
||||
this.each(function(){
|
||||
var $group = $(this);
|
||||
var currentExponent = 0;
|
||||
$input = $group.find('input');
|
||||
|
||||
var setExponent = function() {
|
||||
var newExponent = parseInt($exponent.val());
|
||||
var delta = currentExponent - newExponent;
|
||||
$input.val(parseFloat($input.val()) * 10 ** delta);
|
||||
currentExponent = newExponent;
|
||||
};
|
||||
|
||||
$exponent = $group.find('select.frequency-exponent');
|
||||
$exponent.on('change', setExponent);
|
||||
|
||||
// calculate initial exponent
|
||||
$exponent.val(Math.floor(Math.log10($input.val()) / 3) * 3);
|
||||
setExponent();
|
||||
})
|
||||
};
|
@ -7,4 +7,5 @@ $(function(){
|
||||
$('#rf_gain').gainInput();
|
||||
$('.optional-section').optionalSection();
|
||||
$('#scheduler').schedulerInput();
|
||||
$('.frequency-input').frequencyInput();
|
||||
});
|
Reference in New Issue
Block a user