update image sizes

This commit is contained in:
Luke Pulverenti 2015-05-12 09:58:03 -04:00
parent 589ad2de70
commit 16f30944f8
7 changed files with 260 additions and 51 deletions

View File

@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
<meta http-equiv="X-UA-Compatibility" content="IE=Edge">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="application-name" content="Emby">
<meta name="robots" content="noindex, nofollow, noarchive" />
<link rel="apple-touch-icon" href="css/images/touchicon.png" />
<link rel="apple-touch-icon" sizes="72x72" href="css/images/touchicon72.png" />
<link rel="apple-touch-icon" sizes="114x114" href="css/images/touchicon114.png" />
<link rel="apple-touch-startup-image" href="css/images/iossplash.png" />
<link rel="shortcut icon" href="css/images/favicon.ico" />
<script src="cordova.js"></script>
<title>Emby</title>
<style>
body, html {
background: #222;
}
</style>
</head>
<body>
<script type="text/javascript">
document.addEventListener("deviceready", function () {
var deviceId = device.uuid;
localStorage.setItem('cordovaDeviceName', device.model);
localStorage.setItem('cordovaDeviceId', device.uuid);
window.location.replace('index.html');
}, false);
</script>
</body>
</html>

View File

@ -590,11 +590,11 @@
getClientImage: function (connection) {
var clientLowered = connection.Client.toLowerCase();
if (clientLowered == "dashboard" || clientLowered == "emby web client" || clientLowered == "emby mobile") {
var device = connection.DeviceName.toLowerCase();
if (clientLowered == "dashboard" || clientLowered == "emby web client") {
var imgUrl;
if (device.indexOf('chrome') != -1) {
@ -615,6 +615,19 @@
return "<img src='" + imgUrl + "' alt='Emby Web Client' />";
}
if (clientLowered == "emby mobile") {
var imgUrl;
if (device.indexOf('iphone') != -1 || device.indexOf('ipad') != -1) {
imgUrl = 'css/images/clients/ios.png';
}
else {
imgUrl = 'css/images/clients/html5.png';
}
return "<img src='" + imgUrl + "' alt='Emby Web Client' />";
}
if (clientLowered == "mb-classic") {
return "<img src='css/images/clients/mbc.png' />";

View File

@ -282,7 +282,7 @@
items: result.Items,
preferThumb: true,
shape: 'backdrop',
overlayText: screenWidth >= 600 && !AppInfo.hasLowImageBandwidth,
overlayText: screenWidth >= 800 && !AppInfo.hasLowImageBandwidth,
showTitle: true,
showParentTitle: true,
context: 'home',

View File

@ -1070,18 +1070,16 @@
var html = "";
var primaryImageAspectRatio;
var primaryImageAspectRatio = LibraryBrowser.getAveragePrimaryImageAspectRatio(items);
var isThumbAspectRatio = primaryImageAspectRatio && Math.abs(primaryImageAspectRatio - 1.777777778) < .3;
var isSquareAspectRatio = primaryImageAspectRatio && Math.abs(primaryImageAspectRatio - 1) < .33 ||
primaryImageAspectRatio && Math.abs(primaryImageAspectRatio - 1.3333334) < .01;
if (options.shape == 'auto' || options.shape == 'autohome') {
primaryImageAspectRatio = LibraryBrowser.getAveragePrimaryImageAspectRatio(items);
if (primaryImageAspectRatio && Math.abs(primaryImageAspectRatio - 1.777777778) < .3) {
if (isThumbAspectRatio) {
options.shape = options.shape == 'auto' ? 'backdrop' : 'backdrop';
} else if (primaryImageAspectRatio && Math.abs(primaryImageAspectRatio - 1) < .33) {
options.coverImage = true;
options.shape = 'square';
} else if (primaryImageAspectRatio && Math.abs(primaryImageAspectRatio - 1.3333334) < .01) {
} else if (isSquareAspectRatio) {
options.coverImage = true;
options.shape = 'square';
} else if (primaryImageAspectRatio && primaryImageAspectRatio > 1.9) {
@ -1101,18 +1099,34 @@
var squareSize = posterInfo.squareSize;
var bannerWidth = posterInfo.bannerWidth;
if (isThumbAspectRatio) {
posterInfo.smallPosterWidth = posterInfo.smallThumbWidth;
posterWidth = thumbWidth;
}
else if (isSquareAspectRatio) {
posterInfo.smallPosterWidth = posterInfo.smallSquareSize;
posterWidth = squareSize;
}
if (options.shape == 'backdrop' && posterInfo.defaultThumb == 'smallBackdrop') {
options.shape = 'smallBackdrop';
thumbWidth = posterInfo.smallThumbWidth;
}
else if (options.shape == 'portrait' && posterInfo.defaultPortait == 'smallPortrait') {
options.shape = 'smallPortrait';
posterWidth = posterInfo.smallPosterWidth;
}
else if (options.shape == 'square' && posterInfo.defaultSquare == 'smallSquare') {
options.shape = 'smallSquare';
}
if (options.shape == 'smallBackdrop') {
thumbWidth = posterInfo.smallThumbWidth;
}
else if (options.shape == 'smallPortrait') {
posterWidth = posterInfo.smallPosterWidth;
}
else if (options.shape == 'smallSquare') {
squareSize = posterInfo.smallSquareSize;
}
else if (options.shape == 'detailPagePortrait') {

View File

@ -1421,34 +1421,12 @@ var Dashboard = {
if (Dashboard.isRunningInCordova()) {
if ($.browser.safari) {
appName = "iOS";
if ($.browser.iphone) {
deviceName = 'iPhone';
} else if ($.browser.ipad) {
deviceName = 'iPad';
}
} else {
appName = "Android";
}
deviceName = store.getItem('cordovaDeviceName');
deviceId = store.getItem('cordovaDeviceId');
}
deviceName = deviceName || generateDeviceName();
// Cordova
//if (window.device) {
// deviceName = device.model;
// deviceId = device.uuid;
//}
//else
{
var seed = [];
var keyName = 'randomId';
@ -1457,8 +1435,7 @@ var Dashboard = {
keyName = 'cordovaDeviceId';
}
deviceId = MediaBrowser.generateDeviceId(keyName, seed.join(','));
}
deviceId = deviceId || MediaBrowser.generateDeviceId(keyName, seed.join(','));
return {
appName: appName,

View File

@ -69,6 +69,8 @@
var parentId = LibraryMenu.getTopParentId();
var screenWidth = $(window).width();
var limit = AppInfo.hasLowImageBandwidth ?
4 :
6;
@ -102,7 +104,7 @@
shape: "backdrop",
showTitle: true,
showParentTitle: true,
overlayText: true,
overlayText: screenWidth >= 800 && !AppInfo.hasLowImageBandwidth,
lazy: true,
context: 'tv'

View File

@ -285,6 +285,162 @@
} catch (err) {
deferred.reject();
}
} else {
deferred.reject();
}
}, false);
// Send XHR
xhr.send();
return deferred.promise();
};
self.setImageInto = function (elem, url) {
function onFail() {
setImageIntoElement(elem, url);
}
openPromise.done(function () {
self.getImageUrl(url).done(function (localUrl) {
setImageIntoElement(elem, localUrl);
}).fail(onFail);
}).fail(onFail);
};
}
function indexedDbBlobImageStore() {
var self = this;
var openPromise = openDb().done(function (db) {
self._db = db;
});
self.addImageToDatabase = function (blob, key) {
console.log("addImageToDatabase");
// Open a transaction to the database
var transaction = self.db().transaction([imagesStoreName], "readwrite");
// Put the blob into the dabase
var put = transaction.objectStore(imagesStoreName).put(blob, key);
};
self.revokeUrl = function (url) {
// Get window.URL object
var URL = window.URL || window.webkitURL;
URL.revokeObjectURL(url);
};
self.db = function () {
return self._db;
};
self.get = function (key) {
var deferred = DeferredBuilder.Deferred();
var transaction = self.db().transaction([imagesStoreName], "readonly");
// Open a transaction to the database
var getRequest = transaction.objectStore(imagesStoreName).get(key);
getRequest.onsuccess = function (event) {
var imgFile = event.target.result;
if (imgFile) {
// Get window.URL object
var URL = window.URL || window.webkitURL;
// Create and revoke ObjectURL
var imgUrl = URL.createObjectURL(imgFile);
deferred.resolveWith(null, [imgUrl]);
} else {
deferred.reject();
}
};
getRequest.onerror = function () {
deferred.reject();
};
return deferred.promise();
};
self.getImageUrl = function (originalUrl) {
console.log('getImageUrl:' + originalUrl);
var key = CryptoJS.SHA1(originalUrl + "1").toString();
var deferred = DeferredBuilder.Deferred();
self.get(key).done(function (url) {
deferred.resolveWith(null, [url]);
}).fail(function () {
self.downloadImage(originalUrl, key).done(function () {
self.get(key).done(function (url) {
deferred.resolveWith(null, [url]);
}).fail(function () {
deferred.reject();
});
}).fail(function () {
deferred.reject();
});
});
return deferred.promise();
};
self.downloadImage = function (url, key) {
var deferred = DeferredBuilder.Deferred();
console.log('downloadImage:' + url);
// Create XHR
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
// Set the responseType to blob
xhr.responseType = "arraybuffer";
xhr.addEventListener("load", function () {
if (xhr.status === 200) {
console.log("Image retrieved");
try {
var blob = new Blob([this.response], { type: this.getResponseHeader('content-type') });
// Put the received blob into IndexedDB
self.addImageToDatabase(blob, key);
deferred.resolve();
} catch (err) {
deferred.reject();
}
} else {
deferred.reject();
}
}, false);
@ -319,9 +475,16 @@
self.setImageInto = setImageIntoElement;
}
if ($.browser.safari && indexedDB) {
if ($.browser.safari && indexedDB && window.Blob) {
console.log('creating indexedDbBlobImageStore');
window.ImageStore = new indexedDbBlobImageStore();
}
else if ($.browser.safari && indexedDB) {
console.log('creating indexedDbImageStore');
window.ImageStore = new indexedDbImageStore();
} else {
}
else {
console.log('creating simpleImageStore');
window.ImageStore = new simpleImageStore();
}