]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
ui: Add Next/Prev buttons to filter epg channels.
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Sat, 22 Sep 2018 17:19:15 +0000 (18:19 +0100)
committerperexg <perex@perex.cz>
Wed, 26 Sep 2018 15:31:14 +0000 (17:31 +0200)
This provides a simple way to provide a "now & next" view in the
EPG.

src/webui/static/app/epg.js

index 7e57e7e28bdfead78ee55a2b07c2240b7f93ade3..7b16ff4389a1376a18560bbf59f319ae87d8aeff 100644 (file)
@@ -484,6 +484,7 @@ tvheadend.epgDetails = function(grid, index) {
 
 tvheadend.epg = function() {
     var lookup = '<span class="x-linked">&nbsp;</span>';
+    var epgChannelCurrentIndex = 0;
 
     var detailsfcn = function(grid, rec, act, row) {
         new tvheadend.epgDetails(grid, row);
@@ -881,6 +882,18 @@ tvheadend.epg = function() {
         }
     });
 
+    var epgPrevChannel = new Ext.Button({
+        handler: epgPrevChannelCB,
+        iconCls: 'previous',
+        tooltip: _("Go to previous channel"),
+    });
+
+    var epgNextChannel = new Ext.Button({
+        handler: epgNextChannelCB,
+        iconCls: 'next',
+        tooltip: _("Go to next channel"),
+    });
+
     // Tags, uses global store
 
     var epgFilterChannelTags = new Ext.ux.form.ComboAny({
@@ -1096,7 +1109,8 @@ tvheadend.epg = function() {
         epgView.reset();
     }
 
-    epgFilterChannels.on('select', function(c, r) {
+    epgFilterChannels.on('select', function(c, r, index) {
+        epgChannelCurrentIndex = index;
         epgFilterChannelSet(r.data.key == -1 ? "" : r.data.key);
     });
 
@@ -1192,7 +1206,7 @@ tvheadend.epg = function() {
     var tbar = [
         epgMode, '-',
         epgFilterTitle, { text: _('Fulltext') }, epgFilterFulltext, { text: _('New only') }, epgFilterNewOnly, '-',
-        epgFilterChannels, '-',
+        epgPrevChannel, epgFilterChannels, epgNextChannel, '-',
         epgFilterChannelTags, '-',
         epgFilterContentGroup, '-',
         epgFilterDuration, '-',
@@ -1359,6 +1373,38 @@ tvheadend.epg = function() {
         new tvheadend.epgDetails(grid, index);
     }
 
+    function epgChannelSetCommon(delta) {
+        // Count is 1-based
+        var max = epgFilterChannels.store.getCount();
+        // Elem 0 is "clear filter" so we expect at least
+        // two items.
+        if (max < 2)
+            return;
+
+        epgChannelCurrentIndex += delta;
+        // Wrap-around seems to make sense for EPG since
+        // we have a text field showing the channel names.
+        if (epgChannelCurrentIndex < 1)
+            epgChannelCurrentIndex = max - 1;
+        else if (epgChannelCurrentIndex >= max)
+            epgChannelCurrentIndex = 1;
+
+        var text = epgFilterChannels.store.getAt(epgChannelCurrentIndex).get("val");
+        epgFilterChannels.setValue(text);
+        // We have to call our "value changed" cb ourselves, but with
+        // the associated key for it to be sent to the server for filtering.
+        var key = epgFilterChannels.store.getAt(epgChannelCurrentIndex).get("key");
+        epgFilterChannelSet(key);
+    }
+
+    function epgPrevChannelCB() {
+        epgChannelSetCommon(-1);
+    }
+
+    function epgNextChannelCB() {
+        epgChannelSetCommon(+1);
+    }
+
     function createAutoRec() {
     
         if (!tvheadend.accessUpdate.dvr)