2014-10-15 20:26:39 -07:00
|
|
|
|
(function ($, document) {
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
2014-01-06 06:33:14 -07:00
|
|
|
|
// 30 mins
|
2015-04-13 20:28:11 -07:00
|
|
|
|
var cellCurationMinutes = 30;
|
2014-01-06 09:48:43 -07:00
|
|
|
|
var cellDurationMs = cellCurationMinutes * 60 * 1000;
|
2015-04-13 20:28:11 -07:00
|
|
|
|
var msPerDay = 86400000;
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2014-01-07 11:39:35 -07:00
|
|
|
|
var currentDate;
|
2014-01-10 06:52:01 -07:00
|
|
|
|
|
|
|
|
|
var channelQuery = {
|
|
|
|
|
|
|
|
|
|
StartIndex: 0,
|
2015-04-12 09:46:29 -07:00
|
|
|
|
Limit: 50,
|
2015-04-11 18:38:38 -07:00
|
|
|
|
EnableFavoriteSorting: true
|
2014-01-10 06:52:01 -07:00
|
|
|
|
};
|
2014-01-07 11:39:35 -07:00
|
|
|
|
var channelsPromise;
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
2014-05-23 16:58:28 -07:00
|
|
|
|
function showLoadingMessage(page) {
|
|
|
|
|
|
|
|
|
|
$('.popupLoading', page).popup('open');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hideLoadingMessage(page) {
|
|
|
|
|
$('.popupLoading', page).popup('close');
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-05 18:59:21 -07:00
|
|
|
|
function normalizeDateToTimeslot(date) {
|
|
|
|
|
|
2014-01-06 09:48:43 -07:00
|
|
|
|
var minutesOffset = date.getMinutes() - cellCurationMinutes;
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
|
|
|
|
if (minutesOffset >= 0) {
|
|
|
|
|
|
2014-01-06 09:48:43 -07:00
|
|
|
|
date.setHours(date.getHours(), cellCurationMinutes, 0, 0);
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
2014-01-06 09:48:43 -07:00
|
|
|
|
date.setHours(date.getHours(), 0, 0, 0);
|
2014-01-05 18:59:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return date;
|
|
|
|
|
}
|
2014-01-15 15:19:45 -07:00
|
|
|
|
|
2014-01-10 06:52:01 -07:00
|
|
|
|
function reloadChannels(page) {
|
|
|
|
|
channelsPromise = null;
|
|
|
|
|
reloadGuide(page);
|
|
|
|
|
}
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
|
|
|
|
function reloadGuide(page) {
|
|
|
|
|
|
2014-05-23 16:58:28 -07:00
|
|
|
|
showLoadingMessage(page);
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
2014-01-10 06:52:01 -07:00
|
|
|
|
channelQuery.userId = Dashboard.getCurrentUserId();
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
2014-10-15 20:26:39 -07:00
|
|
|
|
channelsPromise = channelsPromise || ApiClient.getLiveTvChannels(channelQuery);
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
|
|
|
|
var date = currentDate;
|
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
var nextDay = new Date(date.getTime() + msPerDay - 1);
|
2014-01-10 22:49:18 -07:00
|
|
|
|
console.log(nextDay);
|
2014-01-15 15:19:45 -07:00
|
|
|
|
channelsPromise.done(function (channelsResult) {
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
2014-10-15 20:26:39 -07:00
|
|
|
|
ApiClient.getLiveTvPrograms({
|
2014-01-10 06:52:01 -07:00
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
|
|
|
MaxStartDate: nextDay.toISOString(),
|
|
|
|
|
MinEndDate: date.toISOString(),
|
2014-01-15 15:19:45 -07:00
|
|
|
|
channelIds: channelsResult.Items.map(function (c) {
|
2014-01-10 06:52:01 -07:00
|
|
|
|
return c.Id;
|
|
|
|
|
}).join(',')
|
2014-01-15 15:19:45 -07:00
|
|
|
|
|
|
|
|
|
}).done(function (programsResult) {
|
|
|
|
|
|
2014-01-10 06:52:01 -07:00
|
|
|
|
renderGuide(page, date, channelsResult.Items, programsResult.Items);
|
2015-04-13 20:28:11 -07:00
|
|
|
|
|
2014-05-23 16:58:28 -07:00
|
|
|
|
hideLoadingMessage(page);
|
|
|
|
|
|
2014-01-10 06:52:01 -07:00
|
|
|
|
});
|
2014-01-15 15:19:45 -07:00
|
|
|
|
|
2014-01-10 06:52:01 -07:00
|
|
|
|
var channelPagingHtml = LibraryBrowser.getPagingHtml(channelQuery, channelsResult.TotalRecordCount, false, [10, 20, 30, 50, 100]);
|
|
|
|
|
$('.channelPaging', page).html(channelPagingHtml).trigger('create');
|
|
|
|
|
|
|
|
|
|
$('.btnNextPage', page).on('click', function () {
|
|
|
|
|
channelQuery.StartIndex += channelQuery.Limit;
|
|
|
|
|
reloadChannels(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnPreviousPage', page).on('click', function () {
|
|
|
|
|
channelQuery.StartIndex -= channelQuery.Limit;
|
|
|
|
|
reloadChannels(page);
|
|
|
|
|
});
|
2015-04-14 08:26:02 -07:00
|
|
|
|
|
|
|
|
|
$('.selectPageSize', page).on('change', function () {
|
|
|
|
|
channelQuery.Limit = parseInt(this.value);
|
|
|
|
|
channelQuery.StartIndex = 0;
|
|
|
|
|
reloadChannels(page);
|
|
|
|
|
});
|
2014-01-05 18:59:21 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
function getTimeslotHeadersHtml(startDate, endDateTime) {
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
// clone
|
|
|
|
|
startDate = new Date(startDate.getTime());
|
|
|
|
|
|
|
|
|
|
html += '<div class="timeslotHeadersInner">'
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
while (startDate.getTime() < endDateTime) {
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
|
|
|
|
html += '<div class="timeslotHeader">';
|
2014-01-06 06:33:14 -07:00
|
|
|
|
html += '<div class="timeslotHeaderInner">';
|
2015-03-18 22:56:55 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
html += LiveTvHelpers.getDisplayTime(startDate);
|
2014-01-05 18:59:21 -07:00
|
|
|
|
html += '</div>';
|
2014-01-06 06:33:14 -07:00
|
|
|
|
html += '</div>';
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
|
|
|
|
// Add 30 mins
|
2015-04-13 20:28:11 -07:00
|
|
|
|
startDate.setTime(startDate.getTime() + cellDurationMs);
|
2014-01-05 18:59:21 -07:00
|
|
|
|
}
|
2015-04-13 20:28:11 -07:00
|
|
|
|
html += '</div>';
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
function parseDates(program) {
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
if (!program.StartDateLocal) {
|
|
|
|
|
try {
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
program.StartDateLocal = parseISO8601Date(program.StartDate, { toLocal: true });
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
} catch (err) {
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
}
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
if (!program.EndDateLocal) {
|
|
|
|
|
try {
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
program.EndDateLocal = parseISO8601Date(program.EndDate, { toLocal: true });
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
} catch (err) {
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getChannelProgramsHtml(page, date, channel, programs) {
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
var startMs = date.getTime();
|
|
|
|
|
var endMs = startMs + msPerDay - 1;
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
|
|
|
|
programs = programs.filter(function (curr) {
|
|
|
|
|
return curr.ChannelId == channel.Id;
|
|
|
|
|
});
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
2014-01-06 06:33:14 -07:00
|
|
|
|
html += '<div class="channelPrograms">';
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
for (var i = 0, length = programs.length; i < length; i++) {
|
2014-01-06 09:48:43 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
var program = programs[i];
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
if (program.ChannelId != channel.Id) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
parseDates(program);
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
if (program.EndDateLocal.getTime() < startMs) {
|
|
|
|
|
continue;
|
2015-03-18 22:56:55 -07:00
|
|
|
|
}
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
if (program.StartDateLocal.getTime() > endMs) {
|
|
|
|
|
break;
|
2014-01-06 06:33:14 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
var renderStartMs = Math.max(program.StartDateLocal.getTime(), startMs);
|
|
|
|
|
var startPercent = (program.StartDateLocal.getTime() - startMs) / msPerDay;
|
|
|
|
|
startPercent *= 100;
|
|
|
|
|
startPercent = Math.max(startPercent, 0);
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
var renderEndMs = Math.min(program.EndDateLocal.getTime(), endMs);
|
|
|
|
|
var endPercent = (renderEndMs - renderStartMs) / msPerDay;
|
|
|
|
|
endPercent *= 100;
|
2014-01-10 06:52:01 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
html += '<div class="programCell" style="left:' + startPercent + '%;width:' + endPercent + '%;">';
|
2014-01-06 09:48:43 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
var cssClass = "programCellInner";
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
if (program.IsKids) {
|
|
|
|
|
cssClass += " childProgramInfo";
|
|
|
|
|
} else if (program.IsSports) {
|
|
|
|
|
cssClass += " sportsProgramInfo";
|
|
|
|
|
} else if (program.IsNews) {
|
|
|
|
|
cssClass += " newsProgramInfo";
|
|
|
|
|
} else if (program.IsMovie) {
|
|
|
|
|
cssClass += " movieProgramInfo";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cssClass += " plainProgramInfo";
|
|
|
|
|
}
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
html += '<a href="livetvprogram.html?id=' + program.Id + '" class="' + cssClass + '" data-programid="' + program.Id + '">';
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
html += '<div class="guideProgramName">';
|
|
|
|
|
html += program.Name;
|
|
|
|
|
html += '</div>';
|
2014-01-06 09:48:43 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
html += '<div class="guideProgramTime">';
|
|
|
|
|
if (program.IsLive) {
|
|
|
|
|
html += '<span class="liveTvProgram">' + Globalize.translate('LabelLiveProgram') + ' </span>';
|
|
|
|
|
}
|
|
|
|
|
else if (program.IsPremiere) {
|
|
|
|
|
html += '<span class="premiereTvProgram">' + Globalize.translate('LabelPremiereProgram') + ' </span>';
|
|
|
|
|
}
|
|
|
|
|
else if (program.IsSeries && !program.IsRepeat) {
|
|
|
|
|
html += '<span class="newTvProgram">' + Globalize.translate('LabelNewProgram') + ' </span>';
|
|
|
|
|
}
|
2014-01-06 09:48:43 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
html += LiveTvHelpers.getDisplayTime(program.StartDateLocal);
|
|
|
|
|
html += ' - ';
|
|
|
|
|
html += LiveTvHelpers.getDisplayTime(program.EndDateLocal);
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
if (program.SeriesTimerId) {
|
|
|
|
|
html += '<div class="timerCircle seriesTimerCircle"></div>';
|
|
|
|
|
html += '<div class="timerCircle seriesTimerCircle"></div>';
|
|
|
|
|
html += '<div class="timerCircle seriesTimerCircle"></div>';
|
2014-01-06 06:33:14 -07:00
|
|
|
|
}
|
2015-04-13 20:28:11 -07:00
|
|
|
|
else if (program.TimerId) {
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
html += '<div class="timerCircle"></div>';
|
|
|
|
|
}
|
2014-01-06 06:33:14 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2015-04-13 20:28:11 -07:00
|
|
|
|
html += '</a>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
2014-01-06 06:33:14 -07:00
|
|
|
|
}
|
2015-04-13 20:28:11 -07:00
|
|
|
|
|
2014-01-05 18:59:21 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-06 06:33:14 -07:00
|
|
|
|
function renderPrograms(page, date, channels, programs) {
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
|
|
|
|
var html = [];
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = channels.length; i < length; i++) {
|
|
|
|
|
|
2014-01-06 06:33:14 -07:00
|
|
|
|
html.push(getChannelProgramsHtml(page, date, channels[i], programs));
|
2014-01-05 18:59:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-15 15:19:45 -07:00
|
|
|
|
$('.programGrid', page).html(html.join('')).scrollTop(0).scrollLeft(0)
|
2015-04-13 20:28:11 -07:00
|
|
|
|
.createGuideHoverMenu('.programCellInner');
|
2014-01-06 06:33:14 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderChannelHeaders(page, channels) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = channels.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var channel = channels[i];
|
|
|
|
|
|
|
|
|
|
html += '<div class="channelHeaderCellContainer">';
|
|
|
|
|
|
2014-01-06 09:48:43 -07:00
|
|
|
|
html += '<div class="channelHeaderCell">';
|
|
|
|
|
html += '<a class="channelHeaderCellInner" href="livetvchannel.html?id=' + channel.Id + '">';
|
2014-01-06 11:25:33 -07:00
|
|
|
|
|
|
|
|
|
html += '<div class="guideChannelInfo">' + channel.Name + '<br/>' + channel.Number + '</div>';
|
|
|
|
|
|
|
|
|
|
if (channel.ImageTags.Primary) {
|
|
|
|
|
|
2014-05-23 16:58:28 -07:00
|
|
|
|
var url = ApiClient.getScaledImageUrl(channel.Id, {
|
|
|
|
|
maxHeight: 35,
|
|
|
|
|
maxWidth: 60,
|
2014-01-06 11:25:33 -07:00
|
|
|
|
tag: channel.ImageTags.Primary,
|
|
|
|
|
type: "Primary"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
html += '<img class="guideChannelImage" src="' + url + '" />';
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-06 09:48:43 -07:00
|
|
|
|
html += '</a>';
|
2014-01-06 06:33:14 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('.channelList', page).html(html);
|
2014-01-05 18:59:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderGuide(page, date, channels, programs) {
|
|
|
|
|
|
2014-01-06 06:33:14 -07:00
|
|
|
|
renderChannelHeaders(page, channels);
|
2015-04-13 20:28:11 -07:00
|
|
|
|
|
|
|
|
|
var startDate = date;
|
|
|
|
|
var endDate = new Date(startDate.getTime() + msPerDay);
|
|
|
|
|
$('.timeslotHeaders', page).html(getTimeslotHeadersHtml(startDate, endDate));
|
2014-01-06 06:33:14 -07:00
|
|
|
|
renderPrograms(page, date, channels, programs);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-12 09:46:29 -07:00
|
|
|
|
var gridScrolling = false;
|
|
|
|
|
var headersScrolling = false;
|
2014-01-06 06:33:14 -07:00
|
|
|
|
function onProgramGridScroll(page, elem) {
|
|
|
|
|
|
2015-04-12 09:46:29 -07:00
|
|
|
|
if (!headersScrolling) {
|
|
|
|
|
gridScrolling = true;
|
|
|
|
|
var grid = $(elem);
|
2014-01-06 06:33:14 -07:00
|
|
|
|
|
2015-04-12 09:46:29 -07:00
|
|
|
|
$('.timeslotHeaders', page).scrollLeft(grid.scrollLeft());
|
|
|
|
|
gridScrolling = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onTimeslotHeadersScroll(page, elem) {
|
|
|
|
|
|
|
|
|
|
if (!gridScrolling) {
|
|
|
|
|
headersScrolling = true;
|
|
|
|
|
elem = $(elem);
|
|
|
|
|
$('.programGrid', page).scrollLeft(elem.scrollLeft());
|
|
|
|
|
headersScrolling = false;
|
|
|
|
|
}
|
2014-01-05 18:59:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-07 11:39:35 -07:00
|
|
|
|
function changeDate(page, date) {
|
|
|
|
|
|
|
|
|
|
currentDate = normalizeDateToTimeslot(date);
|
|
|
|
|
|
|
|
|
|
reloadGuide(page);
|
2015-04-12 09:46:29 -07:00
|
|
|
|
|
|
|
|
|
var text = LibraryBrowser.getFutureDateText(date);
|
|
|
|
|
text = '<span class="currentDay">' + text.replace(' ', ' </span>');
|
|
|
|
|
$('.currentDate', page).html(text);
|
2014-01-07 11:39:35 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setDateRange(page, guideInfo) {
|
|
|
|
|
|
|
|
|
|
var today = new Date();
|
|
|
|
|
today.setHours(today.getHours(), 0, 0, 0);
|
|
|
|
|
|
|
|
|
|
var start = parseISO8601Date(guideInfo.StartDate, { toLocal: true });
|
|
|
|
|
var end = parseISO8601Date(guideInfo.EndDate, { toLocal: true });
|
|
|
|
|
|
|
|
|
|
start.setHours(0, 0, 0, 0);
|
|
|
|
|
end.setHours(0, 0, 0, 0);
|
|
|
|
|
|
2014-08-16 22:38:13 -07:00
|
|
|
|
if (start.getTime() >= end.getTime()) {
|
|
|
|
|
end.setDate(start.getDate() + 1);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-07 11:39:35 -07:00
|
|
|
|
start = new Date(Math.max(today, start));
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
while (start <= end) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
html += '<option value="' + start.getTime() + '">' + LibraryBrowser.getFutureDateText(start) + '</option>';
|
|
|
|
|
|
|
|
|
|
start.setDate(start.getDate() + 1);
|
|
|
|
|
start.setHours(0, 0, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var elem = $('#selectDate', page).html(html).selectmenu('refresh');
|
2014-01-10 06:52:01 -07:00
|
|
|
|
|
2014-01-07 11:39:35 -07:00
|
|
|
|
if (currentDate) {
|
|
|
|
|
elem.val(currentDate.getTime()).selectmenu('refresh');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var val = elem.val();
|
|
|
|
|
var date = new Date();
|
2014-08-16 22:38:13 -07:00
|
|
|
|
|
|
|
|
|
if (val) {
|
|
|
|
|
date.setTime(parseInt(val));
|
|
|
|
|
}
|
2014-01-07 11:39:35 -07:00
|
|
|
|
|
|
|
|
|
changeDate(page, date);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-06 06:33:14 -07:00
|
|
|
|
$(document).on('pageinit', "#liveTvGuidePage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('.programGrid', page).on('scroll', function () {
|
|
|
|
|
|
|
|
|
|
onProgramGridScroll(page, this);
|
|
|
|
|
});
|
|
|
|
|
|
2014-01-10 06:52:01 -07:00
|
|
|
|
$('#selectDate', page).on('change', function () {
|
|
|
|
|
|
2014-01-07 11:39:35 -07:00
|
|
|
|
var date = new Date();
|
|
|
|
|
date.setTime(parseInt(this.value));
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
2015-04-12 09:46:29 -07:00
|
|
|
|
$('#popupConfig', page).popup('close');
|
2015-04-13 20:28:11 -07:00
|
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
|
|
|
|
|
changeDate(page, date);
|
|
|
|
|
}, 300);
|
2014-01-07 11:39:35 -07:00
|
|
|
|
});
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
2015-04-12 09:46:29 -07:00
|
|
|
|
if ($.browser.mobile) {
|
|
|
|
|
$('.tvGuide', page).addClass('mobileGuide');
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
$('.tvGuide', page).removeClass('mobileGuide');
|
|
|
|
|
|
|
|
|
|
$('.timeslotHeaders', page).on('scroll', function () {
|
|
|
|
|
|
|
|
|
|
onTimeslotHeadersScroll(page, this);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-04 07:35:38 -07:00
|
|
|
|
$('.tvGuideHeader', page).each(function () {
|
|
|
|
|
|
|
|
|
|
// construct an instance of Headroom, passing the element
|
|
|
|
|
var headroom = new Headroom(this);
|
|
|
|
|
// initialise
|
|
|
|
|
headroom.init();
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2015-04-14 08:26:02 -07:00
|
|
|
|
}).on('pageshow', "#liveTvGuidePage", function () {
|
2014-01-06 09:48:43 -07:00
|
|
|
|
|
2014-01-07 11:39:35 -07:00
|
|
|
|
var page = this;
|
2014-01-06 09:48:43 -07:00
|
|
|
|
|
2014-10-15 20:26:39 -07:00
|
|
|
|
ApiClient.getLiveTvGuideInfo().done(function (guideInfo) {
|
2014-01-07 11:39:35 -07:00
|
|
|
|
|
|
|
|
|
setDateRange(page, guideInfo);
|
|
|
|
|
});
|
2014-01-05 18:59:21 -07:00
|
|
|
|
});
|
|
|
|
|
|
2014-10-15 20:26:39 -07:00
|
|
|
|
})(jQuery, document);
|
2014-01-15 15:19:45 -07:00
|
|
|
|
|
|
|
|
|
(function ($, document, window) {
|
|
|
|
|
|
|
|
|
|
var showOverlayTimeout;
|
|
|
|
|
var hideOverlayTimeout;
|
|
|
|
|
var currentPosterItem;
|
|
|
|
|
|
|
|
|
|
function onOverlayMouseOver() {
|
|
|
|
|
|
|
|
|
|
if (hideOverlayTimeout) {
|
|
|
|
|
clearTimeout(hideOverlayTimeout);
|
|
|
|
|
hideOverlayTimeout = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onOverlayMouseOut() {
|
|
|
|
|
|
|
|
|
|
startHideOverlayTimer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getOverlayHtml(item) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<div class="itemOverlayContent">';
|
|
|
|
|
|
|
|
|
|
if (item.EpisodeTitle) {
|
|
|
|
|
html += '<p>';
|
|
|
|
|
html += item.EpisodeTitle;
|
|
|
|
|
html += '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<p class="itemMiscInfo miscTvProgramInfo"></p>';
|
|
|
|
|
|
|
|
|
|
html += '<p style="margin: 1.25em 0;">';
|
2015-01-01 22:36:27 -07:00
|
|
|
|
html += '<span class="itemCommunityRating">';
|
2014-01-15 15:19:45 -07:00
|
|
|
|
html += LibraryBrowser.getRatingHtml(item);
|
2015-01-01 22:36:27 -07:00
|
|
|
|
html += '</span>';
|
2014-01-15 15:19:45 -07:00
|
|
|
|
html += '<span class="userDataIcons">';
|
|
|
|
|
html += LibraryBrowser.getUserDataIconsHtml(item);
|
|
|
|
|
html += '</span>';
|
|
|
|
|
html += '</p>';
|
|
|
|
|
|
|
|
|
|
html += '<p class="itemGenres"></p>';
|
|
|
|
|
|
|
|
|
|
html += '<p class="itemOverlayHtml">';
|
2014-05-27 07:30:21 -07:00
|
|
|
|
html += (item.Overview || '');
|
2014-01-15 15:19:45 -07:00
|
|
|
|
html += '</p>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showOverlay(elem, item) {
|
|
|
|
|
|
|
|
|
|
$('.itemFlyout').popup('close').remove();
|
|
|
|
|
|
|
|
|
|
var html = '<div data-role="popup" class="itemFlyout" data-theme="b" data-arrow="true" data-history="false">';
|
|
|
|
|
|
|
|
|
|
html += '<div class="ui-bar-b" style="text-align:center;">';
|
|
|
|
|
html += '<h3 style="margin: .5em 0;padding:0 1em;font-weight:normal;">' + item.Name + '</h3>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<div style="padding: 0 1em;">';
|
|
|
|
|
html += getOverlayHtml(item);
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
$('.itemFlyout').popup('close').popup('destroy').remove();
|
|
|
|
|
|
|
|
|
|
$(document.body).append(html);
|
|
|
|
|
|
|
|
|
|
var popup = $('.itemFlyout').on('mouseenter', onOverlayMouseOver).on('mouseleave', onOverlayMouseOut).popup({
|
|
|
|
|
|
|
|
|
|
positionTo: elem
|
|
|
|
|
|
|
|
|
|
}).trigger('create').popup("open").on("popupafterclose", function () {
|
|
|
|
|
|
|
|
|
|
$(this).off("popupafterclose").off("mouseenter").off("mouseleave").remove();
|
|
|
|
|
});
|
|
|
|
|
|
2015-01-31 19:41:35 -07:00
|
|
|
|
LibraryBrowser.renderGenres($('.itemGenres', popup), item, 'livetv', 3);
|
2014-01-15 15:19:45 -07:00
|
|
|
|
LiveTvHelpers.renderMiscProgramInfo($('.miscTvProgramInfo', popup), item);
|
|
|
|
|
|
|
|
|
|
popup.parents().prev('.ui-popup-screen').remove();
|
|
|
|
|
currentPosterItem = elem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onProgramClicked() {
|
|
|
|
|
|
|
|
|
|
if (showOverlayTimeout) {
|
|
|
|
|
clearTimeout(showOverlayTimeout);
|
|
|
|
|
showOverlayTimeout = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hideOverlayTimeout) {
|
|
|
|
|
clearTimeout(hideOverlayTimeout);
|
|
|
|
|
hideOverlayTimeout = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hideOverlay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hideOverlay() {
|
|
|
|
|
|
|
|
|
|
$('.itemFlyout').popup('close').remove();
|
|
|
|
|
|
|
|
|
|
if (currentPosterItem) {
|
|
|
|
|
|
|
|
|
|
$(currentPosterItem).off('click.overlay');
|
|
|
|
|
currentPosterItem = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function startHideOverlayTimer() {
|
|
|
|
|
|
|
|
|
|
if (hideOverlayTimeout) {
|
|
|
|
|
clearTimeout(hideOverlayTimeout);
|
|
|
|
|
hideOverlayTimeout = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hideOverlayTimeout = setTimeout(hideOverlay, 200);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onHoverOut() {
|
|
|
|
|
|
|
|
|
|
if (showOverlayTimeout) {
|
|
|
|
|
clearTimeout(showOverlayTimeout);
|
|
|
|
|
showOverlayTimeout = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startHideOverlayTimer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$.fn.createGuideHoverMenu = function (childSelector) {
|
|
|
|
|
|
|
|
|
|
function onShowTimerExpired(elem) {
|
|
|
|
|
|
|
|
|
|
var id = elem.getAttribute('data-programid');
|
|
|
|
|
|
|
|
|
|
ApiClient.getLiveTvProgram(id, Dashboard.getCurrentUserId()).done(function (item) {
|
|
|
|
|
|
|
|
|
|
showOverlay(elem, item);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onHoverIn() {
|
|
|
|
|
|
|
|
|
|
if (showOverlayTimeout) {
|
|
|
|
|
clearTimeout(showOverlayTimeout);
|
|
|
|
|
showOverlayTimeout = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hideOverlayTimeout) {
|
|
|
|
|
clearTimeout(hideOverlayTimeout);
|
|
|
|
|
hideOverlayTimeout = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var elem = this;
|
|
|
|
|
|
|
|
|
|
if (currentPosterItem) {
|
|
|
|
|
if (currentPosterItem && currentPosterItem == elem) {
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
hideOverlay();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showOverlayTimeout = setTimeout(function () {
|
|
|
|
|
|
|
|
|
|
onShowTimerExpired(elem);
|
|
|
|
|
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// https://hacks.mozilla.org/2013/04/detecting-touch-its-the-why-not-the-how/
|
|
|
|
|
|
|
|
|
|
if (('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)) {
|
|
|
|
|
/* browser with either Touch Events of Pointer Events
|
|
|
|
|
running on touch-capable device */
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.on('mouseenter', childSelector, onHoverIn)
|
|
|
|
|
.on('mouseleave', childSelector, onHoverOut)
|
|
|
|
|
.on('click', childSelector, onProgramClicked);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
})(jQuery, document, window);
|