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';
|
||||
|
||||
function enableProgressIndicator(item) {
|
||||
|
||||
if (item.MediaType === 'Video') {
|
||||
if (item.Type !== 'TvChannel') {
|
||||
return true;
|
||||
|
@ -17,9 +16,7 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
|||
}
|
||||
|
||||
function getProgressHtml(pct, options) {
|
||||
|
||||
var containerClass = 'itemProgressBar';
|
||||
|
||||
if (options) {
|
||||
if (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) {
|
||||
|
||||
var containerClass = 'itemProgressBar';
|
||||
|
||||
if (options) {
|
||||
if (options.containerClass) {
|
||||
containerClass += ' ' + options.containerClass;
|
||||
|
@ -40,7 +35,6 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
|||
}
|
||||
|
||||
var foregroundClass = 'itemProgressBarForeground';
|
||||
|
||||
if (isRecording) {
|
||||
foregroundClass += ' itemProgressBarForeground-recording';
|
||||
}
|
||||
|
@ -49,39 +43,26 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
|||
}
|
||||
|
||||
function getProgressBarHtml(item, options) {
|
||||
|
||||
var pct;
|
||||
|
||||
if (enableProgressIndicator(item) && item.Type !== "Recording") {
|
||||
|
||||
var userData = options ? (options.userData || item.UserData) : item.UserData;
|
||||
if (userData) {
|
||||
pct = userData.PlayedPercentage;
|
||||
|
||||
if (pct && pct < 100) {
|
||||
|
||||
return getProgressHtml(pct, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((item.Type === 'Program' || item.Type === 'Timer' || item.Type === 'Recording') && item.StartDate && item.EndDate) {
|
||||
|
||||
var startDate = 0;
|
||||
var endDate = 1;
|
||||
|
||||
try {
|
||||
|
||||
startDate = datetime.parseISO8601Date(item.StartDate).getTime();
|
||||
|
||||
} catch (err) {
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
endDate = datetime.parseISO8601Date(item.EndDate).getTime();
|
||||
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
var now = new Date().getTime();
|
||||
|
@ -89,9 +70,7 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
@ -100,16 +79,12 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
|||
}
|
||||
|
||||
function enablePlayedIndicator(item) {
|
||||
|
||||
return itemHelper.canMarkPlayed(item);
|
||||
}
|
||||
|
||||
function getPlayedIndicator(item) {
|
||||
|
||||
if (enablePlayedIndicator(item)) {
|
||||
|
||||
var userData = item.UserData || {};
|
||||
|
||||
if (userData.UnplayedItemCount) {
|
||||
return '<div class="countIndicator indicator">' + userData.UnplayedItemCount + '</div>';
|
||||
}
|
||||
|
@ -123,14 +98,11 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
|||
}
|
||||
|
||||
function getCountIndicatorHtml(count) {
|
||||
|
||||
return '<div class="countIndicator indicator">' + count + '</div>';
|
||||
}
|
||||
|
||||
function getChildCountIndicatorHtml(item, options) {
|
||||
|
||||
var minCount = 0;
|
||||
|
||||
if (options) {
|
||||
minCount = options.minCount || minCount;
|
||||
}
|
||||
|
@ -148,21 +120,15 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
|||
|
||||
if (item.Type === 'SeriesTimer') {
|
||||
return '<i class="md-icon timerIndicator indicatorIcon"></i>';
|
||||
}
|
||||
else if (item.TimerId || item.SeriesTimerId) {
|
||||
|
||||
} else if (item.TimerId || item.SeriesTimerId) {
|
||||
status = item.Status || 'Cancelled';
|
||||
}
|
||||
else if (item.Type === 'Timer') {
|
||||
|
||||
} else if (item.Type === 'Timer') {
|
||||
status = item.Status;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (item.SeriesTimerId) {
|
||||
|
||||
if (status !== 'Cancelled') {
|
||||
return '<i class="md-icon timerIndicator indicatorIcon"></i>';
|
||||
}
|
||||
|
@ -174,7 +140,6 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
|||
}
|
||||
|
||||
function getSyncIndicator(item) {
|
||||
|
||||
if (item.SyncPercent === 100) {
|
||||
return '<div class="syncIndicator indicator fullSyncIndicator"><i class="md-icon indicatorIcon"></i></div>';
|
||||
} else if (item.SyncPercent != null) {
|
||||
|
@ -185,41 +150,31 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
|||
}
|
||||
|
||||
function getTypeIndicator(item) {
|
||||
|
||||
if (item.Type === 'Video') {
|
||||
|
||||
return '<div class="indicator videoIndicator"><i class="md-icon indicatorIcon"></i></div>';
|
||||
}
|
||||
if (item.Type === 'Folder' || item.Type === 'PhotoAlbum') {
|
||||
|
||||
return '<div class="indicator videoIndicator"><i class="md-icon indicatorIcon"></i></div>';
|
||||
}
|
||||
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 '';
|
||||
}
|
||||
|
||||
function getMissingIndicator(item) {
|
||||
|
||||
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) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
function onAutoTimeProgress() {
|
||||
|
||||
var start = parseInt(this.getAttribute('data-starttime'));
|
||||
var end = parseInt(this.getAttribute('data-endtime'));
|
||||
|
||||
|
@ -245,7 +199,6 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
|||
}
|
||||
|
||||
ProgressBarPrototype.attachedCallback = function () {
|
||||
|
||||
if (this.timeInterval) {
|
||||
clearInterval(this.timeInterval);
|
||||
}
|
||||
|
@ -256,7 +209,6 @@ define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], fun
|
|||
};
|
||||
|
||||
ProgressBarPrototype.detachedCallback = function () {
|
||||
|
||||
if (this.timeInterval) {
|
||||
clearInterval(this.timeInterval);
|
||||
this.timeInterval = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue