jellyfin-web/dashboard-ui/cordova/android/androidcredentials.js

46 lines
1.3 KiB
JavaScript
Raw Normal View History

2015-05-28 16:37:43 -07:00
(function () {
function updateCredentials() {
console.log('sending updated credentials to ApiClientBridge');
var json = JSON.stringify(ConnectionManager.credentialProvider().credentials());
var credentials = JSON.parse(json);
for (var i = 0, length = credentials.Servers.length; i < length; i++) {
var server = credentials.Servers[i];
if (server.DateLastAccessed != null) {
server.DateLastAccessed = new Date(server.DateLastAccessed).toISOString();
}
}
json = JSON.stringify(credentials);
ApiClientBridge.updateCredentials(json);
}
function initNativeConnectionManager() {
console.log('initNativeConnectionManager');
var capabilities = ConnectionManager.capabilities();
ApiClientBridge.init(AppInfo.appName, AppInfo.appVersion, AppInfo.deviceId, AppInfo.deviceName, JSON.stringify(capabilities));
//initAjax();
}
Events.on(ConnectionManager.credentialProvider(), 'credentialsupdated', updateCredentials);
updateCredentials();
initNativeConnectionManager();
window.AndroidAjax = {
onResponse: function (id, status, response) {
Events.trigger(AndroidAjax, 'response' + id, [status, response]);
}
};
})();