define(['datetime', 'tvguide'], function (datetime) { function renderPrograms(page, result) { var html = ''; var currentIndexValue; var now = new Date(); for (var i = 0, length = result.Items.length; i < length; i++) { var program = result.Items[i]; var startDate = datetime.parseISO8601Date(program.StartDate, true); var startDateText = LibraryBrowser.getFutureDateText(startDate); var endDate = datetime.parseISO8601Date(program.EndDate, true); if (startDateText != currentIndexValue) { html += '

' + startDateText + '

'; currentIndexValue = startDateText; } html += ''; var cssClass = "tvProgramTimeSlot"; if (now >= startDate && now < endDate) { cssClass += " tvProgramCurrentTimeSlot"; } html += '
'; html += '
' + datetime.getDisplayTime(startDate) + '
'; html += '
'; cssClass = "tvProgramInfo"; if (program.IsKids) { cssClass += " childProgramInfo"; } else if (program.IsSports) { cssClass += " sportsProgramInfo"; } else if (program.IsNews) { cssClass += " newsProgramInfo"; } else if (program.IsMovie) { cssClass += " movieProgramInfo"; } html += '
'; var name = program.Name; html += '
' + name + '
'; html += '
'; if (program.IsLive) { html += '' + Globalize.translate('AttributeLive') + '  '; } else if (program.IsPremiere) { html += '' + Globalize.translate('AttributePremiere') + '  '; } else if (program.IsSeries && !program.IsRepeat) { html += '' + Globalize.translate('AttributeNew') + '  '; } var minutes = program.RunTimeTicks / 600000000; minutes = Math.round(minutes || 1) + ' min'; if (program.EpisodeTitle) { html += program.EpisodeTitle + '  (' + minutes + ')'; } else { html += minutes; } if (program.SeriesTimerId) { html += '
'; html += '
'; html += '
'; } else if (program.TimerId) { html += '
'; } html += '
'; html += '
'; html += '
'; html += '
'; } page.querySelector('#childrenContent').innerHTML = html; } function loadPrograms(page, channelId) { ApiClient.getLiveTvPrograms({ ChannelIds: channelId, UserId: Dashboard.getCurrentUserId(), HasAired: false, SortBy: "StartDate" }).then(function (result) { renderPrograms(page, result); Dashboard.hideLoadingMsg(); }); } window.LiveTvChannelPage = { renderPrograms: loadPrograms }; });