mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Unminify using 1.5.323
Repo with tag: https://github.com/MediaBrowser/emby-webcomponents/tree/1.5.323
This commit is contained in:
parent
4678528d00
commit
de6ac33ec1
289 changed files with 78483 additions and 54701 deletions
|
@ -1,112 +1,274 @@
|
|||
define(["datetime", "itemHelper", "css!./indicators.css", "material-icons"], function(datetime, itemHelper) {
|
||||
"use strict";
|
||||
define(['datetime', 'itemHelper', 'css!./indicators.css', 'material-icons'], function (datetime, itemHelper) {
|
||||
'use strict';
|
||||
|
||||
function enableProgressIndicator(item) {
|
||||
return "Video" === item.MediaType && "TvChannel" !== item.Type || ("AudioBook" === item.Type || "AudioPodcast" === item.Type)
|
||||
|
||||
if (item.MediaType === 'Video') {
|
||||
if (item.Type !== 'TvChannel') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.Type === 'AudioBook' || item.Type === 'AudioPodcast') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getProgressHtml(pct, options) {
|
||||
var containerClass = "itemProgressBar";
|
||||
return options && options.containerClass && (containerClass += " " + options.containerClass), '<div class="' + containerClass + '"><div class="itemProgressBarForeground" style="width:' + pct + '%;"></div></div>'
|
||||
|
||||
var containerClass = 'itemProgressBar';
|
||||
|
||||
if (options) {
|
||||
if (options.containerClass) {
|
||||
containerClass += ' ' + options.containerClass;
|
||||
}
|
||||
}
|
||||
|
||||
return '<div class="' + containerClass + '"><div class="itemProgressBarForeground" style="width:' + pct + '%;"></div></div>';
|
||||
}
|
||||
|
||||
function getAutoTimeProgressHtml(pct, options, isRecording, start, end) {
|
||||
var containerClass = "itemProgressBar";
|
||||
options && options.containerClass && (containerClass += " " + options.containerClass);
|
||||
var foregroundClass = "itemProgressBarForeground";
|
||||
return isRecording && (foregroundClass += " itemProgressBarForeground-recording"), '<div is="emby-progressbar" data-automode="time" data-starttime="' + start + '" data-endtime="' + end + '" class="' + containerClass + '"><div class="' + foregroundClass + '" style="width:' + pct + '%;"></div></div>'
|
||||
|
||||
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>';
|
||||
}
|
||||
|
||||
function getProgressBarHtml(item, options) {
|
||||
|
||||
var pct;
|
||||
if (enableProgressIndicator(item) && "Recording" !== item.Type) {
|
||||
var userData = options ? options.userData || item.UserData : item.UserData;
|
||||
if (userData && (pct = userData.PlayedPercentage) && pct < 100) return getProgressHtml(pct, options)
|
||||
}
|
||||
if (("Program" === item.Type || "Timer" === item.Type || "Recording" === item.Type) && item.StartDate && item.EndDate) {
|
||||
var startDate = 0,
|
||||
endDate = 1;
|
||||
try {
|
||||
startDate = datetime.parseISO8601Date(item.StartDate).getTime()
|
||||
} catch (err) {}
|
||||
try {
|
||||
endDate = datetime.parseISO8601Date(item.EndDate).getTime()
|
||||
} catch (err) {}
|
||||
if ((pct = ((new Date).getTime() - startDate) / (endDate - startDate) * 100) > 0 && pct < 100) {
|
||||
return getAutoTimeProgressHtml(pct, options, "Timer" === item.Type || "Recording" === item.Type || item.TimerId, startDate, endDate)
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
|
||||
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) {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function enablePlayedIndicator(item) {
|
||||
return itemHelper.canMarkPlayed(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>";
|
||||
if (userData.PlayedPercentage && userData.PlayedPercentage >= 100 || userData.Played) return '<div class="playedIndicator indicator"><i class="md-icon indicatorIcon"></i></div>'
|
||||
|
||||
if (userData.UnplayedItemCount) {
|
||||
return '<div class="countIndicator indicator">' + userData.UnplayedItemCount + '</div>';
|
||||
}
|
||||
|
||||
if (userData.PlayedPercentage && userData.PlayedPercentage >= 100 || (userData.Played)) {
|
||||
return '<div class="playedIndicator indicator"><i class="md-icon indicatorIcon"></i></div>';
|
||||
}
|
||||
}
|
||||
return ""
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function getCountIndicatorHtml(count) {
|
||||
return '<div class="countIndicator indicator">' + count + "</div>"
|
||||
|
||||
return '<div class="countIndicator indicator">' + count + '</div>';
|
||||
}
|
||||
|
||||
function getChildCountIndicatorHtml(item, options) {
|
||||
|
||||
var minCount = 0;
|
||||
return options && (minCount = options.minCount || minCount), item.ChildCount && item.ChildCount > minCount ? getCountIndicatorHtml(item.ChildCount) : ""
|
||||
|
||||
if (options) {
|
||||
minCount = options.minCount || minCount;
|
||||
}
|
||||
|
||||
if (item.ChildCount && item.ChildCount > minCount) {
|
||||
return getCountIndicatorHtml(item.ChildCount);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function getTimerIndicator(item) {
|
||||
|
||||
var status;
|
||||
if ("SeriesTimer" === item.Type) return '<i class="md-icon timerIndicator indicatorIcon"></i>';
|
||||
if (item.TimerId || item.SeriesTimerId) status = item.Status || "Cancelled";
|
||||
else {
|
||||
if ("Timer" !== item.Type) return "";
|
||||
status = item.Status
|
||||
|
||||
if (item.Type === 'SeriesTimer') {
|
||||
return '<i class="md-icon timerIndicator indicatorIcon"></i>';
|
||||
}
|
||||
return item.SeriesTimerId ? "Cancelled" !== status ? '<i class="md-icon timerIndicator indicatorIcon"></i>' : '<i class="md-icon timerIndicator timerIndicator-inactive indicatorIcon"></i>' : '<i class="md-icon timerIndicator indicatorIcon"></i>'
|
||||
else if (item.TimerId || item.SeriesTimerId) {
|
||||
|
||||
status = item.Status || 'Cancelled';
|
||||
}
|
||||
else if (item.Type === 'Timer') {
|
||||
|
||||
status = item.Status;
|
||||
}
|
||||
else {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (item.SeriesTimerId) {
|
||||
|
||||
if (status !== 'Cancelled') {
|
||||
return '<i class="md-icon timerIndicator indicatorIcon"></i>';
|
||||
}
|
||||
|
||||
return '<i class="md-icon timerIndicator timerIndicator-inactive indicatorIcon"></i>';
|
||||
}
|
||||
|
||||
return '<i class="md-icon timerIndicator indicatorIcon"></i>';
|
||||
}
|
||||
|
||||
function getSyncIndicator(item) {
|
||||
return 100 === item.SyncPercent ? '<div class="syncIndicator indicator fullSyncIndicator"><i class="md-icon indicatorIcon"></i></div>' : null != item.SyncPercent ? '<div class="syncIndicator indicator emptySyncIndicator"><i class="md-icon indicatorIcon"></i></div>' : ""
|
||||
|
||||
if (item.SyncPercent === 100) {
|
||||
return '<div class="syncIndicator indicator fullSyncIndicator"><i class="md-icon indicatorIcon"></i></div>';
|
||||
} else if (item.SyncPercent != null) {
|
||||
return '<div class="syncIndicator indicator emptySyncIndicator"><i class="md-icon indicatorIcon"></i></div>';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function getTypeIndicator(item) {
|
||||
return "Video" === item.Type ? '<div class="indicator videoIndicator"><i class="md-icon indicatorIcon"></i></div>' : "Folder" === item.Type || "PhotoAlbum" === item.Type ? '<div class="indicator videoIndicator"><i class="md-icon indicatorIcon"></i></div>' : "Photo" === item.Type ? '<div class="indicator videoIndicator"><i class="md-icon indicatorIcon"></i></div>' : ""
|
||||
|
||||
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 ("Episode" === item.Type && "Virtual" === item.LocationType) {
|
||||
if (item.PremiereDate) try {
|
||||
if (datetime.parseISO8601Date(item.PremiereDate).getTime() > (new Date).getTime()) return '<div class="unairedIndicator">Unaired</div>'
|
||||
} catch (err) {}
|
||||
return '<div class="missingIndicator">Missing</div>'
|
||||
|
||||
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) {
|
||||
}
|
||||
}
|
||||
|
||||
return '<div class="missingIndicator">Missing</div>';
|
||||
}
|
||||
return ""
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function onAutoTimeProgress() {
|
||||
var start = parseInt(this.getAttribute("data-starttime")),
|
||||
end = parseInt(this.getAttribute("data-endtime")),
|
||||
now = (new Date).getTime(),
|
||||
total = end - start,
|
||||
pct = (now - start) / total * 100;
|
||||
pct = Math.min(100, pct), pct = Math.max(0, pct), this.querySelector(".itemProgressBarForeground").style.width = pct + "%"
|
||||
}
|
||||
var ProgressBarPrototype = Object.create(HTMLDivElement.prototype);
|
||||
return ProgressBarPrototype.attachedCallback = function() {
|
||||
this.timeInterval && clearInterval(this.timeInterval), "time" === this.getAttribute("data-automode") && (this.timeInterval = setInterval(onAutoTimeProgress.bind(this), 6e4))
|
||||
}, ProgressBarPrototype.detachedCallback = function() {
|
||||
this.timeInterval && (clearInterval(this.timeInterval), this.timeInterval = null)
|
||||
}, document.registerElement("emby-progressbar", {
|
||||
|
||||
function onAutoTimeProgress() {
|
||||
|
||||
var start = parseInt(this.getAttribute('data-starttime'));
|
||||
var end = parseInt(this.getAttribute('data-endtime'));
|
||||
|
||||
var now = new Date().getTime();
|
||||
var total = end - start;
|
||||
var pct = 100 * ((now - start) / total);
|
||||
|
||||
pct = Math.min(100, pct);
|
||||
pct = Math.max(0, pct);
|
||||
|
||||
var itemProgressBarForeground = this.querySelector('.itemProgressBarForeground');
|
||||
itemProgressBarForeground.style.width = pct + '%';
|
||||
}
|
||||
|
||||
ProgressBarPrototype.attachedCallback = function () {
|
||||
|
||||
if (this.timeInterval) {
|
||||
clearInterval(this.timeInterval);
|
||||
}
|
||||
|
||||
if (this.getAttribute('data-automode') === 'time') {
|
||||
this.timeInterval = setInterval(onAutoTimeProgress.bind(this), 60000);
|
||||
}
|
||||
};
|
||||
|
||||
ProgressBarPrototype.detachedCallback = function () {
|
||||
|
||||
if (this.timeInterval) {
|
||||
clearInterval(this.timeInterval);
|
||||
this.timeInterval = null;
|
||||
}
|
||||
};
|
||||
|
||||
document.registerElement('emby-progressbar', {
|
||||
prototype: ProgressBarPrototype,
|
||||
extends: "div"
|
||||
}), {
|
||||
extends: 'div'
|
||||
});
|
||||
|
||||
return {
|
||||
getProgressBarHtml: getProgressBarHtml,
|
||||
getPlayedIndicatorHtml: getPlayedIndicator,
|
||||
getChildCountIndicatorHtml: getChildCountIndicatorHtml,
|
||||
|
@ -116,5 +278,5 @@ define(["datetime", "itemHelper", "css!./indicators.css", "material-icons"], fun
|
|||
getSyncIndicator: getSyncIndicator,
|
||||
getTypeIndicator: getTypeIndicator,
|
||||
getMissingIndicator: getMissingIndicator
|
||||
}
|
||||
};
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue