3.0.5641.4
This commit is contained in:
parent
3b403bc22d
commit
46776f1eac
9 changed files with 122 additions and 282 deletions
|
@ -1131,40 +1131,35 @@
|
|||
return deferred.promise();
|
||||
}
|
||||
|
||||
require(['connectservice'], function () {
|
||||
AjaxApi.ajax({
|
||||
type: "POST",
|
||||
url: "https://connect.mediabrowser.tv/service/register",
|
||||
data: {
|
||||
email: email,
|
||||
userName: username,
|
||||
password: password
|
||||
},
|
||||
dataType: "json",
|
||||
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
headers: {
|
||||
"X-Application": appName + "/" + appVersion,
|
||||
"X-CONNECT-TOKEN": "CONNECT-REGISTER"
|
||||
}
|
||||
|
||||
var md5 = self.getConnectPasswordHash(password);
|
||||
}).done(function (result) {
|
||||
|
||||
AjaxApi.ajax({
|
||||
type: "POST",
|
||||
url: "https://connect.mediabrowser.tv/service/register",
|
||||
data: {
|
||||
email: email,
|
||||
userName: username,
|
||||
password: md5
|
||||
},
|
||||
dataType: "json",
|
||||
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
headers: {
|
||||
"X-Application": appName + "/" + appVersion,
|
||||
"X-CONNECT-TOKEN": "CONNECT-REGISTER"
|
||||
}
|
||||
deferred.resolve(null, []);
|
||||
|
||||
}).done(function (result) {
|
||||
}).fail(function (e) {
|
||||
|
||||
deferred.resolve(null, []);
|
||||
try {
|
||||
|
||||
}).fail(function (e) {
|
||||
var result = JSON.parse(e.responseText);
|
||||
|
||||
try {
|
||||
|
||||
var result = JSON.parse(e.responseText);
|
||||
|
||||
deferred.rejectWith(null, [{ errorCode: result.Status }]);
|
||||
} catch (err) {
|
||||
deferred.rejectWith(null, [{}]);
|
||||
}
|
||||
});
|
||||
deferred.rejectWith(null, [{ errorCode: result.Status }]);
|
||||
} catch (err) {
|
||||
deferred.rejectWith(null, [{}]);
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise();
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
(function () {
|
||||
|
||||
function setImageIntoElement(elem, url) {
|
||||
|
||||
if (elem.tagName === "DIV") {
|
||||
|
||||
elem.style.backgroundImage = "url('" + url + "')";
|
||||
|
||||
} else {
|
||||
elem.setAttribute("src", url);
|
||||
}
|
||||
}
|
||||
|
||||
var fileSystem;
|
||||
function getFileSystem() {
|
||||
|
||||
var deferred = DeferredBuilder.Deferred();
|
||||
|
||||
if (fileSystem) {
|
||||
deferred.resolveWith(null, [fileSystem]);
|
||||
} else {
|
||||
requestFileSystem(PERSISTENT, 0, function (fs) {
|
||||
fileSystem = fs;
|
||||
deferred.resolveWith(null, [fileSystem]);
|
||||
});
|
||||
}
|
||||
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
function indexedDbBlobImageStore() {
|
||||
|
||||
var self = this;
|
||||
|
||||
function getCacheKey(url) {
|
||||
|
||||
// Try to strip off the domain to share the cache between local and remote connections
|
||||
var index = url.indexOf('://');
|
||||
|
||||
if (index != -1) {
|
||||
url = url.substring(index + 3);
|
||||
|
||||
index = url.indexOf('/');
|
||||
|
||||
if (index != -1) {
|
||||
url = url.substring(index + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return CryptoJS.MD5(url).toString();
|
||||
}
|
||||
|
||||
self.getImageUrl = function (originalUrl) {
|
||||
|
||||
if ($.browser.android && originalUrl.indexOf('tag=') != -1) {
|
||||
originalUrl += "&format=webp";
|
||||
}
|
||||
|
||||
var deferred = DeferredBuilder.Deferred();
|
||||
var key = getCacheKey(originalUrl);
|
||||
|
||||
console.log('getImageUrl:' + originalUrl);
|
||||
|
||||
getFileSystem().done(function (fileSystem) {
|
||||
var path = fileSystem.root.toURL() + "/emby/cache/" + key;
|
||||
|
||||
resolveLocalFileSystemURL(path, function (fileEntry) {
|
||||
var localUrl = fileEntry.toURL();
|
||||
console.log('returning cached file: ' + localUrl);
|
||||
console.log(localUrl);
|
||||
deferred.resolveWith(null, [localUrl]);
|
||||
|
||||
}, function () {
|
||||
|
||||
console.log('downloading: ' + originalUrl);
|
||||
var ft = new FileTransfer();
|
||||
ft.download(originalUrl, path, function (entry) {
|
||||
|
||||
var localUrl = entry.toURL();
|
||||
|
||||
console.log(localUrl);
|
||||
deferred.resolveWith(null, [localUrl]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return deferred.promise();
|
||||
};
|
||||
|
||||
self.setImageInto = function (elem, url) {
|
||||
|
||||
function onFail() {
|
||||
setImageIntoElement(elem, url);
|
||||
}
|
||||
|
||||
self.getImageUrl(url).done(function (localUrl) {
|
||||
|
||||
setImageIntoElement(elem, localUrl);
|
||||
|
||||
}).fail(onFail);
|
||||
};
|
||||
|
||||
window.ImageStore = self;
|
||||
}
|
||||
|
||||
new indexedDbBlobImageStore();
|
||||
|
||||
})();
|
171
dashboard-ui/thirdparty/cordova/imagestore.js
vendored
171
dashboard-ui/thirdparty/cordova/imagestore.js
vendored
|
@ -11,73 +11,29 @@
|
|||
}
|
||||
}
|
||||
|
||||
function onDbOpened(imageStore, db) {
|
||||
var fileSystem;
|
||||
function getFileSystem() {
|
||||
|
||||
imageStore._db = db;
|
||||
window.ImageStore = imageStore;
|
||||
var deferred = DeferredBuilder.Deferred();
|
||||
|
||||
if (fileSystem) {
|
||||
deferred.resolveWith(null, [fileSystem]);
|
||||
} else {
|
||||
requestFileSystem(PERSISTENT, 0, function (fs) {
|
||||
fileSystem = fs;
|
||||
deferred.resolveWith(null, [fileSystem]);
|
||||
});
|
||||
}
|
||||
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
function openDb(imageStore) {
|
||||
|
||||
// Create/open database
|
||||
var db = window.sqlitePlugin.openDatabase({ name: "my.db" });
|
||||
|
||||
db.transaction(function (tx) {
|
||||
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS images (id text primary key, data text)');
|
||||
tx.executeSql('create index if not exists idx_images on images(id)');
|
||||
|
||||
onDbOpened(imageStore, db);
|
||||
});
|
||||
}
|
||||
|
||||
function sqliteImageStore() {
|
||||
function indexedDbBlobImageStore() {
|
||||
|
||||
var self = this;
|
||||
|
||||
self.addImageToDatabase = function (blob, key, deferred) {
|
||||
|
||||
console.log("addImageToDatabase");
|
||||
|
||||
self.db().transaction(function (tx) {
|
||||
|
||||
tx.executeSql("REPLACE INTO images (id, data) VALUES (?,?)", [key, blob], function (tx, res) {
|
||||
|
||||
deferred.resolve();
|
||||
}, function (e) {
|
||||
deferred.reject();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
self.db = function () {
|
||||
|
||||
return self._db;
|
||||
};
|
||||
|
||||
self.get = function (key) {
|
||||
|
||||
var deferred = DeferredBuilder.Deferred();
|
||||
|
||||
self.db().transaction(function (tx) {
|
||||
|
||||
tx.executeSql("SELECT data from images where id=?", [key], function (tx, res) {
|
||||
|
||||
if (res.rows.length) {
|
||||
|
||||
deferred.resolveWith(null, [res.rows.item(0).data]);
|
||||
} else {
|
||||
deferred.reject();
|
||||
}
|
||||
}, function (e) {
|
||||
deferred.reject();
|
||||
});
|
||||
});
|
||||
|
||||
return deferred.promise();
|
||||
};
|
||||
function getCacheKey(url) {
|
||||
|
||||
|
||||
// Try to strip off the domain to share the cache between local and remote connections
|
||||
var index = url.indexOf('://');
|
||||
|
||||
|
@ -91,89 +47,53 @@
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
return CryptoJS.MD5(url).toString();
|
||||
}
|
||||
|
||||
function normalizeReturnUrl(url) {
|
||||
if ($.browser.safari) {
|
||||
return url.replace('file://', '');
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
self.getImageUrl = function (originalUrl) {
|
||||
|
||||
console.log('getImageUrl:' + originalUrl);
|
||||
|
||||
var key = getCacheKey(originalUrl);
|
||||
if ($.browser.android && originalUrl.indexOf('tag=') != -1) {
|
||||
originalUrl += "&format=webp";
|
||||
}
|
||||
|
||||
var deferred = DeferredBuilder.Deferred();
|
||||
var key = getCacheKey(originalUrl);
|
||||
|
||||
self.get(key).done(function (url) {
|
||||
console.log('getImageUrl:' + originalUrl);
|
||||
|
||||
deferred.resolveWith(null, [url]);
|
||||
getFileSystem().done(function (fileSystem) {
|
||||
var path = fileSystem.root.toURL() + "/emby/cache/" + key;
|
||||
|
||||
}).fail(function () {
|
||||
resolveLocalFileSystemURL(path, function (fileEntry) {
|
||||
var localUrl = normalizeReturnUrl(fileEntry.toURL());
|
||||
console.log('returning cached file: ' + localUrl);
|
||||
deferred.resolveWith(null, [localUrl]);
|
||||
|
||||
self.downloadImage(originalUrl, key).done(function () {
|
||||
self.get(key).done(function (url) {
|
||||
}, function () {
|
||||
|
||||
deferred.resolveWith(null, [url]);
|
||||
console.log('downloading: ' + originalUrl);
|
||||
var ft = new FileTransfer();
|
||||
ft.download(originalUrl, path, function (entry) {
|
||||
|
||||
}).fail(function () {
|
||||
var localUrl = normalizeReturnUrl(entry.toURL());
|
||||
|
||||
deferred.reject();
|
||||
console.log(localUrl);
|
||||
deferred.resolveWith(null, [localUrl]);
|
||||
});
|
||||
}).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 arr = new Uint8Array(this.response);
|
||||
|
||||
// Convert the int array to a binary string
|
||||
// We have to use apply() as we are converting an *array*
|
||||
// and String.fromCharCode() takes one or more single values, not
|
||||
// an array.
|
||||
var raw = String.fromCharCode.apply(null, arr);
|
||||
|
||||
// This works!!!
|
||||
var b64 = btoa(raw);
|
||||
var dataURL = "data:image/jpeg;base64," + b64;
|
||||
|
||||
// Put the received blob into the database
|
||||
self.addImageToDatabase(dataURL, key, deferred);
|
||||
} catch (err) {
|
||||
console.log("Error adding image to database");
|
||||
deferred.reject();
|
||||
}
|
||||
} else {
|
||||
deferred.reject();
|
||||
}
|
||||
}, false);
|
||||
|
||||
// Send XHR
|
||||
xhr.send();
|
||||
return deferred.promise();
|
||||
};
|
||||
|
||||
self.setImageInto = function (elem, url) {
|
||||
|
||||
function onFail() {
|
||||
|
@ -181,14 +101,15 @@
|
|||
}
|
||||
|
||||
self.getImageUrl(url).done(function (localUrl) {
|
||||
|
||||
setImageIntoElement(elem, localUrl);
|
||||
|
||||
}).fail(onFail);
|
||||
};
|
||||
|
||||
openDb(self);
|
||||
window.ImageStore = self;
|
||||
}
|
||||
|
||||
new sqliteImageStore();
|
||||
new indexedDbBlobImageStore();
|
||||
|
||||
})();
|
||||
})();
|
10
dashboard-ui/thirdparty/jquery.unveil-custom.js
vendored
10
dashboard-ui/thirdparty/jquery.unveil-custom.js
vendored
|
@ -19,14 +19,10 @@
|
|||
// If less than 200, this happens on the home page
|
||||
// Need to fix those before this can be set to 0
|
||||
|
||||
// Non-ios browsers can generally handle a higher value and still perform well
|
||||
// This helps eliminate the draw-in effect as you scroll
|
||||
if (!$.browser.ipad && !$.browser.iphone) {
|
||||
return 1000;
|
||||
//return Math.max(screen.height, screen.width, 1000);
|
||||
}
|
||||
var screens = $.browser.mobile ? 2 : 1;
|
||||
|
||||
return 500;
|
||||
// This helps eliminate the draw-in effect as you scroll
|
||||
return screen.availHeight * screens;
|
||||
}
|
||||
|
||||
$.fn.unveil = function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue