jellyfin-web/dashboard-ui/scripts/livetvcomponents.js

148 lines
5.1 KiB
JavaScript
Raw Normal View History

2016-05-05 19:55:15 -07:00
define(['datetime'], function (datetime) {
2015-05-22 12:16:14 -07:00
2015-09-07 21:22:38 -07:00
function getTimersHtml(timers) {
2015-12-14 08:43:03 -07:00
return new Promise(function (resolve, reject) {
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
require(['paper-fab', 'paper-item-body', 'paper-icon-item'], function () {
var html = '';
var index = '';
var imgUrl;
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
for (var i = 0, length = timers.length; i < length; i++) {
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
var timer = timers[i];
2015-09-07 21:22:38 -07:00
2016-05-05 21:50:06 -07:00
var startDateText = LibraryBrowser.getFutureDateText(datetime.parseISO8601Date(timer.StartDate, true));
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
if (startDateText != index) {
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
if (index) {
html += '</div>';
html += '</div>';
}
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
html += '<div class="homePageSection">';
html += '<h1>' + startDateText + '</h1>';
html += '<div class="paperList">';
index = startDateText;
}
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
html += '<paper-icon-item>';
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
var program = timer.ProgramInfo || {};
2015-09-07 21:22:38 -07:00
imgUrl = null;
2015-12-14 08:43:03 -07:00
if (program.ImageTags && program.ImageTags.Primary) {
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
imgUrl = ApiClient.getScaledImageUrl(program.Id, {
height: 80,
tag: program.ImageTags.Primary,
type: "Primary"
});
}
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
if (imgUrl) {
2016-02-18 11:19:18 -07:00
html += '<paper-fab mini class="blue lazy" data-src="' + imgUrl + '" style="background-repeat:no-repeat;background-position:center center;background-size: cover;" item-icon></paper-fab>';
2015-12-14 08:43:03 -07:00
}
else if (program.IsKids) {
html += '<paper-fab mini style="background:#2196F3;" icon="person" item-icon></paper-fab>';
}
else if (program.IsSports) {
html += '<paper-fab mini style="background:#8BC34A;" icon="person" item-icon></paper-fab>';
}
else if (program.IsMovie) {
html += '<paper-fab mini icon="movie" item-icon></paper-fab>';
}
else if (program.IsNews) {
html += '<paper-fab mini style="background:#673AB7;" icon="new-releases" item-icon></paper-fab>';
}
else {
html += '<paper-fab mini class="blue" icon="live-tv" item-icon></paper-fab>';
}
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
html += '<paper-item-body two-line>';
html += '<a class="clearLink" href="livetvtimer.html?id=' + timer.Id + '">';
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
html += '<div>';
html += timer.Name;
html += '</div>';
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
html += '<div secondary>';
2016-05-05 19:55:15 -07:00
html += datetime.getDisplayTime(timer.StartDate);
html += ' - ' + datetime.getDisplayTime(timer.EndDate);
2015-12-14 08:43:03 -07:00
html += '</div>';
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
html += '</a>';
html += '</paper-item-body>';
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
if (timer.SeriesTimerId) {
html += '<div class="ui-li-aside" style="right:0;">';
html += '<div class="timerCircle seriesTimerCircle"></div>';
html += '<div class="timerCircle seriesTimerCircle"></div>';
html += '<div class="timerCircle seriesTimerCircle"></div>';
html += '</div>';
}
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
html += '<paper-icon-button icon="cancel" data-timerid="' + timer.Id + '" title="' + Globalize.translate('ButonCancelRecording') + '" class="btnDeleteTimer"></paper-icon-button>';
2015-09-07 21:22:38 -07:00
2015-12-14 08:43:03 -07:00
html += '</paper-icon-item>';
}
if (timers.length) {
html += '</div>';
html += '</div>';
}
resolve(html);
});
});
2015-09-07 21:22:38 -07:00
}
2015-05-22 12:16:14 -07:00
window.LiveTvHelpers = {
getDaysOfWeek: function () {
var days = [
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
];
return days.map(function (d) {
return {
name: d,
value: d
};
});
},
renderOriginalAirDate: function (elem, item) {
2015-09-29 09:29:06 -07:00
var airDate = item.PremiereDate;
2015-05-22 12:16:14 -07:00
if (airDate && item.IsRepeat) {
try {
2016-05-05 21:50:06 -07:00
airDate = datetime.parseISO8601Date(airDate, true).toLocaleDateString();
2015-05-22 12:16:14 -07:00
}
catch (e) {
2015-12-23 10:46:01 -07:00
console.log("Error parsing date: " + airDate);
2015-05-22 12:16:14 -07:00
}
elem.html(Globalize.translate('ValueOriginalAirDate').replace('{0}', airDate)).show();
} else {
elem.hide();
}
2015-09-07 21:22:38 -07:00
},
getTimersHtml: getTimersHtml
2015-05-22 12:16:14 -07:00
};
});