mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
add some error checking to indicators
This commit is contained in:
parent
19530c4ade
commit
8bd840bedc
1 changed files with 5 additions and 53 deletions
|
@ -2,7 +2,6 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function enableProgressIndicator(item) {
|
function enableProgressIndicator(item) {
|
||||||
|
|
||||||
if (item.MediaType === 'Video') {
|
if (item.MediaType === 'Video') {
|
||||||
if (item.Type !== 'TvChannel') {
|
if (item.Type !== 'TvChannel') {
|
||||||
return true;
|
return true;
|
||||||
|
@ -17,9 +16,7 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProgressHtml(pct, options) {
|
function getProgressHtml(pct, options) {
|
||||||
|
|
||||||
var containerClass = 'itemProgressBar';
|
var containerClass = 'itemProgressBar';
|
||||||
|
|
||||||
if (options) {
|
if (options) {
|
||||||
if (options.containerClass) {
|
if (options.containerClass) {
|
||||||
containerClass += ' ' + options.containerClass;
|
containerClass += ' ' + options.containerClass;
|
||||||
|
@ -30,9 +27,7 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAutoTimeProgressHtml(pct, options, isRecording, start, end) {
|
function getAutoTimeProgressHtml(pct, options, isRecording, start, end) {
|
||||||
|
|
||||||
var containerClass = 'itemProgressBar';
|
var containerClass = 'itemProgressBar';
|
||||||
|
|
||||||
if (options) {
|
if (options) {
|
||||||
if (options.containerClass) {
|
if (options.containerClass) {
|
||||||
containerClass += ' ' + options.containerClass;
|
containerClass += ' ' + options.containerClass;
|
||||||
|
@ -40,7 +35,6 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
||||||
}
|
}
|
||||||
|
|
||||||
var foregroundClass = 'itemProgressBarForeground';
|
var foregroundClass = 'itemProgressBarForeground';
|
||||||
|
|
||||||
if (isRecording) {
|
if (isRecording) {
|
||||||
foregroundClass += ' itemProgressBarForeground-recording';
|
foregroundClass += ' itemProgressBarForeground-recording';
|
||||||
}
|
}
|
||||||
|
@ -49,39 +43,26 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProgressBarHtml(item, options) {
|
function getProgressBarHtml(item, options) {
|
||||||
|
|
||||||
var pct;
|
var pct;
|
||||||
|
|
||||||
if (enableProgressIndicator(item) && item.Type !== "Recording") {
|
if (enableProgressIndicator(item) && item.Type !== "Recording") {
|
||||||
|
|
||||||
var userData = options ? (options.userData || item.UserData) : item.UserData;
|
var userData = options ? (options.userData || item.UserData) : item.UserData;
|
||||||
if (userData) {
|
if (userData) {
|
||||||
pct = userData.PlayedPercentage;
|
pct = userData.PlayedPercentage;
|
||||||
|
|
||||||
if (pct && pct < 100) {
|
if (pct && pct < 100) {
|
||||||
|
|
||||||
return getProgressHtml(pct, options);
|
return getProgressHtml(pct, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((item.Type === 'Program' || item.Type === 'Timer' || item.Type === 'Recording') && item.StartDate && item.EndDate) {
|
if ((item.Type === 'Program' || item.Type === 'Timer' || item.Type === 'Recording') && item.StartDate && item.EndDate) {
|
||||||
|
|
||||||
var startDate = 0;
|
var startDate = 0;
|
||||||
var endDate = 1;
|
var endDate = 1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
startDate = datetime.parseISO8601Date(item.StartDate).getTime();
|
startDate = datetime.parseISO8601Date(item.StartDate).getTime();
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
endDate = datetime.parseISO8601Date(item.EndDate).getTime();
|
endDate = datetime.parseISO8601Date(item.EndDate).getTime();
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var now = new Date().getTime();
|
var now = new Date().getTime();
|
||||||
|
@ -89,9 +70,7 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
||||||
pct = 100 * ((now - startDate) / total);
|
pct = 100 * ((now - startDate) / total);
|
||||||
|
|
||||||
if (pct > 0 && pct < 100) {
|
if (pct > 0 && pct < 100) {
|
||||||
|
|
||||||
var isRecording = item.Type === 'Timer' || item.Type === 'Recording' || item.TimerId;
|
var isRecording = item.Type === 'Timer' || item.Type === 'Recording' || item.TimerId;
|
||||||
|
|
||||||
return getAutoTimeProgressHtml(pct, options, isRecording, startDate, endDate);
|
return getAutoTimeProgressHtml(pct, options, isRecording, startDate, endDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,16 +79,12 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
||||||
}
|
}
|
||||||
|
|
||||||
function enablePlayedIndicator(item) {
|
function enablePlayedIndicator(item) {
|
||||||
|
|
||||||
return itemHelper.canMarkPlayed(item);
|
return itemHelper.canMarkPlayed(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPlayedIndicator(item) {
|
function getPlayedIndicator(item) {
|
||||||
|
|
||||||
if (enablePlayedIndicator(item)) {
|
if (enablePlayedIndicator(item)) {
|
||||||
|
|
||||||
var userData = item.UserData || {};
|
var userData = item.UserData || {};
|
||||||
|
|
||||||
if (userData.UnplayedItemCount) {
|
if (userData.UnplayedItemCount) {
|
||||||
return '<div class="countIndicator indicator">' + userData.UnplayedItemCount + '</div>';
|
return '<div class="countIndicator indicator">' + userData.UnplayedItemCount + '</div>';
|
||||||
}
|
}
|
||||||
|
@ -123,14 +98,11 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCountIndicatorHtml(count) {
|
function getCountIndicatorHtml(count) {
|
||||||
|
|
||||||
return '<div class="countIndicator indicator">' + count + '</div>';
|
return '<div class="countIndicator indicator">' + count + '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChildCountIndicatorHtml(item, options) {
|
function getChildCountIndicatorHtml(item, options) {
|
||||||
|
|
||||||
var minCount = 0;
|
var minCount = 0;
|
||||||
|
|
||||||
if (options) {
|
if (options) {
|
||||||
minCount = options.minCount || minCount;
|
minCount = options.minCount || minCount;
|
||||||
}
|
}
|
||||||
|
@ -148,21 +120,15 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
||||||
|
|
||||||
if (item.Type === 'SeriesTimer') {
|
if (item.Type === 'SeriesTimer') {
|
||||||
return '<i class="md-icon timerIndicator indicatorIcon"></i>';
|
return '<i class="md-icon timerIndicator indicatorIcon"></i>';
|
||||||
}
|
} else if (item.TimerId || item.SeriesTimerId) {
|
||||||
else if (item.TimerId || item.SeriesTimerId) {
|
|
||||||
|
|
||||||
status = item.Status || 'Cancelled';
|
status = item.Status || 'Cancelled';
|
||||||
}
|
} else if (item.Type === 'Timer') {
|
||||||
else if (item.Type === 'Timer') {
|
|
||||||
|
|
||||||
status = item.Status;
|
status = item.Status;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.SeriesTimerId) {
|
if (item.SeriesTimerId) {
|
||||||
|
|
||||||
if (status !== 'Cancelled') {
|
if (status !== 'Cancelled') {
|
||||||
return '<i class="md-icon timerIndicator indicatorIcon"></i>';
|
return '<i class="md-icon timerIndicator indicatorIcon"></i>';
|
||||||
}
|
}
|
||||||
|
@ -174,7 +140,6 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSyncIndicator(item) {
|
function getSyncIndicator(item) {
|
||||||
|
|
||||||
if (item.SyncPercent === 100) {
|
if (item.SyncPercent === 100) {
|
||||||
return '<div class="syncIndicator indicator fullSyncIndicator"><i class="md-icon indicatorIcon"></i></div>';
|
return '<div class="syncIndicator indicator fullSyncIndicator"><i class="md-icon indicatorIcon"></i></div>';
|
||||||
} else if (item.SyncPercent != null) {
|
} else if (item.SyncPercent != null) {
|
||||||
|
@ -185,41 +150,31 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTypeIndicator(item) {
|
function getTypeIndicator(item) {
|
||||||
|
|
||||||
if (item.Type === 'Video') {
|
if (item.Type === 'Video') {
|
||||||
|
|
||||||
return '<div class="indicator videoIndicator"><i class="md-icon indicatorIcon"></i></div>';
|
return '<div class="indicator videoIndicator"><i class="md-icon indicatorIcon"></i></div>';
|
||||||
}
|
}
|
||||||
if (item.Type === 'Folder' || item.Type === 'PhotoAlbum') {
|
if (item.Type === 'Folder' || item.Type === 'PhotoAlbum') {
|
||||||
|
|
||||||
return '<div class="indicator videoIndicator"><i class="md-icon indicatorIcon"></i></div>';
|
return '<div class="indicator videoIndicator"><i class="md-icon indicatorIcon"></i></div>';
|
||||||
}
|
}
|
||||||
if (item.Type === 'Photo') {
|
if (item.Type === 'Photo') {
|
||||||
|
|
||||||
return '<div class="indicator videoIndicator"><i class="md-icon indicatorIcon"></i></div>';
|
return '<div class="indicator videoIndicator"><i class="md-icon indicatorIcon"></i></div>';
|
||||||
//return '<div class="indicator videoIndicator"><i class="md-icon indicatorIcon"></i></div>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMissingIndicator(item) {
|
function getMissingIndicator(item) {
|
||||||
|
|
||||||
if (item.Type === 'Episode' && item.LocationType === 'Virtual') {
|
if (item.Type === 'Episode' && item.LocationType === 'Virtual') {
|
||||||
|
|
||||||
if (item.PremiereDate) {
|
if (item.PremiereDate) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
var premiereDate = datetime.parseISO8601Date(item.PremiereDate).getTime();
|
var premiereDate = datetime.parseISO8601Date(item.PremiereDate).getTime();
|
||||||
|
|
||||||
if (premiereDate > new Date().getTime()) {
|
if (premiereDate > new Date().getTime()) {
|
||||||
return '<div class="unairedIndicator">Unaired</div>';
|
return '<div class="unairedIndicator">Unaired</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<div class="missingIndicator">Missing</div>';
|
return '<div class="missingIndicator">Missing</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +184,6 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
||||||
var ProgressBarPrototype = Object.create(HTMLDivElement.prototype);
|
var ProgressBarPrototype = Object.create(HTMLDivElement.prototype);
|
||||||
|
|
||||||
function onAutoTimeProgress() {
|
function onAutoTimeProgress() {
|
||||||
|
|
||||||
var start = parseInt(this.getAttribute('data-starttime'));
|
var start = parseInt(this.getAttribute('data-starttime'));
|
||||||
var end = parseInt(this.getAttribute('data-endtime'));
|
var end = parseInt(this.getAttribute('data-endtime'));
|
||||||
|
|
||||||
|
@ -245,7 +199,6 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressBarPrototype.attachedCallback = function () {
|
ProgressBarPrototype.attachedCallback = function () {
|
||||||
|
|
||||||
if (this.timeInterval) {
|
if (this.timeInterval) {
|
||||||
clearInterval(this.timeInterval);
|
clearInterval(this.timeInterval);
|
||||||
}
|
}
|
||||||
|
@ -256,7 +209,6 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
||||||
};
|
};
|
||||||
|
|
||||||
ProgressBarPrototype.detachedCallback = function () {
|
ProgressBarPrototype.detachedCallback = function () {
|
||||||
|
|
||||||
if (this.timeInterval) {
|
if (this.timeInterval) {
|
||||||
clearInterval(this.timeInterval);
|
clearInterval(this.timeInterval);
|
||||||
this.timeInterval = null;
|
this.timeInterval = null;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue