From 4801503598f6cc3b7e7d77967b8e9a9635e187b3 Mon Sep 17 00:00:00 2001 From: Stefan Westerfeld Date: Fri, 6 Oct 2023 17:29:11 +0200 Subject: [PATCH] UI: b/trackvolume.js: add data bubble with dB value Signed-off-by: Stefan Westerfeld --- ui/b/trackvolume.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/b/trackvolume.js b/ui/b/trackvolume.js index b7371c43..13203293 100644 --- a/ui/b/trackvolume.js +++ b/ui/b/trackvolume.js @@ -65,6 +65,13 @@ class BTrackVolume extends LitComponent { updated (changed_props) { this.update_value(); + var db_value = 20 * Math.log10 (2*this.value**3); + var db_string; + if (this.value === 0) + db_string = "-" + "\u221E"; + else + db_string = db_value.toFixed (1); + this.setAttribute ('data-bubble', "Volume " + db_string + " dB"); } async update_value() {