From 71acad3b4fceeb2b36f832bb897a77122c588a56 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sat, 27 Feb 2021 22:30:48 +0100 Subject: [PATCH] add keyboard shortcuts for quicker input --- htdocs/lib/settings/FrequencyInput.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/lib/settings/FrequencyInput.js b/htdocs/lib/settings/FrequencyInput.js index 482f658..81fdef4 100644 --- a/htdocs/lib/settings/FrequencyInput.js +++ b/htdocs/lib/settings/FrequencyInput.js @@ -1,4 +1,11 @@ $.fn.frequencyInput = function() { + var suffixes = { + "K": 3, + "M": 6, + "G": 9, + "T": 12 + }; + this.each(function(){ var $group = $(this); var currentExponent = 0; @@ -11,6 +18,14 @@ $.fn.frequencyInput = function() { currentExponent = newExponent; }; + $input.on('keydown', function(e) { + var c = String.fromCharCode(e.which); + if (c in suffixes) { + currentExponent = suffixes[c]; + $exponent.val(suffixes[c]); + } + }); + $exponent = $group.find('select.frequency-exponent'); $exponent.on('change', setExponent);