Author: ygrego Date: 2015-03-11 12:44:10 +0000 (Wed, 11 Mar 2015) New Revision: 931 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/931 Log: Implementation of method "getChannelByTriplet". Modified: oipf/js/impl/model/ChannelList.js Modified: oipf/js/impl/model/ChannelList.js =================================================================== --- oipf/js/impl/model/ChannelList.js 2015-03-11 11:19:15 UTC (rev 930) +++ oipf/js/impl/model/ChannelList.js 2015-03-11 12:44:10 UTC (rev 931) @@ -24,12 +24,12 @@ * Return: Channel */ getChannel: function(channelID) { - for (var i = 0; i < this.super.length; i++) { + for (var i = 0; i < this.length; i++) { var channel = (this)[i]; - console.log(channel.channelId, channelID, "----------------OUT", channel); - console.log("Test", channel.channelID == channelID, channel.channelId, channelID); - if (channel.channelID == channelID) { - console.log(channel, "----------------"); + console.log("channelId:38" == "channelId:38" , channel.channelId, channelID, "----------------OUT", channel); + console.log(channel.channelId, channelID, "-----------------"); + if (channel.channelId == channelID) { + console.log(channel, "OK----------------"); return channel; } } @@ -60,7 +60,30 @@ * Return: Channel */ getChannelByTriplet: function(onid, tsid, sid, nid) { - + var self = this; + + if (nid) { + + var test = function(i) { + + if (self[i].onid == onid && self[i].tsid == tsid && self[i].sid == sid && self[i].nid == nid) { + return self[i]; + } + }; + + } else { + test = function(i) { + + if (self[i].onid == onid && self[i].tsid == tsid && self[i].sid == sid) { + return self[i]; + } + }; + } + + for (var i = 0, l = this.length; i < l; i++) { + + test(i); + } }, /*
participants (1)
-
ygregoï¼ users.nuiton.org