From: E.Smith <31170571+azlm8t@users.noreply.github.com> Date: Sat, 22 Sep 2018 17:19:15 +0000 (+0100) Subject: ui: Add Next/Prev buttons to filter epg channels. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a12bef876d5c96ec73787e0eaf0195c3fd6c4e5;p=thirdparty%2Ftvheadend.git ui: Add Next/Prev buttons to filter epg channels. This provides a simple way to provide a "now & next" view in the EPG. --- diff --git a/src/webui/static/app/epg.js b/src/webui/static/app/epg.js index 7e57e7e28..7b16ff438 100644 --- a/src/webui/static/app/epg.js +++ b/src/webui/static/app/epg.js @@ -484,6 +484,7 @@ tvheadend.epgDetails = function(grid, index) { tvheadend.epg = function() { var lookup = ' '; + 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)