From e1dd9d32f49183f2f27dc16fefd01fa6be409c42 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Thu, 25 Mar 2021 16:08:02 +0100 Subject: [PATCH] prevent javascript errors if frequency is NaN --- htdocs/lib/FrequencyDisplay.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/lib/FrequencyDisplay.js b/htdocs/lib/FrequencyDisplay.js index 3d20f8c..86c7632 100644 --- a/htdocs/lib/FrequencyDisplay.js +++ b/htdocs/lib/FrequencyDisplay.js @@ -29,7 +29,11 @@ FrequencyDisplay.prototype.getPrefix = function() { FrequencyDisplay.prototype.setFrequency = function(freq) { this.frequency = freq; - this.exponent = Math.floor(Math.log10(this.frequency) / 3) * 3; + if (Number.isNaN(this.frequency)) { + this.exponent = 0 + } else { + this.exponent = Math.floor(Math.log10(this.frequency) / 3) * 3; + } var digits = Math.max(0, this.exponent - this.precision); var formatted = (freq / 10 ** this.exponent).toLocaleString(