epgd.channels = {
list: null,
autoCompleteData: null,
isDirty: false,
selBox: $('')[0],
load: function () {
if (!this.list || this.isDirty) {
epgd.ajax({ url: epgd.login.url + "data/channels", async: false, cache: false},function (data) {
var logoPath = (epgd.profile.channelLogoPath ? epgd.profile.channelLogoPath + '?maxW=70&maxH=50&id=' : false),
channelOpt = '',
list = {},
ac_data = [];
data.channels && $.each(data.channels, function (i, channel) {
var id = channel.channelid || i;
if (channel.name) {
channel.html = '
' + (logoPath ? '
'
+ '
'
+ (epgd.profile.logoShowName == "1" ? channel.name : '') : channel.name) + '
';
channel.visible & 1 && (channelOpt += '');
}
else {
channel.html = ''
+ '' + id + '
';
channel.visible & 1 && (channelOpt += '');
}
list[id] = channel;
ac_data.push({ label: channel.name, value: id });
});
epgd.channels.list = list;
epgd.channels.autoCompleteData= ac_data;
$(epgd.channels.selBox).html(channelOpt);
$(window).trigger('channels_load');
this.dirty = false;
});
}
},
getHtml: function (id) {
var ch = this.list[id];
return ch ? ch.html : ''
+ '' + id + '
';
},
getName: function (id) {
var ch = this.list[id];
return ch ? ch.name : id;
}
};