2020-04-13 13:09:01 +02:00
|
|
|
define(['datetime', 'itemHelper', 'emby-progressbar', 'css!./indicators.css', 'material-icons'], function (datetime, itemHelper) {
|
2019-01-10 15:39:37 +03:00
|
|
|
'use strict';
|
2018-10-23 01:05:09 +03:00
|
|
|
|
|
|
|
function enableProgressIndicator(item) {
|
2019-01-10 15:39:37 +03:00
|
|
|
if (item.MediaType === 'Video') {
|
|
|
|
if (item.Type !== 'TvChannel') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.Type === 'AudioBook' || item.Type === 'AudioPodcast') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getProgressHtml(pct, options) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var containerClass = 'itemProgressBar';
|
|
|
|
if (options) {
|
|
|
|
if (options.containerClass) {
|
|
|
|
containerClass += ' ' + options.containerClass;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return '<div class="' + containerClass + '"><div class="itemProgressBarForeground" style="width:' + pct + '%;"></div></div>';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getAutoTimeProgressHtml(pct, options, isRecording, start, end) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var containerClass = 'itemProgressBar';
|
|
|
|
if (options) {
|
|
|
|
if (options.containerClass) {
|
|
|
|
containerClass += ' ' + options.containerClass;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var foregroundClass = 'itemProgressBarForeground';
|
|
|
|
if (isRecording) {
|
|
|
|
foregroundClass += ' itemProgressBarForeground-recording';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '<div is="emby-progressbar" data-automode="time" data-starttime="' + start + '" data-endtime="' + end + '" class="' + containerClass + '"><div class="' + foregroundClass + '" style="width:' + pct + '%;"></div></div>';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getProgressBarHtml(item, options) {
|
|
|
|
var pct;
|
2020-05-04 12:44:12 +02:00
|
|
|
if (enableProgressIndicator(item) && item.Type !== 'Recording') {
|
2019-01-10 15:39:37 +03:00
|
|
|
var userData = options ? (options.userData || item.UserData) : item.UserData;
|
|
|
|
if (userData) {
|
|
|
|
pct = userData.PlayedPercentage;
|
|
|
|
if (pct && pct < 100) {
|
|
|
|
return getProgressHtml(pct, options);
|
|
|
|
}
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
if ((item.Type === 'Program' || item.Type === 'Timer' || item.Type === 'Recording') && item.StartDate && item.EndDate) {
|
|
|
|
var startDate = 0;
|
|
|
|
var endDate = 1;
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
try {
|
2019-01-10 15:39:37 +03:00
|
|
|
startDate = datetime.parseISO8601Date(item.StartDate).getTime();
|
|
|
|
endDate = datetime.parseISO8601Date(item.EndDate).getTime();
|
|
|
|
} catch (err) {
|
2020-02-16 03:44:43 +01:00
|
|
|
console.error(err);
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
var now = new Date().getTime();
|
|
|
|
var total = endDate - startDate;
|
|
|
|
pct = 100 * ((now - startDate) / total);
|
|
|
|
|
|
|
|
if (pct > 0 && pct < 100) {
|
|
|
|
var isRecording = item.Type === 'Timer' || item.Type === 'Recording' || item.TimerId;
|
|
|
|
return getAutoTimeProgressHtml(pct, options, isRecording, startDate, endDate);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
return '';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function enablePlayedIndicator(item) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return itemHelper.canMarkPlayed(item);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getPlayedIndicator(item) {
|
|
|
|
if (enablePlayedIndicator(item)) {
|
|
|
|
var userData = item.UserData || {};
|
2019-01-10 15:39:37 +03:00
|
|
|
if (userData.UnplayedItemCount) {
|
|
|
|
return '<div class="countIndicator indicator">' + userData.UnplayedItemCount + '</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (userData.PlayedPercentage && userData.PlayedPercentage >= 100 || (userData.Played)) {
|
2020-04-26 02:37:28 +03:00
|
|
|
return '<div class="playedIndicator indicator"><span class="material-icons indicatorIcon check"></span></div>';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
return '';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getCountIndicatorHtml(count) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return '<div class="countIndicator indicator">' + count + '</div>';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getChildCountIndicatorHtml(item, options) {
|
|
|
|
var minCount = 0;
|
2019-01-10 15:39:37 +03:00
|
|
|
if (options) {
|
|
|
|
minCount = options.minCount || minCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.ChildCount && item.ChildCount > minCount) {
|
|
|
|
return getCountIndicatorHtml(item.ChildCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getTimerIndicator(item) {
|
|
|
|
var status;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
if (item.Type === 'SeriesTimer') {
|
2020-04-26 02:37:28 +03:00
|
|
|
return '<span class="material-icons timerIndicator indicatorIcon fiber_smart_record"></span>';
|
2019-05-02 16:03:52 -07:00
|
|
|
} else if (item.TimerId || item.SeriesTimerId) {
|
2019-01-10 15:39:37 +03:00
|
|
|
status = item.Status || 'Cancelled';
|
2019-05-02 16:03:52 -07:00
|
|
|
} else if (item.Type === 'Timer') {
|
2019-01-10 15:39:37 +03:00
|
|
|
status = item.Status;
|
2019-05-02 16:03:52 -07:00
|
|
|
} else {
|
2019-01-10 15:39:37 +03:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.SeriesTimerId) {
|
|
|
|
if (status !== 'Cancelled') {
|
2020-04-26 02:37:28 +03:00
|
|
|
return '<span class="material-icons timerIndicator indicatorIcon fiber_smart_record"></span>';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
2020-04-26 02:37:28 +03:00
|
|
|
return '<span class="material-icons timerIndicator timerIndicator-inactive indicatorIcon fiber_smart_record"></span>';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-04-26 02:37:28 +03:00
|
|
|
return '<span class="material-icons timerIndicator indicatorIcon fiber_manual_record"></span>';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getSyncIndicator(item) {
|
2019-01-10 15:39:37 +03:00
|
|
|
if (item.SyncPercent === 100) {
|
2020-04-26 02:37:28 +03:00
|
|
|
return '<div class="syncIndicator indicator fullSyncIndicator"><span class="material-icons indicatorIcon file_download"></span></div>';
|
2019-01-10 15:39:37 +03:00
|
|
|
} else if (item.SyncPercent != null) {
|
2020-04-26 02:37:28 +03:00
|
|
|
return '<div class="syncIndicator indicator emptySyncIndicator"><span class="material-icons indicatorIcon file_download"></span></div>';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getTypeIndicator(item) {
|
2019-01-10 15:39:37 +03:00
|
|
|
if (item.Type === 'Video') {
|
2020-04-26 02:37:28 +03:00
|
|
|
return '<div class="indicator videoIndicator"><span class="material-icons indicatorIcon videocam"></span></div>';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
2020-02-16 02:34:40 +01:00
|
|
|
if (item.Type === 'Folder') {
|
2020-04-26 02:37:28 +03:00
|
|
|
return '<div class="indicator videoIndicator"><span class="material-icons indicatorIcon folder"></span></div>';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
2020-02-16 02:34:40 +01:00
|
|
|
if (item.Type === 'PhotoAlbum') {
|
2020-04-26 02:37:28 +03:00
|
|
|
return '<div class="indicator videoIndicator"><span class="material-icons indicatorIcon photo_album"></span></div>';
|
2020-02-16 02:34:40 +01:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
if (item.Type === 'Photo') {
|
2020-04-26 02:37:28 +03:00
|
|
|
return '<div class="indicator videoIndicator"><span class="material-icons indicatorIcon photo"></span></div>';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getMissingIndicator(item) {
|
2019-01-10 15:39:37 +03:00
|
|
|
if (item.Type === 'Episode' && item.LocationType === 'Virtual') {
|
|
|
|
if (item.PremiereDate) {
|
|
|
|
try {
|
|
|
|
var premiereDate = datetime.parseISO8601Date(item.PremiereDate).getTime();
|
|
|
|
if (premiereDate > new Date().getTime()) {
|
|
|
|
return '<div class="unairedIndicator">Unaired</div>';
|
|
|
|
}
|
|
|
|
} catch (err) {
|
2020-02-16 03:44:43 +01:00
|
|
|
console.error(err);
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return '<div class="missingIndicator">Missing</div>';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
return '';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
2019-01-10 15:39:37 +03:00
|
|
|
return {
|
2019-08-31 03:12:10 -07:00
|
|
|
getProgressHtml: getProgressHtml,
|
2018-10-23 01:05:09 +03:00
|
|
|
getProgressBarHtml: getProgressBarHtml,
|
|
|
|
getPlayedIndicatorHtml: getPlayedIndicator,
|
|
|
|
getChildCountIndicatorHtml: getChildCountIndicatorHtml,
|
|
|
|
enableProgressIndicator: enableProgressIndicator,
|
|
|
|
getTimerIndicator: getTimerIndicator,
|
|
|
|
enablePlayedIndicator: enablePlayedIndicator,
|
|
|
|
getSyncIndicator: getSyncIndicator,
|
|
|
|
getTypeIndicator: getTypeIndicator,
|
|
|
|
getMissingIndicator: getMissingIndicator
|
2019-01-10 15:39:37 +03:00
|
|
|
};
|
2019-11-20 00:24:54 +03:00
|
|
|
});
|