Author: ygrego Date: 2015-03-02 13:07:51 +0000 (Mon, 02 Mar 2015) New Revision: 904 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/904 Log: Use of loop (for) in method "findChannel" and new approach to retrieve the next/previous channel. Modified: oipf/js/utils/ChannelTools.js Modified: oipf/js/utils/ChannelTools.js =================================================================== --- oipf/js/utils/ChannelTools.js 2015-03-02 13:06:01 UTC (rev 903) +++ oipf/js/utils/ChannelTools.js 2015-03-02 13:07:51 UTC (rev 904) @@ -4,19 +4,38 @@ * and open the template in the editor. */ var ChannelTools = Class.extend({ + init: function() { }, + findChannel: function(channelCollection, channel, step) { - for (var keys = Object.keys(channelCollection) in channelCollection) { - if (channelCollection[keys] == channel) { - return channelCollection[Math.abs((keys%(channelCollection.length))+step)]; + for (var i = 0, l = channelCollection.length; i < l; i++ ) { + + if (channelCollection[i] == channel) { + + if ((i == 0) && (step == -1)) { + var index = channelCollection.length + step; + + } else { + + if((i == (channelCollection.length-1)) && (step == 1)) { + index = 0; + + } else { + index = i + step; + + } + } + return channelCollection[index]; } } return null; }, + isAValidDVBTChannel: function(channel) { return (channel.onid) && (channel.tsid) && (channel.sid); }, + /* * Description: * This method verify that a tuner is available to receive a channel with this "idType".
participants (1)
-
ygregoï¼ users.nuiton.org