From e4c635af9c709199613a000299965995a6194380 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Fri, 26 Jan 2024 19:22:38 +0100 Subject: [PATCH] automatically select a programme to play --- htdocs/lib/MetaPanel.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/htdocs/lib/MetaPanel.js b/htdocs/lib/MetaPanel.js index 236d8283..584fadf6 100644 --- a/htdocs/lib/MetaPanel.js +++ b/htdocs/lib/MetaPanel.js @@ -565,12 +565,13 @@ function DabMetaPanel(el) { '
' + '
' + '
' + - '' + + '' + '' ); $container.append(this.$select); $(this.el).append($container); this.clear(); + this.programmeTimeout = false; } DabMetaPanel.prototype = new MetaPanel(); @@ -601,16 +602,27 @@ DabMetaPanel.prototype.update = function(data) { return ''; }); this.$select.html( - options.join('') + options.join('') + + '' ); - this.$select.val(this.service_id); + + var me = this; + if (this.programmeTimeout) clearTimeout(this.programmeTimeout); + this.programmeTimeout = setTimeout(function() { + // user has selected a programme to play. don't interfere. + me.$select.val(this.service_id); + if (me.$select.val()) return; + me.$select.val(me.$select.find('option:first').val()).change(); + }, 1000); } } DabMetaPanel.prototype.clear = function() { this.service_id = 0; $(this.el).find('.dab-auto-clear').empty(); - this.$select.empty(); + this.$select.html( + '' + ); } MetaPanel.types = {