define(['jQuery'], function ($) { 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 = parseISO8601Date(program.StartDate, { toLocal: true }); var startDateText = LibraryBrowser.getFutureDateText(startDate); var endDate = parseISO8601Date(program.EndDate, { toLocal: true }); if (startDateText != currentIndexValue) { html += '

' + startDateText + '

'; currentIndexValue = startDateText; } html += ''; var cssClass = "tvProgramTimeSlot"; if (now >= startDate && now < endDate) { cssClass += " tvProgramCurrentTimeSlot"; } html += '
'; html += '
' + LibraryBrowser.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('LabelLiveProgram') + '  '; } else if (program.IsPremiere) { html += '' + Globalize.translate('LabelPremiereProgram') + '  '; } else if (program.IsSeries && !program.IsRepeat) { html += '' + Globalize.translate('LabelNewProgram') + '  '; } 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 += '
'; } $('#childrenContent', page).html(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 }; });