Author: ygrego Date: 2015-03-11 14:31:03 +0000 (Wed, 11 Mar 2015) New Revision: 935 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/935 Log: The methods which was contained in "ChannelUtils" become javascript "anonymous functions". Added: oipf/js/utils/ChannelUtils.js Removed: oipf/js/utils/ChannelTools.js Deleted: oipf/js/utils/ChannelTools.js =================================================================== --- oipf/js/utils/ChannelTools.js 2015-03-11 14:03:55 UTC (rev 934) +++ oipf/js/utils/ChannelTools.js 2015-03-11 14:31:03 UTC (rev 935) @@ -1,120 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -var ChannelTools = Class.extend({ - - init: function() { - }, - - findChannel: function(channelCollection, channel, 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". - * And return the first tuner found which match the "idType". - * Actually all video broadcast will use the same tuner because there is only one and - * this choice would be directed by parameter. - * - * ToDo :Normally the method should check if the tuner don't locked by another object but - * no way to do that in the norm. - * - * Argument: - * - idType : the type of tuner researched. - * - * Return: Tuner - */ - verifyASuitableTunerAvailable: function(idType, object) { - var config = oipfObjectFactory.createConfigurationObject(); - var availableTuners = config.localSystem.tuners; - - for (var i = 0; i < availableTuners.length; i++) { - var tunerIdTypes = availableTuners[i].idTypes; - for (var j = 0; j < tunerIdTypes.length; j++) { - var tuner = availableTuners[i]; - if (tunerIdTypes[j] == idType) { - return tuner; - } - } - } - - if (idType == 40 || idType == 41) { - object.onChannelChangeError && object.onChannelChangeError(null, 8); - } else { - //this.onChannelChangeError && this.onChannelChangeError(null, 2); - object.onChannelChangeError && object.onChannelChangeError(null, 0); - } - return null; - }, - - getChannelByDsd: function(channelCollection, dsd) { - for (var i = 0, l = channelCollection.length; i < l; i++) { - if (channelCollection[i].dsd == dsd) { - return channelCollection[i]; - } - } - }, - - /* - * Description: - * This method verify the validity of the terrestrial delivery system descriptor. - * The argument will be compare to the dsd array byte defined either in - * the transport stream or directly in the terminal. - * - * Arguments - * - dsd: the delivery system descriptor string necessary to create a channel by intermediate of method - * createChannelObject. - */ - isAValidTerrestrialDsd: function(dsd) { - var dsdAttributes = dsd.split(","); - - if (TERRESTIAL_DELIVERY_SYSTEM_DESCRIPTOR.length == dsdAttributes.length) { - - for (var i = 0, l = TERRESTIAL_DELIVERY_SYSTEM_DESCRIPTOR.length; i < l; i++) { - - if (!(TERRESTIAL_DELIVERY_SYSTEM_DESCRIPTOR[i] == dsdAttributes[i])) { - return false; - } - } - - return true; - } - }, - - getChannelByIpBroadcastID: function(channelCollection, ipBroadcastID) { - for (var i = 0, l = channelCollection.length; i < l; i++) { - if (channelCollection[i].ipBroadcastID == ipBroadcastID) { - return channelCollection[i]; - } - } - } - -}); - Copied: oipf/js/utils/ChannelUtils.js (from rev 933, oipf/js/utils/ChannelTools.js) =================================================================== --- oipf/js/utils/ChannelUtils.js (rev 0) +++ oipf/js/utils/ChannelUtils.js 2015-03-11 14:31:03 UTC (rev 935) @@ -0,0 +1,107 @@ +function findChannel(channelCollection, channel, 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; +} + +function isAValidDVBTChannel(channel) { + return (channel.onid) && (channel.tsid) && (channel.sid); +} + +/* + * Description: + * This method verify that a tuner is available to receive a channel with this "idType". + * And return the first tuner found which match the "idType". + * Actually all video broadcast will use the same tuner because there is only one and + * this choice would be directed by parameter. + * + * ToDo :Normally the method should check if the tuner don't locked by another object but + * no way to do that in the norm. + * + * Argument: + * - idType : the type of tuner researched. + * + * Return: Tuner + */ +function verifyASuitableTunerAvailable(idType, object) { + var config = oipfObjectFactory.createConfigurationObject(); + var availableTuners = config.localSystem.tuners; + + for (var i = 0; i < availableTuners.length; i++) { + var tunerIdTypes = availableTuners[i].idTypes; + for (var j = 0; j < tunerIdTypes.length; j++) { + var tuner = availableTuners[i]; + if (tunerIdTypes[j] == idType) { + return tuner; + } + } + } + + if (idType == 40 || idType == 41) { + object.onChannelChangeError && object.onChannelChangeError(null, 8); + } else { + //this.onChannelChangeError && this.onChannelChangeError(null, 2); + object.onChannelChangeError && object.onChannelChangeError(null, 0); + } + return null; +} + +function getChannelByDsd(channelCollection, dsd) { + for (var i = 0, l = channelCollection.length; i < l; i++) { + if (channelCollection[i].dsd == dsd) { + return channelCollection[i]; + } + } +} + +/* + * Description: + * This method verify the validity of the terrestrial delivery system descriptor. + * The argument will be compare to the dsd array byte defined either in + * the transport stream or directly in the terminal. + * + * Arguments + * - dsd: the delivery system descriptor string necessary to create a channel by intermediate of method + * createChannelObject. + */ +function isAValidTerrestrialDsd(dsd) { + var dsdAttributes = dsd.split(","); + + if (TERRESTIAL_DELIVERY_SYSTEM_DESCRIPTOR.length == dsdAttributes.length) { + + for (var i = 0, l = TERRESTIAL_DELIVERY_SYSTEM_DESCRIPTOR.length; i < l; i++) { + + if (!(TERRESTIAL_DELIVERY_SYSTEM_DESCRIPTOR[i] == dsdAttributes[i])) { + return false; + } + } + + return true; + } +} + +function getChannelByIpBroadcastID(channelCollection, ipBroadcastID) { + for (var i = 0, l = channelCollection.length; i < l; i++) { + if (channelCollection[i].ipBroadcastID == ipBroadcastID) { + return channelCollection[i]; + } + } +}