mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
minify resources
This commit is contained in:
parent
8a6884abef
commit
661eeac16e
201 changed files with 203 additions and 52376 deletions
|
@ -1,112 +1 @@
|
|||
define(['backdrop', 'appStorage'], function (backdrop, appStorage) {
|
||||
'use strict';
|
||||
|
||||
function enabled() {
|
||||
|
||||
var apiClient = window.ApiClient;
|
||||
|
||||
if (!apiClient) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var userId = apiClient.getCurrentUserId();
|
||||
|
||||
var val = appStorage.getItem('enableBackdrops-' + userId);
|
||||
|
||||
// For bandwidth
|
||||
return val == '1';
|
||||
}
|
||||
|
||||
var cache = {};
|
||||
|
||||
function getBackdropItemIds(apiClient, userId, types, parentId) {
|
||||
|
||||
var key = 'backdrops2_' + userId + (types || '') + (parentId || '');
|
||||
|
||||
var data = cache[key];
|
||||
|
||||
if (data) {
|
||||
|
||||
console.log('Found backdrop id list in cache. Key: ' + key);
|
||||
data = JSON.parse(data);
|
||||
return Promise.resolve(data);
|
||||
} else {
|
||||
|
||||
var options = {
|
||||
|
||||
SortBy: "IsFavoriteOrLiked,Random",
|
||||
Limit: 20,
|
||||
Recursive: true,
|
||||
IncludeItemTypes: types,
|
||||
ImageTypes: "Backdrop",
|
||||
//Ids: "8114409aa00a2722456c08e298f90bed",
|
||||
ParentId: parentId
|
||||
};
|
||||
|
||||
return apiClient.getItems(apiClient.getCurrentUserId(), options).then(function (result) {
|
||||
|
||||
var images = result.Items.map(function (i) {
|
||||
return {
|
||||
Id: i.Id,
|
||||
tag: i.BackdropImageTags[0],
|
||||
ServerId: i.ServerId
|
||||
};
|
||||
});
|
||||
|
||||
cache[key] = JSON.stringify(images);
|
||||
return images;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function showBackdrop(type, parentId) {
|
||||
|
||||
var apiClient = window.ApiClient;
|
||||
|
||||
if (!apiClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
getBackdropItemIds(apiClient, apiClient.getCurrentUserId(), type, parentId).then(function (images) {
|
||||
|
||||
if (images.length) {
|
||||
|
||||
backdrop.setBackdrops(images.map(function (i) {
|
||||
i.BackdropImageTags = [i.tag];
|
||||
return i;
|
||||
}));
|
||||
|
||||
} else {
|
||||
|
||||
backdrop.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pageClassOn('pagebeforeshow', "page", function () {
|
||||
|
||||
var page = this;
|
||||
|
||||
// These pages self-manage their backdrops
|
||||
if (page.classList.contains('selfBackdropPage')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (page.classList.contains('backdropPage')) {
|
||||
|
||||
if (enabled()) {
|
||||
var type = page.getAttribute('data-backdroptype');
|
||||
|
||||
var parentId = page.classList.contains('globalBackdropPage') ? '' : LibraryMenu.getTopParentId();
|
||||
showBackdrop(type, parentId);
|
||||
|
||||
} else {
|
||||
page.classList.remove('backdropPage');
|
||||
backdrop.clear();
|
||||
}
|
||||
} else {
|
||||
backdrop.clear();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
define(["backdrop","appStorage"],function(backdrop,appStorage){"use strict";function enabled(){var apiClient=window.ApiClient;if(!apiClient)return!1;var userId=apiClient.getCurrentUserId(),val=appStorage.getItem("enableBackdrops-"+userId);return"1"==val}function getBackdropItemIds(apiClient,userId,types,parentId){var key="backdrops2_"+userId+(types||"")+(parentId||""),data=cache[key];if(data)return console.log("Found backdrop id list in cache. Key: "+key),data=JSON.parse(data),Promise.resolve(data);var options={SortBy:"IsFavoriteOrLiked,Random",Limit:20,Recursive:!0,IncludeItemTypes:types,ImageTypes:"Backdrop",ParentId:parentId};return apiClient.getItems(apiClient.getCurrentUserId(),options).then(function(result){var images=result.Items.map(function(i){return{Id:i.Id,tag:i.BackdropImageTags[0],ServerId:i.ServerId}});return cache[key]=JSON.stringify(images),images})}function showBackdrop(type,parentId){var apiClient=window.ApiClient;apiClient&&getBackdropItemIds(apiClient,apiClient.getCurrentUserId(),type,parentId).then(function(images){images.length?backdrop.setBackdrops(images.map(function(i){return i.BackdropImageTags=[i.tag],i})):backdrop.clear()})}var cache={};pageClassOn("pagebeforeshow","page",function(){var page=this;if(!page.classList.contains("selfBackdropPage"))if(page.classList.contains("backdropPage"))if(enabled()){var type=page.getAttribute("data-backdroptype"),parentId=page.classList.contains("globalBackdropPage")?"":LibraryMenu.getTopParentId();showBackdrop(type,parentId)}else page.classList.remove("backdropPage"),backdrop.clear();else backdrop.clear()})});
|
Loading…
Add table
Add a link
Reference in a new issue