Author: ygrego Date: 2015-06-09 15:28:47 +0000 (Tue, 09 Jun 2015) New Revision: 1658 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1658 Log: Deletion of an unused class + Refactoring of ChannelService class in the ES6 syntax. Removed: oipf/lib/js/utils/Calculation.js Modified: oipf/lib/js/utils/ChannelService.js Deleted: oipf/lib/js/utils/Calculation.js =================================================================== --- oipf/lib/js/utils/Calculation.js 2015-06-09 15:25:25 UTC (rev 1657) +++ oipf/lib/js/utils/Calculation.js 2015-06-09 15:28:47 UTC (rev 1658) @@ -1,11 +0,0 @@ -var Calculation = Class.extend({ - - init: function() { - }, - - genId: function(boundary, adjustment){ - - return Math.floor((Math.random() * boundary) + adjustment); - } - -}); \ No newline at end of file Modified: oipf/lib/js/utils/ChannelService.js =================================================================== --- oipf/lib/js/utils/ChannelService.js 2015-06-09 15:25:25 UTC (rev 1657) +++ oipf/lib/js/utils/ChannelService.js 2015-06-09 15:28:47 UTC (rev 1658) @@ -1,20 +1,16 @@ -/* +/* * 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 ChannelService = Class.extend({ - - channelObject: { +class ChannelService { - }, - - init: function(currentChannel, channelNumber, channelOrigin, channelList) { + constructor(currentChannel, channelNumber, channelOrigin, channelList) { this.channelNumber = channelNumber; this.channelOrigin = channelOrigin; this.channelListArray = channelList; - + this.getNumber = oipf.utils.generateFourDigit.bind(null); this.channelList = new ChannelList(); @@ -22,54 +18,54 @@ this.favouriteLists = new FavouriteListCollection(); this.currentFavouriteList = new FavouriteList(); this.setCurrentChannel(currentChannel); - }, - - createChannelList: function() { + } + + createChannelList() { if (this.channelNumber > 0) { - + for (var i = 0, li = this.channelListArray.length; i < li; i++) { var channel = this.channelListArray[i]; var newOipfChannel = new Channel(channel); this.channelList && this.channelList.push(newOipfChannel); - + } } - }, - - setCurrentChannel: function(name) { + } + + setCurrentChannel(name) { this.currentChannel = this.getChannelByName(this.channelList, name); - + if (!this.currentChannel && this.channelList) { var channel = this.channelList[0]; - + if (channel) { this.currentChannel = channel; - } - } - }, - - getChannelByName: function(channelCollection, channelName) { + } + } + } + + getChannelByName(channelCollection, channelName) { for (var i = 0, li = channelCollection.length; i < li; i++) { if (channelCollection[i].name == channelName) { return channelCollection[i]; } } - }, - - prevChannel: function(channelCollection, channel) { + } + + prevChannel(channelCollection, channel) { return channelUtils.findChannel(channelCollection, channel, -1); - }, - - nextChannel: function(channelCollection, channel) { + } + + nextChannel(channelCollection, channel) { return channelUtils.findChannel(channelCollection, channel, 1); - }, - - getADvbTChannel: function(name) { - return new Channel(ID_DVB_T, + } + + getADvbTChannel(name) { + return new Channel(ID_DVB_T, this.getNumber(), this.getNumber(), this.getNumber(), name); - } - -}); + } + +}
participants (1)
-
ygregoï¼ users.nuiton.org